70,037
社区成员
发帖
与我相关
我的任务
分享
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
MoveToEx(hdc, 1, 1, NULL);
LineTo(hdc, 100,100);
TextOut(hdc, 100, 100, "helloworld!", strlen("helloworld!"));
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
POINT s_mousePos; // Global variable.
case WM_PAINT:
TCHAR buf[1024];
sprintf(buf, _T("(%d, %d)"), s_mousePos.x, s_mousePos.y);
TextOut(..., buf); // Can't remember, refer to MSDN.
case WM_MOUSEMOVE:
s_mousePos.x = GET_X_LPARAM(lParam);
s_mousePos.y = GET_Y_LPARAM(lParam);
UpdateWindow();