hello, this Is pete, I've written some code, found out it didn't work, stripped it down to just the problem, and no matter what I do I can't seem to fix it.
I'm trying to get the window handle of "test - notepad" I'm using Api Spy to see what handle I'm SUPPOSE to get, but the handle I'm getting, is no where close to correct, plus it changes wildly each time I check again, I'm kinda suspecting it's win 8's doing since I've never had this issue before with win 7 & xp.. though it's been a long time since I last programmed in vb, so I could be doing something wrong too. this is the code I'm using:
<code>
Public Class Form1
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Public Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Public Const WM_SETTEXT = &HC
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim notepad As Long, editx As Long
notepad = FindWindow(Nothing, "test - Notepad")
TextBox1.Text = notepad
End Sub
End Class
</code>
I'm trying to get the window handle of "test - notepad" I'm using Api Spy to see what handle I'm SUPPOSE to get, but the handle I'm getting, is no where close to correct, plus it changes wildly each time I check again, I'm kinda suspecting it's win 8's doing since I've never had this issue before with win 7 & xp.. though it's been a long time since I last programmed in vb, so I could be doing something wrong too. this is the code I'm using:
<code>
Public Class Form1
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Public Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Public Const WM_SETTEXT = &HC
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim notepad As Long, editx As Long
notepad = FindWindow(Nothing, "test - Notepad")
TextBox1.Text = notepad
End Sub
End Class
</code>