hirf-spam-me-here
Sun Dec 14 17:45:11 CST 2003
* "joe" <anonymous@discussions.microsoft.com> scripsit:
> Is there a way to push a button programatically (and for
> that matter to emulate any other key/mouse event).
> For example when a button is pressed by a mouse/key it
> caves in and events get fired.
> How do I cause this to happen programatically?
> Something like:
>
> MyButton.ClickIt()-and the button caves in
\\\
Private Declare Auto Function SendMessage Lib "user32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32 _
) As Int32
Private Const BM_SETSTATE As Int32 = &HF3
Private Const BM_GETSTATE As Int32 = &HF2
Private m_blnDown As Boolean
.
.
.
Private Sub Timer1_Tick( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs _
) Handles Timer1.Tick
If m_blnDown Then
SendMessage(Me.Button1.Handle, BM_SETSTATE, 0, 0)
Else
SendMessage(Me.Button1.Handle, BM_SETSTATE, 1, 0)
End If
m_blnDown = Not m_blnDown
End Sub
///
--
Herfried K. Wagner [MVP]
<
http://www.mvps.org/dotnet>