OnLButtonDown cannot catch mouse click on CButton
-
Hi, I use OnLButtonDown and OnLButtonUp because I want to control the left mouse button press and release over more than one button at the same time. However, if I click on the empty area of the dialog I get these functions called, while I cannot get them called when I click on the buttons themselves. :doh: There is no OnBnClickedButton..() function called. Do I have to change the properties of the buttons? Thanks in advance
-
Hi, I use OnLButtonDown and OnLButtonUp because I want to control the left mouse button press and release over more than one button at the same time. However, if I click on the empty area of the dialog I get these functions called, while I cannot get them called when I click on the buttons themselves. :doh: There is no OnBnClickedButton..() function called. Do I have to change the properties of the buttons? Thanks in advance
The standard Windows button issues the
BN_CLICKED
notification (which you handle via anOnBnClicked...
function) when the button is released, not when it is pressed. If you want to perform an action when the button is pressed, you will need to create your own button class and handle theWM_LBUTTONDOWN
message.
Software Zen:
delete this;
-
Hi, I use OnLButtonDown and OnLButtonUp because I want to control the left mouse button press and release over more than one button at the same time. However, if I click on the empty area of the dialog I get these functions called, while I cannot get them called when I click on the buttons themselves. :doh: There is no OnBnClickedButton..() function called. Do I have to change the properties of the buttons? Thanks in advance
The mouse message is going to the window that the cursor is over, since that's the window being acted on. So when you click the button, the button gets the message, not the button's parent. You'll need to subclass the button and handle
WM_LBUTTONDOWN
in your subclass. --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ There is a saying in statistics that a million monkeys pounding on typewriters would eventually create a work of Shakespeare. Thanks to the Internet, we now know that this is not true.