谢谢~

解决方案 »

  1.   

    http://topic.csdn.net/u/20090116/23/186dd833-cf6b-4af8-9467-ae8ad54f384b.html
    这个也许对楼主有帮助
      

  2.   

    这里有比较好的解释:
    ------------------------------
    关于 WM_NCLBUTTONUP 消息
    WM_NCLBUTTONDOWN 消息的使用体会:
     
    当窗口不是最大化时, 鼠标在标题栏上按下去时会产生 WM_NCLBUTTONDOWN 消息, 鼠标释放时却不会收到 WM_NCLBUTTONUP 消息, 感觉很奇怪, MSDN上的解释:
    The WM_NCLBUTTONUP message is posted when the user releases the left mouse button while the cursor is within the nonclient area of a window. This message is posted to the window that contains the cursor. If a window has captured the mouse, this message is not posted. 
    WM_NCLBUTTONUP 
    nHittest = (INT) wParam;    // hit-test value 
    pts = MAKEPOINTS(lParam);   // mouse-cursor coordinates 
    不过更奇怪的是当鼠标在标题栏上按下去再弹起时用 Spy++ 可以看到程序有抛出 WM_LBUTTONUP 消息 , 应用程序却没有收到这个消息. 为什么会这样?!
    看MFC的源码, 没看出什么来, 到网上找资料,比较多的是用 Mouse Hook 来解决的, 而且也没有说明原因, 这儿是用 Mouse Hook 方式的解决办法:
    http://www.codeguru.com/Cpp/misc/misc/windowsmessaging/article.php/c3885/
    呵呵, 个人感觉比较笨拙, 后面又在 www.codeguru.com 上找到的另外一种解决办法,并且有说明了为什么会产生用 Spy++可以看见, 应用程序却没有收到消息的原因:
    AlanMason :  WM_NCLBUTTONUP not posted
    Alex Fedotov:  The problem is that to implement window movementand resizing, DefWindowProc organizes its own message loop. The WM_LBUTTONUP message is posted to the thread's message queue, but it is fetched in that internal message loop and not in the mainapplication message loop, so the application does not see the message. A possible solution is to install a thread-localmouse hook. It might look like an overkill, but should work - the hook should receive that message. Another way is to poll mouse status calling GetKeyState(VK_LBUTTON) on a timer. This methodlooks not so reliable for me, as the mouse button might be released and pressed again between timer events. Finally, you can process WM_EXITSIZEMOVE message. This message is sent to a window after it has exited the moving or sizing modal loop. This applies toboth mouse and keyboard way of doing that.原文见: http://www.codeguru.com/forum/showthread.php?t=172016
     
    什么时候会收到这个消息, 根据网上收集的资料和个人经验, 有三种情况:
    1. 当在标题栏双击时会产生
    2. 当窗口最大化时, 单击标题栏等非客户区会产生
    3. 在客户区按下鼠标左键, 移动鼠标到非客户区, 松开鼠标左键会产生.
      

  3.   

    应该是你的标题栏(很可能是那几个按钮的消息)在鼠标压下时使用了SetCapture(hwnd),这时弹起消息是WM_LBUTTONUP,而不是WM_NCLBUTTONUP,看看你标题栏上的按钮在压下时移动到窗口外是不是恢复原状应该就能判断了··
      

  4.   

    此问题已解,具体方法是在OnNCLBUTTONDOWN时不去调用父类的,具体不说了...
    ---------------
    各位大侠的提供的方法有时间研究下,...谢谢各位!!
      

  5.   

    另外,VisualEleven说的三种情况不好区分,先放下