如何写测试程序。

解决方案 »

  1.   

    应该是各两次,左键双击时第一次发出的消息应该是LButtonDown
      

  2.   

    应该是各两次: LButtonDown->LButtonUp->LButtonDown->LButtonUp
      

  3.   

    我刚才测试了一下,Down是一次,Up是两次,呵呵,终于借这个机会把这个问题搞清楚了,呵呵
      

  4.   

    //在对话框类的构造函数中给下面两个成员变量赋值;
    m_iNumDown = 0;
    m_iNumUp = 0;//增加下面的函数和代码,调试就可以了;
    BOOL CYourDlg::PreTranslateMessage(MSG* pMsg) 
    {
    // TODO: Add your specialized code here and/or call the base class
    if(pMsg->message == WM_LBUTTONUP)
    m_iNumDown++;
    if(pMsg->message == WM_LBUTTONDOWN)
    m_iNumUp++;
    if(pMsg->message == WM_KEYDOWN)
    int i = 0;//此语句无用,只为了在此设置断点,你在对话框上双击鼠标                          //左键后,按下任意键,就可以看到m_iNumDown、m_iNumUp了

    return CDialog::PreTranslateMessage(pMsg);
    }
      

  5.   

    我用了自己的测试程序,结果和 fengqinggao(风清高) 是一样的。用了spy++,发现是两次down,一次up,没有doublebclick,是不是我看错了地方。在spy中怎样设置成不显示客户区的mousemove事件。至于AthlonxpX86(一滴水) 等人的回答,我真不知道这怎么算得上是一个无聊的问题。在我的程序中,按照目前的思路,需要区分up、down和doubleclick事件,也许实现程序的功能有其它的也许是更好的方法,但我问这样一个问题绝对不能称为无聊,而只能说你没有想到它的用处罢了。看在你的红星星的份上,姑且称你为“智者”,送你一句“智者千虑,必有一失”吧。
      

  6.   

    : LButtonDown->LButtonUp->LButtonDown->LButtonUp
      

  7.   

    单击和双击的消息发送的时间是在按下鼠标键后,放开鼠标键之前的瞬间触发的(在这之后马上触发鼠标键Up事件),所以双击应该是两次down,一次up在MSDN上WM_LBUTTONDGLCLK消息的说明上也能看出来
    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.
      

  8.   

    LButtonDown
    LButtonUp
    DbClick   //here
    LButtonUp
      

  9.   

    up!
    拦截一下消息不就知道了。如果你太关注次数的话。VC里拦截消息很简单的事情啊!
      

  10.   

    <<windows 程序设计>>如果希望您的视窗讯息处理程式能够收到双按键的滑鼠讯息,那么在呼叫RegisterClass初始化视窗类别结构时,必须在视窗风格中包含CS_DBLCLKS识别字:wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS ;
    如果在视窗风格中未包含CS_DBLCLKS,而使用者在短时间内双击了滑鼠按键,那么视窗讯息处理程式会接收到下面这些讯息:WM_LBUTTONDOWNWM_LBUTTONUPWM_LBUTTONDOWNWM_LBUTTONUP视窗讯息处理程式可能在这些键的讯息之前还收到了其他讯息。如果您想实作自己的双击处理,那么您可以使用Windows函式GetMessageTime取得WM_LBUTTONDOWN讯息之间的相对时间。第八章将更详细地讨论这个函式。如果您的视窗类别风格中包含了CS_DBLCLKS,那么双击时视窗讯息处理程式将收到如下讯息:WM_LBUTTONDOWNWM_LBUTTONUPWM_LBUTTONDBLCLKWM_LBUTTONUPWM_LBUTTONDBLCLK讯息简单地替换了第二个WM_LBUTTONDOWN讯息。
      

  11.   

    From 《Programming Windows with MFC》When two clicks of the same button occur within a very short period of time, the second button-down message is replaced by a WM_xBUTTONDBLCLK message. Significantly, this happens only if the window's WNDCLASS includes the class style CS_DBLCLKS. The default WNDCLASS that MFC registers for frame windows has this style, so frame windows receive double-click messages by default. For a CS_DBLCLKS-style window, two rapid clicks of the left mouse button over the window's client area produce the following sequence of messages:WM_LBUTTONDOWN
    WM_LBUTTONUP
    WM_LBUTTONDBLCLK
    WM_LBUTTONUP If the window is not registered to be notified of double clicks, however, the same two button clicks produce the following sequence of messages:WM_LBUTTONDOWN
    WM_LBUTTONUP
    WM_LBUTTONDOWN
    WM_LBUTTONUP
     
      

  12.   

    谢谢各位。
    应该是两次up,一次down。不过是从MSDN中看到的,在spy中我还没有试出来,等忙完这个项目去学学spy的用法,到时再用它来验证。
    以下是从MSDN有关CWnd::OnLButtonDblClk的说明中摘录的。
    The framework calls this member function when the user double-clicks the left mouse button. 
    Only windows that have the CS_DBLCLKSWNDCLASS style will receive OnLButtonDblClk calls. This is the default for Microsoft Foundation Class windows. Windows calls OnLButtonDblClk when the user presses, releases, and then presses the left mouse button again within the system’s double-click time limit. Double-clicking the 
                                                               ~~~~~~~~~~~~~~~~~~~
    left mouse button actually generates four events: WM_LBUTTONDOWN, WM_LBUTTONUP
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    messages, the WM_LBUTTONDBLCLK call, and another WM_LBUTTONUP message when the
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    button is released.
    ~~~~~~~~~~~~~~~~~~~至于 Earthdog(Earthdog) 的看法,可能是因为他看的太快了,事实上那句话是描述在什么情况下触发双击事件,并没有涉及到包括哪些消息的问题。
      

  13.   

    问题有歧义嘛.
    如果截至到双击事件为止,那么应该是 down,up各一次,下一个消息就是 dblclick了.
    如果把整个双击事件算在内,那应该是 down,up,dlbclick,up了
    如果从物理顺序来讲,当然是down,up,down,up了.我这么想的.