WM_LBUTTONDOWN wanted
-
Hi everyone, I have a problem concerning the WM_LBUTTONDOWN message. I'm subclassing a list view control using MFC to implement owner-draw abilities, and I'm using ON_WM_LBUTTONDOWN() in the message map. BUT: When releasing the left button on the list view control nothing happens, the message handler only gets called when double-clicking the left mouse button...? Any suggestions? Alex Don't try it, just do it! ;-)
-
Hi everyone, I have a problem concerning the WM_LBUTTONDOWN message. I'm subclassing a list view control using MFC to implement owner-draw abilities, and I'm using ON_WM_LBUTTONDOWN() in the message map. BUT: When releasing the left button on the list view control nothing happens, the message handler only gets called when double-clicking the left mouse button...? Any suggestions? Alex Don't try it, just do it! ;-)
Maybe the WM_LBUTTONDOWD got reflected to the parent of the control?
-
Hi everyone, I have a problem concerning the WM_LBUTTONDOWN message. I'm subclassing a list view control using MFC to implement owner-draw abilities, and I'm using ON_WM_LBUTTONDOWN() in the message map. BUT: When releasing the left button on the list view control nothing happens, the message handler only gets called when double-clicking the left mouse button...? Any suggestions? Alex Don't try it, just do it! ;-)
If you're looking for clicks on the list control, you need to be handling LVN and NM messages such as NM_CLICK
-
Maybe the WM_LBUTTONDOWD got reflected to the parent of the control?
Doesn't reflection work the other way 'round? In other words, by default messages go to the control's owner and then reflection reflects them back to the control so that message handling can be done in derived control classes?
-
Hi everyone, I have a problem concerning the WM_LBUTTONDOWN message. I'm subclassing a list view control using MFC to implement owner-draw abilities, and I'm using ON_WM_LBUTTONDOWN() in the message map. BUT: When releasing the left button on the list view control nothing happens, the message handler only gets called when double-clicking the left mouse button...? Any suggestions? Alex Don't try it, just do it! ;-)
I just tried this - handling the NM_CLICK message - at both the dialog and control level and it works in both cases.
-
Doesn't reflection work the other way 'round? In other words, by default messages go to the control's owner and then reflection reflects them back to the control so that message handling can be done in derived control classes?
Yes, that is the definition of reflection.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
-
Doesn't reflection work the other way 'round? In other words, by default messages go to the control's owner and then reflection reflects them back to the control so that message handling can be done in derived control classes?
Excuse me. Maybe it was HANDLED by the parent, in which case it will not be reflected back to the control. MFC handler processing code will typically stop at the first handler it finds. If you have a stub handler in your parent window you 'forgot' about, you can scratch your head a long time trying to figure out why the 'reflected' message is never received by the control.
-
I just tried this - handling the NM_CLICK message - at both the dialog and control level and it works in both cases.
Yeah, I will check NM_CLICK. I've found out why WM_LBUTTONUP can't be received by MFC... WM_LBUTTONDOWN: Processed in different ways depending on whether a click or drag operation is being initiated. To determine which operation is involved, the list-view control enters a modal message loop until either the button is released or the mouse is moved. (MSDN) The message is only received if I move the mouse before releasing the button. Thanks for all your quick answers, Alex Don't try it, just do it! ;-)
-
Yeah, I will check NM_CLICK. I've found out why WM_LBUTTONUP can't be received by MFC... WM_LBUTTONDOWN: Processed in different ways depending on whether a click or drag operation is being initiated. To determine which operation is involved, the list-view control enters a modal message loop until either the button is released or the mouse is moved. (MSDN) The message is only received if I move the mouse before releasing the button. Thanks for all your quick answers, Alex Don't try it, just do it! ;-)
In that case, you should look into the LVN_BEGINDRAG message, which sounds like what you need.
-
Yeah, I will check NM_CLICK. I've found out why WM_LBUTTONUP can't be received by MFC... WM_LBUTTONDOWN: Processed in different ways depending on whether a click or drag operation is being initiated. To determine which operation is involved, the list-view control enters a modal message loop until either the button is released or the mouse is moved. (MSDN) The message is only received if I move the mouse before releasing the button. Thanks for all your quick answers, Alex Don't try it, just do it! ;-)
By the way, I just looked at some old code of mine and saw that we handled WM_LBUTTONDOWN, WM_MOUSEMOVE, WM_LBUTTONUP and LVN_BEGINDRAG. We handled all these messages to have control over changing the mouse cursor to represent what was being moved or in some cases to display a shape that indicated something that could not be dragged. Handling these messages also enabled us to change the cursor to indicate a valid "drop zone".