The WM_LBUTTONDOWN message is posted when the user presses the left mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse.你是在Button上按下左键,想捕获WM_LBUTTONDOWN消息?
请参考这篇文章:
http://blog.csdn.net/cy757/archive/2009/08/07/4424060.aspx
在按钮上按下鼠标左键触发不了WM_LBUTTONDOWN
但是在按钮之外的区域就可以触发
{
if(WM_LBUTTONDOWN == msg.message)
{
// Handler ..
}
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
呵呵 谢谢 visualwind
不过我是用API 写的 DLL
消息循环再主程序里
所以我不知道怎么用发消息
PreTranslateMessage
可以在GetMessage处判断WM_LBUTTONDOWN消息,也可以在窗口过程函数里面判断。但是要注意HWND一定要是你button的HWND。
谢谢 两位 问题已经解决了 但是还有个问题 就是用了while(::GetMessage(&msg, NULL, 0, 0))
后 关闭 DLL资源部释放 这个怎么解决啊
在WM_DESTROY时PostQuitMessage后,会跳出while(::GetMessage()),然后会自动释放资源。