Button message - half clicked?
-
Hi, is there a message when a button is clicked "half"? I mean when you click a button, but release mouse button while not being over the button. As a result the button has the focus, but of course a ON_BN_CLICKED is not send. Can I handle this case? I want to give the focus back to the previous control. Do I need to catch mouse messages or is there a button message I can handle? Thx, Moak
-
Hi, is there a message when a button is clicked "half"? I mean when you click a button, but release mouse button while not being over the button. As a result the button has the focus, but of course a ON_BN_CLICKED is not send. Can I handle this case? I want to give the focus back to the previous control. Do I need to catch mouse messages or is there a button message I can handle? Thx, Moak
-
I have used the WM_LBUTTONDOWN in this case and then compared the mouse position with the button's rectangle (easily obtained from CButtonCtrl) to see if the user clicked in the button you want. There may be an easier way, but that's one method. JennyP
or as alternatives... if I don't get a message from the button: 2) How about handling
WM_LBUTTONUP
once and check GetFocus(). Code must be added to PreTranslateMessage() handler of dialog/view. 3) Send a notify from the button to the parent, if button is released but not full clicked. Requires a class derived from CButton, also dialog/view has to handleWM_NOTIFY
. 4) Creating a button that can NOT gain focus... like a toolbar button. I think this approach sounds best (and reuseable), anyone with some comments?