So i'm trying to set focus on a specific part of a window. After i did a little search, i found the following code..
When i run it, it detect the window i am looking for, but i get this Exception whenever it reaches this line
and this is the exception
A call to PInvoke function 'flooder!flooder.Form1::ShowWindow' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
Can anyone please check the code? and is there any other way to set a focus on a specific part of a window?
thanks!!
Code:
Private Declare Function FindWindow _
Lib "user32" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow _
Lib "user32" _
(ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Private Const SW_SHOWNORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3
Private Sub Command1_Click()
Dim lHwnd As Long
lHwnd = FindWindow("RichEdit20W", vbNullString)
If lHwnd <> 0 Then
MsgBox "Chat is open!", vbInformation, "Notepad"
ShowWindow lHwnd, SW_SHOWNORMAL
Else
MsgBox "Notepad isn't open!", vbInformation, "Window not found."
End If
End Sub
When i run it, it detect the window i am looking for, but i get this Exception whenever it reaches this line
Code:
lHwnd = FindWindow("RichEdit20W", vbNullString)
and this is the exception
A call to PInvoke function 'flooder!flooder.Form1::ShowWindow' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
Can anyone please check the code? and is there any other way to set a focus on a specific part of a window?
thanks!!