The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ofg on December 25, 2004, 08:01:18 PM

Title: Double Action Button
Post by: ofg on December 25, 2004, 08:01:18 PM
 hi,
     I have a Button Control as a Child Window.
     The system performs no action on my application when LB is pressed
     but after it is released.
     I want to carry out another action when LB is pressed too.
     Is there anything I can do ?

     thanks.
Title: Re: Double Action Button
Post by: pbrennick on December 25, 2004, 08:33:58 PM
ofg,

QuoteThe BN_PUSHED notification message is sent when the push state of a button is set to pushed. The parent window of the button receives this notification message through the WM_COMMAND message.

I found that in the win32.hlp file, there is a lot of other stuff in Button Messages, such as:

QuoteFollowing are the messages used with buttons.

BM_CLICK
BM_GETCHECK
BM_GETIMAGE
BM_GETSTATE
BM_SETCHECK
BM_SETIMAGE
BM_SETSTATE
BM_SETSTYLE
BN_CLICKEDBN_DBLCLK
BN_DISABLE
BN_DOUBLECLICKED
BN_HILITE
BN_KILLFOCUS
BN_PAINT
BN_PUSHED
BN_SETFOCUS
BN_UNHILITE
BN_UNPUSHED
WM_CTLCOLORBTN

Paul

Title: Re: Double Action Button
Post by: donkey on December 25, 2004, 08:34:20 PM
You can subclass the button and process the WM_LBUTTONDOWN message. It will be sent when the button is pressed down, a WM_LBUTTONUP message is sent when the button is released. It should be noted that this behaviour is by design, it allows the user to move the cursor off the button and release the left button cancelling the button press. To subclass the button do as follows...

invoke SetWindowLong,[hButton],GWL_WNDPROC,offset ButtonSubProc
mov [pButtonProc],eax

ButtonSubProc FRAME hWin,uMsg,wParam, lParam

cmp uMsg, WM_LBUTTONDOWN
jne >.DEFPROC
; do your thing here

.DEFPROC
invoke CallWindowProc,[pButtonProc],[hWin],[uMsg],[wParam],[lParam]
ret
ENDF
Title: Re: Double Action Button
Post by: Manos on December 25, 2004, 08:40:16 PM
Also you can handle the BN_SETFOCUS and after send to Button the message:WM_KILLFOCUS

Manos.