Re: how to differentiate a single click from a double click in CTreeviewCtrl



Hi David,

I have no other choice because the request is from a spec defined by my PD
colleague. On a single click, an item is selected and I need to do a lot
of graphic stuffs that consuming lots of computer power. The PD allow users
to double click another item which may not be the one user just select.
Because of performance, I don't want to perform the graphic stuffs twice if
user double clicks an item.

I agree with you. The timer you just mentioned scared me. I don't want to
complicate the code to jeopardize maintainability. Does everyone follow
Windows' standard in this regard? I am quite surprised. Even developers
follow this standard, user may not follow it. It's quite common that a
normal user select one thing and then change his/her mind by double clicking
another item. We developers must take care of this possibility.

Any further help is much appreciated.

JD


"David Webber" <dave@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:uxU6JTiAIHA.5312@xxxxxxxxxxxxxxxxxxxxxxx

"JD" <jdt_young@xxxxxxxxx> wrote in message
news:%23ItBLxhAIHA.536@xxxxxxxxxxxxxxxxxxxxxxx

In CTreeviewCtrl, I want to catch both the double click and the single
click events, but also need to differentiate them. For the double click
event, a handle is written against WM_LBUTTONDBLCLK. But against what
message should I write for single click event? I tried WM_LBUTTONDOWN.
But WM_LBUTTONDOWN will be fired too if I double click an item.
Basically, I want to differentiate single and double click events. Is
there a way? Thanks for any help.

The standard model in Windows is that a single click selects something,
and that a double click does something to the selected item.

Thus the response to a double click can rely on the fact that the
appropriate item has been selected by a single click.

If you want to do something with a single click which is not compatible
with it being the first half of a double click, then you will probably
confuse the users of your program, and I'd urge you to think of another
way (eg with the right mouse button or the keyboard).

If you really really want to do it, you could probably do something like
setting timer and responding to the single click when the timer expires
only if no double click has been received by then - but it is ugly.

Dave
--
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm



.