Sending Windows Messages
I am playing around trying to send messages to windows (specifically close messages and specific messages to dialog boxes).
I am using visual studio 2003, and am using the windows API to try to send the messages.
What I have found is that FlashWindow and CloseWindow work, MoveWindow kind of works (it does respond, but does some weird things), but SendMessage and DestroyWindow do nothing.
Following is the code I have been tinkering with, does anyone have any advice (eg. are there any .NET framework classes which can help me here):
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function FlashWindow Lib "user32" (ByVal hwnd As Long, ByVal bInvert As Long) As Long
Public Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function CloseWindow Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Int16, ByVal y As Int16, ByVal width As Int16, ByVal height As Int16, ByVal repaint As Boolean) As Boolean
Const WM_CLOSE = &H10
Const WM_SHOWWINDOW = &H18
Dim winHwnd As Long
Dim RetVal As Long
winHwnd = FindWindow(Nothing, "Calculator")
FlashWindow(winHwnd, 1)
If winHwnd <> 0 Then
'MoveWindow(winHwnd, 50, 50, 100, 100, True)
SendMessage(winHwnd, WM_SHOWWINDOW, 0&, 0&![]()
DestroyWindow(winHwnd)
Else
MsgBox("The Calculator is not open.")
End If

