• MFC Windows 程序设计>捕获鼠标


     

    In between, CMainWindow receives WM_MOUSEMOVE messages that report the cursor position even if the cursor leaves it. Client-area mouse messages continue to report cursor positions in client coordinates, but coordinates can now go negative and can also exceed the dimensions of the window's client area.

    A related function, CWnd::GetCapture, returns a CWnd pointer to the window that owns the capture. In the Win32 environment, GetCapture returns NULL if the mouse is not captured or if it's captured by a window belonging to another thread. The most common use of GetCapture is for determining whether your own window has captured the mouse. The statement

    if (GetCapture () == this)
    

    is true if and only if the window identified by this currently has the mouse captured.

    How does capturing the mouse solve the problem with the rubber-banded line? By capturing the mouse in response to a WM_LBUTTONDOWN message and releasing it when a WM_LBUTTONUP message arrives, you're guaranteed to get the WM_LBUTTONUP message when the mouse button is released. The sample program in the next section illustrates the practical effect of this technique.

     

  • 相关阅读:
    推荐]历史上最强的绕口令
    超级经理人的关系学:打造黄金人脉
    个人创业的难点和解决之道
    你的人脉关系中不可缺少的十种人[推荐]
    哲理短文一则:揭示最好的成功法则
    [经验交流]太精彩,太有启发性了(经典经典) 转
    权力领域是人才浪费的致命区域
    2006创业完全手册
    爱你我的宝贝(转)
    最远的你是我最近的爱
  • 原文地址:https://www.cnblogs.com/marryZhan/p/2213917.html
Copyright © 2020-2023  润新知