views:

190

answers:

4

Hi all!

I'm working on an windows application that requires separate events for the push and release of a button. While the button is pushed I have to rotate an opengl scene that is on a child window.

I'd like to do that way in order so user doesn't have to make multiple button clicks each time he wants to rotate the scene.

I've seen that WM_COMMAND is not sent until the user releases the mouse button...

Thanks!

+1  A: 

If you're using the Windows API, you should be able to use DefWndProc track WM_LBUTTONDOWN and WM_LBUTTONUP yourself, using the button's HWND.

Reed Copsey
Thanks, your comment also leaded me to the right solution ;)
A: 

I am no expert in this but I think you have to look at mouse button up\down events( WM_LBUTTONDOWN, WM_RBUTTONDOWN) Also you may want to track mouse move events so that a mouse down on the button mouse leaves the button acts as a release. I believe there are mouse leave\enter events that would be useful.

stonemetal
+1  A: 

You should also look into the Win32 API documentation on windows subclassing. Also you can google "windows subclassing" and you should be able to find a lot of examples.

Anthony Johnson
Great! Using window subclassing and tracking WM_LBUTTONDOWN and and WM_LBUTTONUP myself works fine ;)Thanks!
A: 

Windows UI is designed so buttons are clicked on the mouse up message. This allows the user to change his mind (i.e move to the correct location and release the button).

This means that you will get both WM_LBUTTONDOWN and WM_LBUTTONUP before you get the WM_COMMAND and BN_CLICKED.

To perform an action on when the user clicks a button you need to process the WM_LBUTTONDOWN message manually.

Peter Olsson