Re: how to differentiate a single click from a double click in CTreeviewCtrl
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Sun, 30 Sep 2007 01:00:51 -0400
Part of the problem of "specifications" is that if a specifcation is written by someone
who is clueless about Windows, GUI interfaces in general, and programming, they will
create specifications that cannot be implemented.
Note that if you use a timer, you have to set it to ~1.25 * the double-click time (which
can vary from user to user even on the same machine!). Obviously, < 1 means you will
react before the double-click, and > 2 means that the timer can fire after a double-click
has fired. 1.5 would be ideal, but that gives you no slack, so 1.25 splits the
difference.
It probably won't be reliable anyway, but it will more or lest work more or less of the
time.
joe
On Sat, 29 Sep 2007 00:16:19 -0400, Joseph M. Newcomer <newcomer@xxxxxxxxxxxx> wrote:
Have you ever heard of the concept called "defective design specification"? Sounds likeJoseph M. Newcomer [MVP]
you have one. What's a PD?
No, if a user single clicks something, the actions expected by a single click are assumed
to take place. This is usually selection. If they then double-click something else, that
means they expect the single click action, selection, and the double-click action takes
place. This is the standard interface, and everyone expects things to work this way.
If you have a way that double-click can abort the graphics stuff, that's what you should
do. For example, single-click starts some graphics computations in a separate thread. If
a double-click occurs on the same object, you can terminate the thread and discard the
data computed. But otherwise, you're asking for a capability that is simply not supported
in Windows.
joe
On Fri, 28 Sep 2007 17:38:24 -0700, "JD" <jdt_young@xxxxxxxxx> wrote:
Hi David,Joseph M. Newcomer [MVP]
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
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- how to differentiate a single click from a double click in CTreeviewCtrl
- From: JD
- Re: how to differentiate a single click from a double click in CTreeviewCtrl
- From: David Webber
- Re: how to differentiate a single click from a double click in CTreeviewCtrl
- From: JD
- Re: how to differentiate a single click from a double click in CTreeviewCtrl
- From: Joseph M . Newcomer
- how to differentiate a single click from a double click in CTreeviewCtrl
- Prev by Date: Get free e-books!
- Next by Date: UML class diagram for a typical MDI application
- Previous by thread: Re: how to differentiate a single click from a double click in CTreeviewCtrl
- Next by thread: Re: how to differentiate a single click from a double click in CTreeviewCtrl
- Index(es):