capturing the mouse and WM_COMMAND
I have a pushbutton in a window. When the user presses the left mouse button over the pushbutton, the mouse gets captured by the pushbutton. Once he releases the button, the capture is released. I need this to be able to detect dragging.
The problem is that the pushbutton doesn''t generate any WM_COMMAND messages when the mouse is captured. Does anyone know a way around this? Thanks.
I suppose a good question is "what are you trying to do that for?"
I can think of a few scenarios when you might want something looking like that, but in all of them it tends to be better to do something a tad more custom than trying to force a button to behave.
I suppose you can always process the WM_LBUTTONDOWN and see if you''re over the pushbutton area, then call the button''s usual message handler.
-fel
I can think of a few scenarios when you might want something looking like that, but in all of them it tends to be better to do something a tad more custom than trying to force a button to behave.
I suppose you can always process the WM_LBUTTONDOWN and see if you''re over the pushbutton area, then call the button''s usual message handler.
-fel
I''m trying to make a AWT-like set of classes to make GUIs with. I don''t really like any of the toolkits I''ve seen, and I really like the AWT way of doing things. I thought it would be a good (and hopefully useful) exercise. AWT allows all its components to listen to MouseMotion (moving and dragging). To detect dragging correctly I need to capture the mouse every time the left mouse button is pressed. (There probably are other methods that involve more state-information, but it would be nice to use just the windows messages and functions).
Does anyone know why it''s impossible for the button to detect the click if the mouse is captured?
Does anyone know why it''s impossible for the button to detect the click if the mouse is captured?
Why do you feel you need to do a mouse capture, first off?
Generally mouse captures are used to handle the possibility of moving your cursor entirely outside of the window you''re dealing with.
Unless you''re using "mouse capture" as a term for something other than an actual mouse capture?
-fel
Generally mouse captures are used to handle the possibility of moving your cursor entirely outside of the window you''re dealing with.
Unless you''re using "mouse capture" as a term for something other than an actual mouse capture?
-fel
No, I mean the same thing you do: using SetCapture(componentHWND) so the mouse can be dragged outside of the control. I want to use this because I want my events to be as close as possible to the java-events. And mousedragging in java lasts as long as the left mousebutton is pressed (even if the mouse is moved outside of the control).
Have you considered not capturing until after the button''s event fires? Caputuring on WM_LBUTTONDOWN is generally a bad idea, because it entirely lacks context. That''s why you''re having trouble capturing the click... a CButton is technically a CWnd, and does a good deal of processing internal to its own window scope... if the mouse is captured the messages are forced to the capture context, so the CButton''s CWnd underbelly isn''t going to be getting it to process (which is technically the point of mouse capture, though more to prevent desktop and third party windows from processing mouse events if you want a specific window to be in control regardless).
-fel
-fel
quote:Original post by felisandria
if the mouse is captured the messages are forced to the capture context
And why would that be a problem? That''s exactly what I want: every mouse-related message should be sent to the button (even if it actually occured on the parent window, or somewhere else)...
Or am I missing something here?
I Think you are talking about mfc, right? I''m not using mfc at all. Only the pure win32 api. So all I have for this button is it''s window handle.
That''s why I put the "or" in there. The point of the question is whether or not you''re using the proper window context for the button, rather than whatever construct it''s stuck on.
-fel
-fel
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement