"Lars Netzel" <ui****@adf.se> schrieb:
Thank you.. then.. how come this does not work? my FSM window have a
button with the caption "Button1"
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Public Declare Function FindWindowEx Lib "user32" (ByVal hWnd1 As Long,
ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
[...]
It finds the window fine.. but not the button... is the declaration okay?
Use these declarations and the code below (untested):
\\\
Private Declare Auto Function FindWindow Lib "user32.dll" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String _
) As IntPtr
Private Declare Auto Function FindWindowEx Lib "user32.dll" ( _
ByVal hwndParent As IntPtr, _
ByVal hwndChildAfter As IntPtr, _
ByVal lpszClass As String, _
ByVal lpszWindow As String _
) As IntPtr
..
..
..
Dim hWnd As IntPtr = FindWindow(vbNullString, "FSM")
If hWnd.Equals(IntPtr.Zero) Then
Return
End If
Dim hWndButton As IntPtr = _
FindWindowEx(hWnd, IntPtr.Zero, "BUTTON", "Button 1")
If hWndButton.Equals(IntPtr.Zero) Then
Return
End If
....
///
Note that "BUTTON" must be replaced by the Win32 window class name of the
control. This is typically "BUTTON" for C-based applications, but the class
name can differ for applications written in Classic Visual Basic and .NET.
You can use the Spy++ utility which comes with VS.NET to grab the control's
class name. The last parameter of 'FindWindowEx' expects the button's
caption. Make sure you don't forget the leading "&" character if the
caption contains an accelerator key.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>