我这里检查帖子时发现我这里看代码有点问题 这里再发一遍LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
TCHAR psz;
static int cxChar ,cyChar, cxCount = 0, cyCount = 0;
TEXTMETRIC tm;
switch (message)
{
case WM_CREATE:
hdc = GetDC(hwnd);
GetTextMetrics(hdc, &tm);
cxChar = tm.tmAveCharWidth;
cyChar = tm.tmHeight;
ReleaseDC(hwnd, hdc);
return 0;
case WM_KEYDOWN:
case WM_CHAR:
hdc = GetDC(hwnd);
SetTextAlign(hdc, TA_LEFT | TA_TOP);
psz = (TCHAR)wParam;
TextOut(hdc, cxCount * cxChar, cyCount * cyChar, &psz, 1);
if (cxCount >= 100)
{
cxCount = 0;
cyCount += 1;
}
ReleaseDC(hwnd, hdc);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
EndPaint(hwnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
|