我用DLL 做了个子窗口  子窗口 和窗口上的按钮都是API自绘的单击按钮后在WM_COMMAND消息里能获取单击事件但是按下鼠标左键后 WM_LBUTTONDOWN  不响应 

解决方案 »

  1.   

    利用PreTranslateMessage,响应按钮控件的按下(WM_LBUTTONDOWN)和松开(WM_LBUTTONUP)。
    请参考这篇文章:
    http://blog.csdn.net/cy757/archive/2009/08/07/4424060.aspx
      

  2.   

    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消息?
      

  3.   


    在按钮上按下鼠标左键触发不了WM_LBUTTONDOWN 
    但是在按钮之外的区域就可以触发
      

  4.   

    while(::GetMessage(&msg, NULL, 0, 0))
    {
     if(WM_LBUTTONDOWN == msg.message)
     {
       // Handler ..
     }
     ::TranslateMessage(&msg);
     ::DispatchMessage(&msg);
    }
      

  5.   


    呵呵 谢谢 visualwind 
    不过我是用API 写的 DLL
    消息循环再主程序里
    所以我不知道怎么用发消息
    PreTranslateMessage
      

  6.   


    可以在GetMessage处判断WM_LBUTTONDOWN消息,也可以在窗口过程函数里面判断。但是要注意HWND一定要是你button的HWND。
      

  7.   


    谢谢 两位 问题已经解决了 但是还有个问题 就是用了while(::GetMessage(&msg, NULL, 0, 0))
    后 关闭 DLL资源部释放 这个怎么解决啊 
      

  8.   


    在WM_DESTROY时PostQuitMessage后,会跳出while(::GetMessage()),然后会自动释放资源。