I'm sending a message to notepad. I want to be able to understand the FindWindow function so I'm asking for the integer that it is returning to the variable hwnd to be displayed in notepad. It is doing this and is printing the value à. When I look at the value that I think it should be returing through a program called Winspector it isn't matching. Does anyone have any suggestions.
Public Class Form1
Private Declare Ansi Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Public Const WM_CHAR = &H102
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' assuming you have notepad open.
Dim hwnd As Integer = FindWindow(vbNullString, "Untitled - NotePad")
Dim x As Integer = FindWindowEx(hwnd, 0, "Edit", vbNullString)
' send some keys
SendMessage(x, WM_CHAR, hwnd, 0)