Push the Button!!

My finger is on the button....

(As this tip uses the Win32 API function Sendmessage, it can be used in other languages as well)
You can press a button by clicking with the mouse or defining a shortkey and press the right keyboard button(s). But now you want to press a button programmaticly.
Here is how i do it:

     SendMessage( oButton:Handle(), BM_SETSTATE, 1, 0 )

This will set the button in the pressed state untill it gets released.
Releasing the button goes like this

      SendMessage( oButton:Handle(), BM_SETSTATE, 0, 0 )

If you want to show both, you need to put the app to sleep for a little while

       SendMessage(  oButton:handle(),BM_SETSTATE, 1, 0)
     ApplicationExec( execWhileEvent)
     Sleep(100)
     SendMessage(  oButton:Handle(),BM_SETSTATE, 0, 0
)

OK, this works now. But By doing this, the Buttondown event is not fired.
This can be achieved by sending BM_CLICK

     SendMessage( oButton:Handle(),BM_CLICK , 0, 0 )

Happy VO-ing,

Erik Visser

Geef feedback:

CAPTCHA image
Vul de bovenstaande code hieronder in
Verzend Commentaar