64,646
社区成员
发帖
与我相关
我的任务
分享
#include <Windows.h>
#include <iostream>
using namespace std ;
LRESULT CALLBACK ZhqProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
WNDCLASS wndclass ;
wndclass.style= CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc=ZhqProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance ;
wndclass.hIcon=LoadIcon(NULL,IDI_HAND);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)COLOR_BACKGROUND;
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName="Zhq";
RegisterClass(&wndclass);
HWND hwnd ;
hwnd=CreateWindow("Zhq","hehe",WS_OVERLAPPEDWINDOW,100,100,400,400,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
MSG msg ;
while(GetMessage(&msg,hwnd,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
LRESULT CALLBACK ZhqProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch(uMsg)
{
case WM_LBUTTONDOWN:
// double xPos = GET_X_LPARAM(lParam);
// double yPos = GET_Y_LPARAM(lParam);
POINTS points;
points=MAKEPOINTS(lParam);
cout<<points.x<<endl;
cout<<points.y<<endl;
break;
default:
DefWindowProc(
hwnd, // handle to window
uMsg, // message identifier
wParam, // first message parameter
lParam // second message parameter
);
break;
}
return 0;
}
default:
return DefWindowProc(
hwnd, // handle to window
uMsg, // message identifier
wParam, // first message parameter
lParam // second message parameter
);
break;