Conflict between VC Mouse clicking and double-clicking

Source: Internet
Author: User

Analyze the process first:

 

Click:

Down> up

 

Double-click:

Down> up> Down> up

 

Therefore, during the process of clicking and double-clicking, there must be conflicts due to the key delay. In addition, the clicking and double-clicking functions of VC dialog/view are as follows:

 

 On_wm_lbuttondblclk ()
On_wm_lbuttondown ()

 

By default, they do not handle this latency, so they can only be compiled by themselvesCodeAfter finding the relevant information, sort out the Code as follows:

Void cmouseclickdlg: onlbuttondblclk (uint nflags, cpoint point) <br/>{< br/> // todo: add your message handler code here and/or call default <br/> afxmessagebox ("double click this time! "); // Single click <br/> cdialog: onlbuttondblclk (nflags, point); <br/>}</P> <p> void cmouseclickdlg :: onlbuttondown (uint nflags, cpoint point) <br/>{< br/> // todo: add your message handler code here and/or call default <br/> msgmsg; <br/> dworddwold = gettickcount (); <br/> dworddwnew = 0; </P> <p> while (1) <br/>{< br/> // intercept mouse messages <br/> If (: peekmessage (& MSG, null, 0, 0, pm_remove )) <br/>{< br/>: transl Atemessage (& MSG); <br/>: dispatchmessage (& MSG); <br/> If (MSG. message = wm_lbuttondblclk) <br/> return; <br/>}< br/> dwnew = gettickcount (); </P> <p> // obtain the double-click interval of the system. Of course, you can set the interval .. <br/> If (dwnew-dwold> getdoubleclicktime () <br/> break; <br/>}< br/> afxmessagebox ("Click here! "); <Br/> cdialog: onlbuttondown (nflags, point); <br/>}< br/>

Of course, you can also use setdoubleclicktime to adjust the mouse double-click latency (this option is available in the control panel ).

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.