Henry
Henry

Reputation:

Push / release button click

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!

Upvotes: 0

Views: 1518

Answers (4)

Peter Olsson
Peter Olsson

Reputation: 1322

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.

Upvotes: 0

stonemetal
stonemetal

Reputation: 6208

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.

Upvotes: 0

Anthony Johnson
Anthony Johnson

Reputation: 646

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.

Upvotes: 1

Reed Copsey
Reed Copsey

Reputation: 564413

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.

Upvotes: 1

Related Questions