2009-10-12 03:35:35 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Character Map
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* FILE: base/applications/charmap/map.c
|
|
|
|
* PURPOSE: class implementation for painting glyph region
|
|
|
|
* COPYRIGHT: Copyright 2007 Ged Murphy <gedmurphy@reactos.org>
|
2022-11-05 23:37:18 +00:00
|
|
|
* Copyright 2022 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
2009-10-12 03:35:35 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-08-07 15:19:32 +00:00
|
|
|
#include "precomp.h"
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2014-01-04 14:06:39 +00:00
|
|
|
#include <stdlib.h>
|
2020-06-07 17:34:45 +00:00
|
|
|
#include <winnls.h>
|
2014-01-04 14:06:39 +00:00
|
|
|
|
2009-10-12 03:35:35 +00:00
|
|
|
static const WCHAR szMapWndClass[] = L"FontMapWnd";
|
|
|
|
static const WCHAR szLrgCellWndClass[] = L"LrgCellWnd";
|
|
|
|
|
2014-12-26 11:02:47 +00:00
|
|
|
#define MAX_ROWS (0xFFFF / XCELLS) + 1 - YCELLS
|
|
|
|
|
2009-10-12 03:35:35 +00:00
|
|
|
static
|
|
|
|
VOID
|
|
|
|
SetGrid(PMAP infoPtr)
|
|
|
|
{
|
|
|
|
INT x, y;
|
2022-11-05 23:37:18 +00:00
|
|
|
PCELL Cell;
|
2009-10-12 03:35:35 +00:00
|
|
|
|
|
|
|
for (y = 0; y < YCELLS; y++)
|
|
|
|
for (x = 0; x < XCELLS; x++)
|
|
|
|
{
|
2022-11-05 23:37:18 +00:00
|
|
|
Cell = &infoPtr->Cells[y][x];
|
|
|
|
Cell->CellExt.left = x * infoPtr->CellSize.cx + 1;
|
|
|
|
Cell->CellExt.top = y * infoPtr->CellSize.cy + 1;
|
|
|
|
Cell->CellExt.right = (x + 1) * infoPtr->CellSize.cx + 2;
|
|
|
|
Cell->CellExt.bottom = (y + 1) * infoPtr->CellSize.cy + 2;
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
Cell->CellInt = Cell->CellExt;
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
InflateRect(&Cell->CellInt, -1, -1);
|
2009-10-12 03:35:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
VOID
|
2022-11-05 23:37:18 +00:00
|
|
|
UpdateCells(PMAP infoPtr)
|
2009-10-12 03:35:35 +00:00
|
|
|
{
|
|
|
|
INT x, y;
|
2022-11-05 23:37:18 +00:00
|
|
|
INT i = XCELLS * infoPtr->iYStart;
|
|
|
|
WCHAR ch;
|
2011-05-16 17:46:49 +00:00
|
|
|
PCELL Cell;
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
for (y = 0; y < YCELLS; ++y)
|
2009-10-12 03:35:35 +00:00
|
|
|
{
|
2022-11-05 23:37:18 +00:00
|
|
|
for (x = 0; x < XCELLS; ++x, ++i)
|
2011-05-16 17:46:49 +00:00
|
|
|
{
|
2022-11-05 23:37:18 +00:00
|
|
|
if (i < infoPtr->NumValidGlyphs)
|
|
|
|
ch = (WCHAR)infoPtr->ValidGlyphs[i];
|
|
|
|
else
|
|
|
|
ch = 0xFFFF;
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
Cell = &infoPtr->Cells[y][x];
|
|
|
|
Cell->ch = ch;
|
2011-05-16 17:46:49 +00:00
|
|
|
}
|
|
|
|
}
|
2009-10-12 03:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
VOID
|
|
|
|
FillGrid(PMAP infoPtr,
|
2011-05-16 17:46:49 +00:00
|
|
|
PAINTSTRUCT *ps)
|
2009-10-12 03:35:35 +00:00
|
|
|
{
|
|
|
|
HFONT hOldFont;
|
|
|
|
INT x, y;
|
2011-05-16 17:46:49 +00:00
|
|
|
RECT rc;
|
|
|
|
PCELL Cell;
|
2022-11-05 23:37:18 +00:00
|
|
|
INT i;
|
|
|
|
HBRUSH hOldBrush, hbrGray = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
|
|
|
|
HPEN hOldPen, hPenGray = CreatePen(PS_SOLID, 1, RGB(140, 140, 140));
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
UpdateCells(infoPtr);
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
hOldFont = SelectObject(ps->hdc, infoPtr->hFont);
|
|
|
|
hOldPen = SelectObject(ps->hdc, GetStockObject(BLACK_PEN));
|
|
|
|
hOldBrush = SelectObject(ps->hdc, GetStockObject(WHITE_BRUSH));
|
2015-12-01 21:29:12 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
i = XCELLS * infoPtr->iYStart;
|
2016-07-13 15:50:44 +00:00
|
|
|
|
|
|
|
for (y = 0; y < YCELLS; y++)
|
2009-10-12 03:35:35 +00:00
|
|
|
{
|
2022-11-05 23:37:18 +00:00
|
|
|
for (x = 0; x < XCELLS; x++, i++)
|
2011-05-16 17:46:49 +00:00
|
|
|
{
|
2022-11-05 23:37:18 +00:00
|
|
|
Cell = &infoPtr->Cells[y][x];
|
|
|
|
if (!IntersectRect(&rc, &ps->rcPaint, &Cell->CellExt))
|
|
|
|
continue;
|
2011-05-16 17:46:49 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
rc = Cell->CellExt;
|
|
|
|
Rectangle(ps->hdc, rc.left, rc.top, rc.right, rc.bottom);
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
if (i < infoPtr->NumValidGlyphs)
|
|
|
|
{
|
|
|
|
DrawTextW(ps->hdc, &Cell->ch, 1, &Cell->CellInt,
|
|
|
|
DT_CENTER | DT_VCENTER | DT_SINGLELINE);
|
|
|
|
if (Cell == infoPtr->pActiveCell)
|
|
|
|
{
|
|
|
|
rc = Cell->CellInt;
|
|
|
|
|
|
|
|
/* Draw gray box */
|
|
|
|
SelectObject(ps->hdc, GetStockObject(NULL_BRUSH));
|
|
|
|
SelectObject(ps->hdc, hPenGray);
|
|
|
|
Rectangle(ps->hdc, rc.left, rc.top, rc.right, rc.bottom);
|
|
|
|
SelectObject(ps->hdc, hOldPen);
|
|
|
|
SelectObject(ps->hdc, hOldBrush);
|
|
|
|
|
|
|
|
if (GetFocus() == infoPtr->hMapWnd)
|
|
|
|
{
|
|
|
|
/* Draw focus rectangle */
|
|
|
|
InflateRect(&rc, -1, -1);
|
|
|
|
DrawFocusRect(ps->hdc, &rc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FillRect(ps->hdc, &Cell->CellInt, hbrGray);
|
|
|
|
}
|
2015-12-01 21:29:12 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-05 23:37:18 +00:00
|
|
|
|
|
|
|
SelectObject(ps->hdc, hOldFont);
|
|
|
|
SelectObject(ps->hdc, hOldPen);
|
|
|
|
SelectObject(ps->hdc, hOldBrush);
|
|
|
|
DeleteObject(hPenGray);
|
2009-10-12 03:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
BOOL
|
|
|
|
CreateLargeCell(PMAP infoPtr)
|
|
|
|
{
|
2022-11-05 23:37:18 +00:00
|
|
|
RECT rLarge = infoPtr->pActiveCell->CellExt;
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
MapWindowPoints(infoPtr->hMapWnd, infoPtr->hParent, (LPPOINT)&rLarge, 2);
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
InflateRect(&rLarge, XLARGE - XCELLS, YLARGE - YCELLS);
|
2009-10-12 03:35:35 +00:00
|
|
|
|
|
|
|
infoPtr->hLrgWnd = CreateWindowExW(0,
|
|
|
|
szLrgCellWndClass,
|
|
|
|
NULL,
|
|
|
|
WS_CHILDWINDOW | WS_VISIBLE,
|
|
|
|
rLarge.left,
|
|
|
|
rLarge.top,
|
|
|
|
rLarge.right - rLarge.left,
|
|
|
|
rLarge.bottom - rLarge.top,
|
|
|
|
infoPtr->hParent,
|
|
|
|
NULL,
|
|
|
|
hInstance,
|
|
|
|
infoPtr);
|
|
|
|
if (!infoPtr->hLrgWnd)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
VOID
|
|
|
|
MoveLargeCell(PMAP infoPtr)
|
|
|
|
{
|
2022-11-05 23:37:18 +00:00
|
|
|
RECT rLarge = infoPtr->pActiveCell->CellExt;
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
MapWindowPoints(infoPtr->hMapWnd, infoPtr->hParent, (LPPOINT)&rLarge, 2);
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
InflateRect(&rLarge, XLARGE - XCELLS, YLARGE - YCELLS);
|
2009-10-12 03:35:35 +00:00
|
|
|
|
|
|
|
MoveWindow(infoPtr->hLrgWnd,
|
|
|
|
rLarge.left,
|
|
|
|
rLarge.top,
|
|
|
|
rLarge.right - rLarge.left,
|
|
|
|
rLarge.bottom - rLarge.top,
|
|
|
|
TRUE);
|
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
InvalidateRect(infoPtr->hLrgWnd, NULL, TRUE);
|
2009-10-12 03:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-07 17:34:45 +00:00
|
|
|
static
|
|
|
|
VOID
|
|
|
|
GetPossibleCharacters(WCHAR* ch, INT chLen, INT codePageIdx)
|
|
|
|
{
|
|
|
|
INT i, j;
|
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
ZeroMemory(ch, sizeof(ch[0]) * chLen);
|
2020-06-07 17:34:45 +00:00
|
|
|
|
|
|
|
if (codePageIdx <= 0 || codePageIdx > SIZEOF(codePages))
|
|
|
|
{
|
|
|
|
/* this is unicode, so just load up the first MAX_GLYPHS characters
|
|
|
|
start at 0x21 to bypass whitespace characters */
|
|
|
|
INT len = min(MAX_GLYPHS, chLen);
|
|
|
|
for (i = 0x21, j = 0; i < len; i++)
|
|
|
|
ch[j++] = (WCHAR)i;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* This is a codepage, so use NLS to translate the first 256 characters */
|
|
|
|
CHAR multiByteString[256] = { 0 };
|
|
|
|
for (i = 0x21; i < SIZEOF(multiByteString); i++)
|
|
|
|
multiByteString[i] = (CHAR)i;
|
|
|
|
|
|
|
|
if (!MultiByteToWideChar(codePages[codePageIdx - 1], 0, multiByteString, sizeof(multiByteString), ch, chLen))
|
|
|
|
{
|
|
|
|
/* Failed for some reason, so clear the array */
|
|
|
|
memset(ch, 0, sizeof(ch[0]) * chLen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-12 03:35:35 +00:00
|
|
|
static
|
|
|
|
VOID
|
|
|
|
SetFont(PMAP infoPtr,
|
|
|
|
LPWSTR lpFontName)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
2015-12-01 21:29:12 +00:00
|
|
|
WCHAR ch[MAX_GLYPHS];
|
|
|
|
WORD out[MAX_GLYPHS];
|
2015-12-09 21:55:19 +00:00
|
|
|
DWORD i, j;
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2011-05-16 17:46:49 +00:00
|
|
|
/* Destroy Zoom window, since it was created with older font */
|
|
|
|
DestroyWindow(infoPtr->hLrgWnd);
|
|
|
|
infoPtr->hLrgWnd = NULL;
|
|
|
|
|
2009-10-12 03:35:35 +00:00
|
|
|
if (infoPtr->hFont)
|
|
|
|
DeleteObject(infoPtr->hFont);
|
|
|
|
|
|
|
|
ZeroMemory(&infoPtr->CurrentFont,
|
|
|
|
sizeof(LOGFONTW));
|
|
|
|
|
|
|
|
hdc = GetDC(infoPtr->hMapWnd);
|
2015-12-01 21:29:12 +00:00
|
|
|
infoPtr->CurrentFont.lfHeight = GetDeviceCaps(hdc, LOGPIXELSY) / 5;
|
2009-10-12 03:35:35 +00:00
|
|
|
|
|
|
|
infoPtr->CurrentFont.lfCharSet = DEFAULT_CHARSET;
|
2020-06-07 17:34:45 +00:00
|
|
|
lstrcpynW(infoPtr->CurrentFont.lfFaceName,
|
|
|
|
lpFontName,
|
|
|
|
SIZEOF(infoPtr->CurrentFont.lfFaceName));
|
2009-10-12 03:35:35 +00:00
|
|
|
|
|
|
|
infoPtr->hFont = CreateFontIndirectW(&infoPtr->CurrentFont);
|
|
|
|
|
|
|
|
InvalidateRect(infoPtr->hMapWnd,
|
|
|
|
NULL,
|
|
|
|
TRUE);
|
2011-05-16 17:46:49 +00:00
|
|
|
|
2015-12-01 21:29:12 +00:00
|
|
|
// Get all the valid glyphs in this font
|
|
|
|
|
|
|
|
SelectObject(hdc, infoPtr->hFont);
|
|
|
|
|
2020-06-07 17:34:45 +00:00
|
|
|
// Get the code page associated with the selected 'character set'
|
|
|
|
GetPossibleCharacters(ch, MAX_GLYPHS, infoPtr->CharMap);
|
2015-12-01 21:29:12 +00:00
|
|
|
|
|
|
|
if (GetGlyphIndicesW(hdc,
|
|
|
|
ch,
|
|
|
|
MAX_GLYPHS,
|
|
|
|
out,
|
|
|
|
GGI_MARK_NONEXISTING_GLYPHS) != GDI_ERROR)
|
|
|
|
{
|
|
|
|
j = 0;
|
2020-06-07 17:34:45 +00:00
|
|
|
for (i = 0; i < MAX_GLYPHS; i++)
|
2015-12-01 21:29:12 +00:00
|
|
|
{
|
2020-06-07 17:34:45 +00:00
|
|
|
if (out[i] != 0xffff && out[i] != 0x0000 && ch[i] != 0x0000)
|
2015-12-01 21:29:12 +00:00
|
|
|
{
|
|
|
|
infoPtr->ValidGlyphs[j] = ch[i];
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
infoPtr->NumValidGlyphs = j;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReleaseDC(infoPtr->hMapWnd, hdc);
|
|
|
|
|
2015-12-09 21:55:19 +00:00
|
|
|
infoPtr->NumRows = infoPtr->NumValidGlyphs / XCELLS;
|
2015-12-01 21:29:12 +00:00
|
|
|
if (infoPtr->NumValidGlyphs % XCELLS)
|
2015-12-09 21:55:19 +00:00
|
|
|
infoPtr->NumRows += 1;
|
|
|
|
infoPtr->NumRows = (infoPtr->NumRows > YCELLS) ? infoPtr->NumRows - YCELLS : 0;
|
2015-12-01 21:29:12 +00:00
|
|
|
|
2015-12-09 21:55:19 +00:00
|
|
|
SetScrollRange(infoPtr->hMapWnd, SB_VERT, 0, infoPtr->NumRows, FALSE);
|
|
|
|
SetScrollPos(infoPtr->hMapWnd, SB_VERT, 0, TRUE);
|
|
|
|
infoPtr->iYStart = 0;
|
2009-10-12 03:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
LRESULT
|
|
|
|
NotifyParentOfSelection(PMAP infoPtr,
|
|
|
|
UINT code,
|
|
|
|
WCHAR ch)
|
|
|
|
{
|
|
|
|
LRESULT Ret = 0;
|
|
|
|
|
|
|
|
if (infoPtr->hParent != NULL)
|
|
|
|
{
|
|
|
|
DWORD dwIdc = GetWindowLongPtr(infoPtr->hMapWnd, GWLP_ID);
|
|
|
|
/*
|
|
|
|
* Push directly into the event queue instead of waiting
|
|
|
|
* the parent to be unlocked.
|
|
|
|
* High word of LPARAM is still available for future needs...
|
|
|
|
*/
|
|
|
|
Ret = PostMessage(infoPtr->hParent,
|
|
|
|
WM_COMMAND,
|
|
|
|
MAKELPARAM((WORD)dwIdc, (WORD)code),
|
|
|
|
(LPARAM)LOWORD(ch));
|
|
|
|
}
|
|
|
|
|
|
|
|
return Ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
VOID
|
2022-11-05 23:37:18 +00:00
|
|
|
LimitCaretXY(PMAP infoPtr, INT *pX, INT *pY)
|
2009-10-12 03:35:35 +00:00
|
|
|
{
|
2022-11-05 23:37:18 +00:00
|
|
|
INT i, X = *pX, Y = *pY, iYStart = infoPtr->iYStart;
|
2020-06-07 17:34:45 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
i = XCELLS * (iYStart + Y) + X;
|
|
|
|
while (i >= infoPtr->NumValidGlyphs)
|
2020-06-07 17:34:45 +00:00
|
|
|
{
|
2022-11-05 23:37:18 +00:00
|
|
|
if (X > 0)
|
|
|
|
{
|
|
|
|
--X;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
X = XCELLS - 1;
|
|
|
|
--Y;
|
|
|
|
}
|
|
|
|
i = XCELLS * (iYStart + Y) + X;
|
2020-06-07 17:34:45 +00:00
|
|
|
}
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
*pX = X;
|
|
|
|
*pY = Y;
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
VOID
|
|
|
|
SetCaretXY(PMAP infoPtr, INT X, INT Y, BOOL bLarge, BOOL bInvalidateAll)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* set previous active cell to inactive */
|
|
|
|
if (!bInvalidateAll)
|
2009-10-12 03:35:35 +00:00
|
|
|
{
|
2022-11-05 23:37:18 +00:00
|
|
|
InvalidateRect(infoPtr->hMapWnd,
|
|
|
|
&infoPtr->pActiveCell->CellInt,
|
|
|
|
FALSE);
|
|
|
|
}
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
LimitCaretXY(infoPtr, &X, &Y);
|
|
|
|
infoPtr->CaretX = X;
|
|
|
|
infoPtr->CaretY = Y;
|
|
|
|
UpdateCells(infoPtr);
|
2020-04-15 21:31:16 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
/* set new cell to active */
|
|
|
|
infoPtr->pActiveCell = &infoPtr->Cells[Y][X];
|
|
|
|
if (!bInvalidateAll)
|
|
|
|
{
|
|
|
|
InvalidateRect(infoPtr->hMapWnd,
|
|
|
|
&infoPtr->pActiveCell->CellInt,
|
|
|
|
FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create if needed */
|
|
|
|
if (bLarge)
|
|
|
|
{
|
2020-04-15 21:31:16 +00:00
|
|
|
if (infoPtr->hLrgWnd)
|
|
|
|
MoveLargeCell(infoPtr);
|
|
|
|
else
|
|
|
|
CreateLargeCell(infoPtr);
|
2009-10-12 03:35:35 +00:00
|
|
|
}
|
2022-11-05 23:37:18 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Destroy large window */
|
|
|
|
if (infoPtr->hLrgWnd)
|
|
|
|
{
|
|
|
|
DestroyWindow(infoPtr->hLrgWnd);
|
|
|
|
infoPtr->hLrgWnd = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bInvalidateAll)
|
|
|
|
InvalidateRect(infoPtr->hMapWnd, NULL, FALSE);
|
|
|
|
|
|
|
|
UpdateStatusBar(infoPtr->pActiveCell->ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
VOID
|
|
|
|
OnClick(PMAP infoPtr,
|
|
|
|
WORD ptx,
|
|
|
|
WORD pty)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Find the cell the mouse pointer is over.
|
|
|
|
* Since each cell is the same size, this can be done quickly using CellSize.
|
|
|
|
* Clamp to XCELLS - 1 and YCELLS - 1 because the map can sometimes be slightly
|
|
|
|
* larger than infoPtr.CellSize * XCELLS , due to the map size being a non integer
|
|
|
|
* multiple of infoPtr.CellSize .
|
|
|
|
*/
|
|
|
|
INT x = min(XCELLS - 1, ptx / max(1, infoPtr->CellSize.cx));
|
|
|
|
INT y = min(YCELLS - 1, pty / max(1, infoPtr->CellSize.cy));
|
|
|
|
|
|
|
|
SetCaretXY(infoPtr, x, y, TRUE, FALSE);
|
2009-10-12 03:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
BOOL
|
2017-12-23 12:46:14 +00:00
|
|
|
MapOnCreate(PMAP infoPtr,
|
|
|
|
HWND hwnd,
|
|
|
|
HWND hParent)
|
2009-10-12 03:35:35 +00:00
|
|
|
{
|
|
|
|
RECT rc;
|
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
infoPtr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(MAP));
|
|
|
|
if (!infoPtr)
|
|
|
|
return FALSE;
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
SetWindowLongPtrW(hwnd, 0, (LONG_PTR)infoPtr);
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
infoPtr->hMapWnd = hwnd;
|
|
|
|
infoPtr->hParent = hParent;
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
GetClientRect(hwnd, &rc);
|
|
|
|
infoPtr->ClientSize.cx = rc.right;
|
|
|
|
infoPtr->ClientSize.cy = rc.bottom;
|
|
|
|
infoPtr->CellSize.cx = infoPtr->ClientSize.cx / XCELLS;
|
|
|
|
infoPtr->CellSize.cy = infoPtr->ClientSize.cy / YCELLS;
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
infoPtr->pActiveCell = &infoPtr->Cells[0][0];
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
SetGrid(infoPtr);
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
SetScrollPos(infoPtr->hParent, SB_VERT, 0, TRUE);
|
|
|
|
return TRUE;
|
2009-10-12 03:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
VOID
|
|
|
|
OnVScroll(PMAP infoPtr,
|
|
|
|
INT Value,
|
|
|
|
INT Pos)
|
|
|
|
{
|
|
|
|
INT iYDiff, iOldYStart = infoPtr->iYStart;
|
2022-11-05 23:37:18 +00:00
|
|
|
INT X, Y;
|
2009-10-12 03:35:35 +00:00
|
|
|
|
|
|
|
switch (Value)
|
|
|
|
{
|
|
|
|
case SB_LINEUP:
|
|
|
|
infoPtr->iYStart -= 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SB_LINEDOWN:
|
|
|
|
infoPtr->iYStart += 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SB_PAGEUP:
|
|
|
|
infoPtr->iYStart -= YCELLS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SB_PAGEDOWN:
|
|
|
|
infoPtr->iYStart += YCELLS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SB_THUMBTRACK:
|
|
|
|
infoPtr->iYStart = Pos;
|
|
|
|
break;
|
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
case SB_TOP:
|
|
|
|
infoPtr->iYStart = 0;
|
|
|
|
SetCaretXY(infoPtr, 0, 0, FALSE, TRUE);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case SB_BOTTOM:
|
|
|
|
infoPtr->iYStart = infoPtr->NumRows;
|
|
|
|
SetCaretXY(infoPtr, XCELLS - 1, YCELLS - 1, FALSE, TRUE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2009-10-12 03:35:35 +00:00
|
|
|
break;
|
2022-11-05 23:37:18 +00:00
|
|
|
}
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2015-12-09 21:55:19 +00:00
|
|
|
infoPtr->iYStart = max(0, infoPtr->iYStart);
|
|
|
|
infoPtr->iYStart = min(infoPtr->iYStart, infoPtr->NumRows);
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
UpdateCells(infoPtr);
|
|
|
|
|
|
|
|
X = infoPtr->CaretX;
|
|
|
|
Y = infoPtr->CaretY;
|
|
|
|
LimitCaretXY(infoPtr, &X, &Y);
|
|
|
|
SetCaretXY(infoPtr, X, Y, IsWindow(infoPtr->hLrgWnd), FALSE);
|
|
|
|
|
2009-10-12 03:35:35 +00:00
|
|
|
iYDiff = iOldYStart - infoPtr->iYStart;
|
|
|
|
if (iYDiff)
|
|
|
|
{
|
2011-05-16 17:46:49 +00:00
|
|
|
if (infoPtr->hLrgWnd != NULL)
|
|
|
|
{
|
|
|
|
ShowWindow(infoPtr->hLrgWnd, SW_HIDE);
|
|
|
|
}
|
|
|
|
|
2009-10-12 03:35:35 +00:00
|
|
|
SetScrollPos(infoPtr->hMapWnd,
|
|
|
|
SB_VERT,
|
|
|
|
infoPtr->iYStart,
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
if (abs(iYDiff) < YCELLS)
|
|
|
|
{
|
|
|
|
RECT rect;
|
2020-06-07 17:34:45 +00:00
|
|
|
|
|
|
|
/* Invalidate the rect around the active cell since a new cell will become active */
|
2022-11-05 23:37:18 +00:00
|
|
|
if (infoPtr->pActiveCell)
|
2020-06-07 17:34:45 +00:00
|
|
|
{
|
2021-09-13 01:33:14 +00:00
|
|
|
InvalidateRect(infoPtr->hMapWnd,
|
|
|
|
&infoPtr->pActiveCell->CellExt,
|
2020-06-07 17:34:45 +00:00
|
|
|
TRUE);
|
|
|
|
}
|
2021-09-13 01:33:14 +00:00
|
|
|
|
2009-10-12 03:35:35 +00:00
|
|
|
GetClientRect(infoPtr->hMapWnd, &rect);
|
|
|
|
rect.top += 2;
|
|
|
|
rect.bottom -= 2;
|
|
|
|
ScrollWindowEx(infoPtr->hMapWnd,
|
|
|
|
0,
|
|
|
|
iYDiff * infoPtr->CellSize.cy,
|
|
|
|
&rect,
|
|
|
|
&rect,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
SW_INVALIDATE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
InvalidateRect(infoPtr->hMapWnd,
|
|
|
|
NULL,
|
|
|
|
TRUE);
|
|
|
|
}
|
2011-05-16 17:46:49 +00:00
|
|
|
|
|
|
|
if (infoPtr->hLrgWnd != NULL)
|
|
|
|
{
|
|
|
|
ShowWindow(infoPtr->hLrgWnd, SW_SHOW);
|
|
|
|
}
|
2009-10-12 03:35:35 +00:00
|
|
|
}
|
2022-11-05 23:37:18 +00:00
|
|
|
|
|
|
|
UpdateStatusBar(infoPtr->pActiveCell->ch);
|
2009-10-12 03:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
VOID
|
|
|
|
OnPaint(PMAP infoPtr,
|
|
|
|
WPARAM wParam)
|
|
|
|
{
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
HDC hdc;
|
|
|
|
|
|
|
|
if (wParam != 0)
|
|
|
|
{
|
2022-11-05 23:37:18 +00:00
|
|
|
if (!GetUpdateRect(infoPtr->hMapWnd, &ps.rcPaint, TRUE))
|
2009-10-12 03:35:35 +00:00
|
|
|
return;
|
2022-11-05 23:37:18 +00:00
|
|
|
|
2015-09-04 20:02:25 +00:00
|
|
|
ps.hdc = (HDC)wParam;
|
2009-10-12 03:35:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-11-05 23:37:18 +00:00
|
|
|
hdc = BeginPaint(infoPtr->hMapWnd, &ps);
|
2009-10-12 03:35:35 +00:00
|
|
|
if (hdc == NULL)
|
2022-11-05 23:37:18 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
FillGrid(infoPtr, &ps);
|
|
|
|
|
|
|
|
if (wParam == 0)
|
|
|
|
{
|
|
|
|
EndPaint(infoPtr->hMapWnd, &ps);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
VOID
|
|
|
|
MoveUpDown(PMAP infoPtr, INT DY)
|
|
|
|
{
|
|
|
|
INT Y = infoPtr->CaretY;
|
|
|
|
|
|
|
|
if (DY < 0) /* Move Up */
|
|
|
|
{
|
|
|
|
if (Y <= 0)
|
2009-10-12 03:35:35 +00:00
|
|
|
{
|
2022-11-05 23:37:18 +00:00
|
|
|
SendMessageW(infoPtr->hMapWnd, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
|
2009-10-12 03:35:35 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-11-05 23:37:18 +00:00
|
|
|
|
|
|
|
Y -= 1;
|
2009-10-12 03:35:35 +00:00
|
|
|
}
|
2022-11-05 23:37:18 +00:00
|
|
|
else if (DY > 0) /* Move Down */
|
|
|
|
{
|
|
|
|
if (Y + 1 >= YCELLS)
|
|
|
|
{
|
|
|
|
SendMessageW(infoPtr->hMapWnd, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
|
|
|
|
return;
|
|
|
|
}
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
Y += 1;
|
|
|
|
}
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
SetCaretXY(infoPtr, infoPtr->CaretX, Y, IsWindow(infoPtr->hLrgWnd), FALSE);
|
|
|
|
}
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
static
|
|
|
|
VOID
|
|
|
|
MoveLeftRight(PMAP infoPtr, INT DX)
|
|
|
|
{
|
|
|
|
INT X = infoPtr->CaretX;
|
|
|
|
INT Y = infoPtr->CaretY;
|
|
|
|
|
|
|
|
if (DX < 0) /* Move Left */
|
|
|
|
{
|
|
|
|
if (X <= 0) /* at left edge */
|
|
|
|
{
|
|
|
|
if (Y <= 0) /* at top */
|
|
|
|
{
|
|
|
|
Y = 0;
|
|
|
|
if (infoPtr->iYStart > 0)
|
|
|
|
X = XCELLS - 1;
|
|
|
|
SendMessageW(infoPtr->hMapWnd, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
X = XCELLS - 1;
|
|
|
|
Y -= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* Not at left edge */
|
|
|
|
{
|
|
|
|
X -= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (DX > 0) /* Move Right */
|
2009-10-12 03:35:35 +00:00
|
|
|
{
|
2022-11-05 23:37:18 +00:00
|
|
|
if (X + 1 >= XCELLS) /* at right edge */
|
|
|
|
{
|
|
|
|
if (Y + 1 >= YCELLS) /* at bottom */
|
|
|
|
{
|
|
|
|
Y = YCELLS - 1;
|
|
|
|
if (infoPtr->iYStart < infoPtr->NumRows)
|
|
|
|
X = 0;
|
|
|
|
SendMessageW(infoPtr->hMapWnd, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
X = 0;
|
|
|
|
Y += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
X += 1;
|
|
|
|
}
|
2009-10-12 03:35:35 +00:00
|
|
|
}
|
2022-11-05 23:37:18 +00:00
|
|
|
|
|
|
|
SetCaretXY(infoPtr, X, Y, IsWindow(infoPtr->hLrgWnd), FALSE);
|
2009-10-12 03:35:35 +00:00
|
|
|
}
|
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
static
|
|
|
|
VOID
|
|
|
|
OnKeyDown(PMAP infoPtr, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
BOOL bCtrlDown = (GetKeyState(VK_CONTROL) < 0);
|
|
|
|
|
|
|
|
switch (wParam)
|
|
|
|
{
|
|
|
|
case VK_UP:
|
|
|
|
if (bCtrlDown)
|
|
|
|
SetCaretXY(infoPtr, infoPtr->CaretX, 0, FALSE, FALSE);
|
|
|
|
else
|
|
|
|
MoveUpDown(infoPtr, -1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_DOWN:
|
|
|
|
if (bCtrlDown)
|
|
|
|
SetCaretXY(infoPtr, infoPtr->CaretX, YCELLS - 1, FALSE, FALSE);
|
|
|
|
else
|
|
|
|
MoveUpDown(infoPtr, +1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_LEFT:
|
|
|
|
if (bCtrlDown)
|
|
|
|
SetCaretXY(infoPtr, 0, infoPtr->CaretY, FALSE, FALSE);
|
|
|
|
else
|
|
|
|
MoveLeftRight(infoPtr, -1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_RIGHT:
|
|
|
|
if (bCtrlDown)
|
|
|
|
SetCaretXY(infoPtr, XCELLS - 1, infoPtr->CaretY, FALSE, FALSE);
|
|
|
|
else
|
|
|
|
MoveLeftRight(infoPtr, +1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_PRIOR: /* Page Up */
|
|
|
|
SendMessageW(infoPtr->hMapWnd, WM_VSCROLL, MAKEWPARAM(SB_PAGEUP, 0), 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_NEXT: /* Page Down */
|
|
|
|
SendMessageW(infoPtr->hMapWnd, WM_VSCROLL, MAKEWPARAM(SB_PAGEDOWN, 0), 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_HOME:
|
|
|
|
if (bCtrlDown)
|
|
|
|
SendMessageW(infoPtr->hMapWnd, WM_VSCROLL, MAKEWPARAM(SB_TOP, 0), 0);
|
|
|
|
else
|
|
|
|
SetCaretXY(infoPtr, 0, infoPtr->CaretY, FALSE, FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_END:
|
|
|
|
if (bCtrlDown)
|
|
|
|
SendMessageW(infoPtr->hMapWnd, WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
|
|
|
|
else
|
|
|
|
SetCaretXY(infoPtr, XCELLS - 1, infoPtr->CaretY, FALSE, FALSE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-10-12 03:35:35 +00:00
|
|
|
|
|
|
|
LRESULT
|
|
|
|
CALLBACK
|
|
|
|
MapWndProc(HWND hwnd,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
2022-11-05 23:37:18 +00:00
|
|
|
PMAP infoPtr = (PMAP)GetWindowLongPtrW(hwnd, 0);
|
2009-10-12 03:35:35 +00:00
|
|
|
LRESULT Ret = 0;
|
2020-06-07 17:34:45 +00:00
|
|
|
WCHAR lfFaceName[LF_FACESIZE];
|
2009-10-12 03:35:35 +00:00
|
|
|
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_CREATE:
|
|
|
|
{
|
2017-12-23 12:46:14 +00:00
|
|
|
if (!MapOnCreate(infoPtr,
|
|
|
|
hwnd,
|
|
|
|
((LPCREATESTRUCTW)lParam)->hwndParent))
|
2009-10-12 03:35:35 +00:00
|
|
|
{
|
|
|
|
return (LRESULT)-1;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
case WM_KEYDOWN:
|
2009-10-12 03:35:35 +00:00
|
|
|
{
|
2022-11-05 23:37:18 +00:00
|
|
|
OnKeyDown(infoPtr, wParam, lParam);
|
|
|
|
break;
|
|
|
|
}
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
{
|
|
|
|
SetFocus(hwnd);
|
|
|
|
OnClick(infoPtr, LOWORD(lParam), HIWORD(lParam));
|
2009-10-12 03:35:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-04-15 21:31:16 +00:00
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
{
|
|
|
|
if (wParam & MK_LBUTTON)
|
|
|
|
{
|
2022-11-05 23:37:18 +00:00
|
|
|
OnClick(infoPtr, LOWORD(lParam), HIWORD(lParam));
|
2020-04-15 21:31:16 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-10-12 03:35:35 +00:00
|
|
|
case WM_LBUTTONDBLCLK:
|
|
|
|
{
|
2022-11-05 23:37:18 +00:00
|
|
|
if (!infoPtr->pActiveCell || GetFocus() != hwnd)
|
2020-06-07 17:34:45 +00:00
|
|
|
break;
|
|
|
|
|
2009-10-12 03:35:35 +00:00
|
|
|
NotifyParentOfSelection(infoPtr,
|
|
|
|
FM_SETCHAR,
|
|
|
|
infoPtr->pActiveCell->ch);
|
|
|
|
|
2022-11-05 23:37:18 +00:00
|
|
|
if (infoPtr->hLrgWnd)
|
2020-04-15 21:31:16 +00:00
|
|
|
{
|
|
|
|
DestroyWindow(infoPtr->hLrgWnd);
|
|
|
|
infoPtr->hLrgWnd = NULL;
|
|
|
|
}
|
2009-10-12 03:35:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_VSCROLL:
|
|
|
|
{
|
2022-11-05 23:37:18 +00:00
|
|
|
OnVScroll(infoPtr, LOWORD(wParam), HIWORD(wParam));
|
2009-10-12 03:35:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-06-07 17:34:45 +00:00
|
|
|
case FM_SETCHARMAP:
|
2022-11-05 23:37:18 +00:00
|
|
|
infoPtr->CaretX = infoPtr->CaretY = infoPtr->iYStart = 0;
|
2020-06-07 17:34:45 +00:00
|
|
|
infoPtr->CharMap = LOWORD(wParam);
|
|
|
|
wcsncpy(lfFaceName,
|
|
|
|
infoPtr->CurrentFont.lfFaceName,
|
|
|
|
SIZEOF(lfFaceName));
|
|
|
|
SetFont(infoPtr, lfFaceName);
|
|
|
|
break;
|
|
|
|
|
2009-10-12 03:35:35 +00:00
|
|
|
case FM_SETFONT:
|
2022-11-05 23:37:18 +00:00
|
|
|
infoPtr->CaretX = infoPtr->CaretY = infoPtr->iYStart = 0;
|
2009-10-12 03:35:35 +00:00
|
|
|
SetFont(infoPtr, (LPWSTR)lParam);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FM_GETCHAR:
|
|
|
|
{
|
|
|
|
if (!infoPtr->pActiveCell) return 0;
|
|
|
|
return infoPtr->pActiveCell->ch;
|
|
|
|
}
|
|
|
|
|
2011-02-20 10:55:48 +00:00
|
|
|
case FM_GETHFONT:
|
|
|
|
return (LRESULT)infoPtr->hFont;
|
|
|
|
|
2009-10-12 03:35:35 +00:00
|
|
|
case WM_PAINT:
|
2022-11-05 23:37:18 +00:00
|
|
|
OnPaint(infoPtr, wParam);
|
2009-10-12 03:35:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
DeleteObject(infoPtr->hFont);
|
2022-11-05 23:37:18 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, infoPtr);
|
|
|
|
SetWindowLongPtrW(hwnd, 0, (LONG_PTR)NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_GETDLGCODE:
|
|
|
|
return DLGC_WANTARROWS;
|
|
|
|
|
|
|
|
case WM_SETFOCUS:
|
|
|
|
case WM_KILLFOCUS:
|
|
|
|
if (!infoPtr->hLrgWnd)
|
|
|
|
InvalidateRect(hwnd, &(infoPtr->pActiveCell->CellInt), FALSE);
|
2009-10-12 03:35:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2022-11-05 23:37:18 +00:00
|
|
|
Ret = DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
2009-10-12 03:35:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
RegisterMapClasses(HINSTANCE hInstance)
|
|
|
|
{
|
|
|
|
WNDCLASSW wc = {0};
|
|
|
|
|
|
|
|
wc.style = CS_DBLCLKS;
|
|
|
|
wc.lpfnWndProc = MapWndProc;
|
|
|
|
wc.cbWndExtra = sizeof(PMAP);
|
|
|
|
wc.hInstance = hInstance;
|
|
|
|
wc.hCursor = LoadCursorW(NULL,
|
|
|
|
(LPWSTR)IDC_ARROW);
|
|
|
|
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
|
|
|
wc.lpszClassName = szMapWndClass;
|
|
|
|
|
|
|
|
if (RegisterClassW(&wc))
|
|
|
|
{
|
|
|
|
wc.lpfnWndProc = LrgCellWndProc;
|
|
|
|
wc.cbWndExtra = 0;
|
|
|
|
wc.lpszClassName = szLrgCellWndClass;
|
|
|
|
|
|
|
|
return RegisterClassW(&wc) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
UnregisterMapClasses(HINSTANCE hInstance)
|
|
|
|
{
|
2022-11-05 23:37:18 +00:00
|
|
|
UnregisterClassW(szMapWndClass, hInstance);
|
|
|
|
UnregisterClassW(szLrgCellWndClass, hInstance);
|
2009-10-12 03:35:35 +00:00
|
|
|
}
|