Re: double click in CBitmapButton problem.

"domehead100" <[email protected]>
Newsgroups gmane.comp.windows.wtl
Message-ID <[email protected]>
--- In [email protected], "timza1221" <timza1221@...> wrote:
>
> --- In [email protected], "domehead100" <domehead100@> wrote:
> >
> > --- In [email protected], "timza1221" <timza1221@> wrote:
> > >
> > > I have a class CCFButton : public CBitmapButtonImpl<CCFButton>
> > > and have taken over some left button states to perform my own states, but have No Double Click handlers.
> > > Works great except, if you double-click on it, it takes over all focus over full client area of application, and won't give it up, until you right-click and escape the context menu.
> > > Does this problem sound familiar to anybody? should I post any code?
> > > Thanks
> > > Todd.
> > >
> > 
> > What if you add a double-click message map entry and direct it to the same handler you already use for the single click?
> > 
> > Are you currently handling the BN_CLICKED or WM_LBUTTONDOWN?
> > 
> > Is the parent reflecting the messages back to the button?
> > 
> > ~Mike
> >
> HI,
> 
> I had No handler for either, just MSG_WM_LBUTTONDOWN, MSG_WM_LBUTTONUP.  To fix the problem I added MSG_WM_LBUTTONDBLCLK and  called SetMsgHandled(TRUE) in the handler.
> 
> This is a hack, though, for a problem that was mysterious.
> 
> A user could double-click and then lose all control of the application, without any real clue of what happened, until you noticed that you double-clicked on an image button by accident.
> Todd.
> 
> Why do you ask about the parent reflection?  thanks again!
>

I think the problem is that you really should not be handling WM_LBUTTONDOWN/UP but instead BN_CLICKED/BN_DOUBLECLICKED.  The reason is that the BN_ messages are synthesized by the window procedure, typically on mouse up.  For example, try doing mouse-down on any button but moving the mouse off the button before mouse up:  no click.  

The reason these need to be synthesized is because Windows waits to see if there is a second click within the configurable double-click time period before deciding that a click or a double-click has occurred.

By handling the specific mouse down/up messages, you are interferring with the standard Windows behavior, worse if you are handling mouse down, and even worse if you are eating the messages and not passing them on to the default window procedure.  It is getting confused and does not know the state of the mouse.

My question about reflection had to do with whether you were handling the messages in the dialog (parent) or the button itself.  If the window procedure in the dialog is getting confused, that could explain the strange behavior you noted.

~Mike



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/wtl/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/wtl/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.