WM_MOUSEFIRST       = $0200;
  WM_MOUSEMOVE        = $0200;
  WM_LBUTTONDOWN      = $0201;
  WM_LBUTTONUP        = $0202;  WM_RBUTTONDOWN      = $0204;
  WM_RBUTTONUP        = $0205;按一下笔记本左键,收到的是 $0201 -> $0202 -> $0200 三个消息按一下笔记本右键,收到的是 $0204 -> $0205 两个消息

解决方案 »

  1.   

    WM_MOUSEFIRST 一般用于過濾消息用,對應的還有WM_MOUSELAST
    如GetMessage(msg, 0, WM_MOUSEFIRST, WM_MOUSELAST )
    雙擊的話,windows自己判斷時間差產生消息:
    Only windows that have the CS_DBLCLKS style can receive WM_LBUTTONDBLCLK messages, which the system generates whenever the user presses, releases, and again presses the left mouse button within the system's double-click time limit. Double-clicking the left mouse button actually generates a sequence of four messages: WM_LBUTTONDOWN, WM_LBUTTONUP, WM_LBUTTONDBLCLK, and WM_LBUTTONUP. 其實WM_MOUSEFIRST是WM_MOUSEMOVE的別名,你可以參考messages單元部分的申明
      

  2.   


    是指双击??左键双击 $0203 -> $0202 -> $0200  三个
    右键双击 $0206 -> $0205   两个
      

  3.   

    準確地說$0200是WM_MOUSEMOVW,而不是WM_MOUSEFIRST。
    之所以測試出,左鍵單擊或雙擊會有$0200。應與你的測試方式有關。
    首先,窗口最開始不是active,雖然沒有移動cursor,但也還是可以接收到$0200;
    其次,你嘗試先右鍵單擊或雙擊,然后再單擊或雙擊左鍵,看看結果如何?
      

  4.   

    WM_MOUSEFIRST及WM_MOUSELAST僅僅表示鼠標消息的范圍,以利于過濾消息。
    與雙擊是沒有關系的。
      

  5.   

    嗯...試了一下,確實是這樣...
    討論到現在,問題的焦點是,為何單擊時也會有WM_MOUSEMOVE?
    這個問題也有人討論過,但似乎都沒有滿意的答案。
    MSDN解釋WM_MOUSEMOVE說,when cursor move才產生...
    我想,這是不是硬件上多做的行為?
    先去查證看看
      

  6.   


    最后那个测过,不是WM_mousemove,那么应该是WM_MOUSEFIRST
      

  7.   

    我想我找到了解释:接受到的WM_MOUSEMOVE其实是虚假的消息,而不是实际的硬件触发,请看下面的解释
    Why do I get spurious WM_MOUSEMOVE messages?
    In order to understand this properly, it helps to know where WM_MOUSEMOVE messages come from. When the hardware mouse reports an interrupt, indicating that the physical mouse has moved, Windows determines which thread should receive the mouse move message and sets a flag on that thread's input queue that says, "The mouse moved, in case anybody cares." (Other stuff happens, too, which we will ignore here for now. In particular, if a mouse button event arrives, a lot of bookkeeping happens to preserve the virtual input state.) When that thread calls a message retrieval function like GetMessage, and the "The mouse moved" flag is set, Windows inspects the mouse position and does the work that is commonly considered to be part of mouse movement: Determining the window that should receive the message, changing the cursor, and determining what type of message to generate (usually WM_MOUSEMOVE or perhaps WM_NCMOUSEMOVE). If you understand this, then you already see the answer to the question, "Why does my program not receive all mouse messages if the mouse is moving too fast?" If your program is slow to call GetMessage, then multiple mouse interrupts may arrive before your program calls GetMessage to pick them up. Since all that happens when the mouse interrupt occurs is that a flag is set, if two interrupts happen in succession without a message retrieval function being called, then the second interrupt will merely set a flag that is already set, which has no effect. The net effect is that the first interrupt acts as if it has been "lost" since nobody bothered to pick it up. You should also see the answer to the question, "How fast does Windows deliver mouse movement messages?" The answer is, "As fast as you want." If you call GetMessage frequently, then you get mouse messages frequently; if you call GetMessage rarely, then you get mouse messages rarely. Okay, so back to the original question, "Why do I get spurious WM_MOUSEMOVE messages?" Notice that the delivery of a mouse message includes lots of work that is typically thought of as being part of mouse movement. Often, Windows wants to do that follow-on work even though the mouse hasn't actually moved. The most obvious example is when a window is shown, hidden or moved. When that happens, the mouse cursor may be over a window different from the window it was over previously (or in the case of a move, it may be over a different part of the same window). Windows needs to recalculate the mouse cursor (for example, the old window may have wanted an arrow but the new window wants a pointy finger), so it artificially sets the "The mouse moved, in case anybody cares" flag. This causes all the follow-on work to happen, a side-effect of which is the generation of a spurious WM_MOUSEMOVE message. So if your program wants to detect whether the mouse has moved, you need to add a check in your WM_MOUSEMOVE that the mouse position is different from the position reported by the previous WM_MOUSEMOVE message. 
      

  8.   

    这是原文地址链接:
    http://blogs.msdn.com/oldnewthing/archive/2003/10/01/55108.aspx
      

  9.   


    看似能说明在用ALT+TAB时收到的wm_mouse
      

  10.   

    $0200。應與你的測試方式有關。 
    首先,窗口最開始不是active,雖然沒有移動cursor,但也還是可以接收到$0200; 
    其次,你嘗試先右鍵單擊或雙擊,然后再單擊或雙擊左鍵