capturing the mouse and WM_COMMAND

Started by
16 comments, last by Koen 21 years, 2 months ago
I only use the handle. Whenever I receive WM_LBUTTONDOWN, I do SetCapture(hWnd) and if I receive WM_LBUTTONUP, I do ReleaseCapture().
Advertisement
you''ll need to create a subclass of the BUTTON WndClass in order to install a custom message handler to get at the events. How to do that is explained in the MSDN manual under Subclassing a Window.
I know, I allready did. see http://www.gamedev.net/community/forums/topic.asp?topic_id=135511
Here is a window-procedure that shows the problem:
LRESULT CALLBACK WndProc( HWND handle, UINT messg,WPARAM wParam, LPARAM lParam ){	if(handle==hWnd2)	{ //hWnd2 is the handle for the button		if(messg==WM_LBUTTONDOWN)	{			SetCapture(hWnd2);		}		if(messg==WM_LBUTTONUP)	{			ReleaseCapture();		}		return CallWindowProc(old,hWnd2,messg,wParam,lParam); //old is the button-wndproc	}		switch(messg)	{		case WM_DESTROY:		PostQuitMessage( 0 );		break;		case WM_COMMAND:		SetWindowText(hWnd,"OK"); //hWnd is the handle for the parent window, but this line never gets executed		break;			default:		return( DefWindowProc( handle, messg, wParam, lParam ) );	}	return( 0L );}  


[edited by - Koen on January 28, 2003 7:07:18 PM]
Okay, and where are you posting the button notification that it''s been clicked to your main window? You''re either going to have to explicitly post it yourself, or call the control''s click handler, since you''ve overridden the WM_LBUTTONDOWN processing.

-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
After processing WM_LBUTTONDOWN, CallWindowProc(.....) is executed. If the SetCapture(..) and ReleaseCapture() are commented out, everything works fine. So that can''t be the problem.
Post it anyway and see if it works. *shrug*

Messing with mouse capture can seriously screw things up.
The reason why that happens is tucked deeply away inside the .dll''s for visual studio.

-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
quote:Original post by felisandria
Post it anyway and see if it works. *shrug*

I guess that will be the only option.
Still think they should''ve put something in their docs, though. I hate uncertainty ;-)

This topic is closed to new replies.

Advertisement