我需要知道激活 WM_COMMAND 时按钮单击的 x 和 y 坐标
我创建了一个按钮,
//Create Compass
HWND hWndCompass = CreateWindowEx(NULL, "BUTTON", "Compass", WS_TABSTOP|WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON,
600, 10, 50, 24, hWnd, (HMENU)IDC_COMPASS, GetModuleHandle(NULL), NULL);
我将在将来添加图片,但我需要知道他们单击按钮上的位置,以便我可以确定他们是否单击了 N、S、E、W 或指南针的其他点。
我的电话是:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
我需要在消息中查找该信息吗?
I have a button created with
//Create Compass
HWND hWndCompass = CreateWindowEx(NULL, "BUTTON", "Compass", WS_TABSTOP|WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON,
600, 10, 50, 24, hWnd, (HMENU)IDC_COMPASS, GetModuleHandle(NULL), NULL);
I will add the picture in the future but I need to know where on the button they clicked so I can determine if they clicked on N, S, E, W or some other point of the compass.
My call is:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Do I need to look in the message for that infomration?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了检索鼠标单击按钮的 X 和 Y 坐标,您应该:
WM_MOUSEMOVE
事件wParam 将为您提供事件类型(按下了哪个按钮)
lParam
检索坐标类似的内容:
In order to retrieve the X and Y coordinates of a mouse click on your button, you should :
WM_MOUSEMOVE
eventwParam
will give you the type of event (Which button has been pressed)lParam
Something like that :