Witam, mam problem prawdopodobnie z funkcją SendMessage. Otóż problem polega na tym, że dla 1 buttona działa wszystko poprawnie. Natomiast dla kolejnych już nie.
Declare Auto Function FindWindow Lib "USER32.DLL" (
ByVal lpClassName As String,
ByVal lpWindowName As String) As IntPtr
Declare Auto Function SendMessage Lib "USER32.DLL" (
ByVal hWnd As IntPtr,
ByVal Msg As UInteger,
ByVal wParam As IntPtr,
ByVal lParam As IntPtr) As Integer
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
Private Const BM_CLICK As Integer = &HF5
Declare Auto Function SetForegroundWindow Lib "USER32.DLL" (
ByVal hWnd As IntPtr) As Boolean
Dim hwnd As IntPtr = FindWindow("TKlawisze", vbNullString)
Dim hwndFrame As IntPtr = FindWindowEx(hwnd, Nothing, "Tpanel", Nothing)
Dim hwndDialog As IntPtr = FindWindowEx(hwndFrame, Nothing, "Tpanel", Nothing)
Dim hwndDialog1 As IntPtr = FindWindowEx(hwndFrame, hwndDialog, "Tpanel", Nothing)
Dim hwndDialog2 As IntPtr = FindWindowEx(hwndFrame, hwndDialog1, "TPanel", Nothing)
Dim hWndButton As IntPtr = FindWindowEx(hwndDialog2, Nothing, "TButton", ">>")
SetForegroundWindow(hWndButton)
SendMessage(hWndButton, BM_CLICK, 0, 0)
Powyższy kod działa poprawnie. Jeśli jednak zmienię hWndButton na inny, nie ma "klinięcia" obiektu.
Dim hWndButton As IntPtr = FindWindowEx(hwndDialog2, Nothing, "TPanel", "USTAW BAZĘ")