Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
Posted: Oct 8th, 2003 04:03 AM Post subject: Close A Window with the SendMessage API |
|
|
| Code: | Option Explicit
'Strings
Dim WindowTitle As String
Dim WindowHwnd As Long
'Declares
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, lParam As Any) As Long
'Constants
Private Const WM_CLOSE = &H10
Private Sub Form_Load()
WindowTitle = InputBox("What is the name of the window?", "Window Name Needed")
WindowHwnd = FindWindow(vbNullString, WindowTitle)
Debug.Print WindowHwnd
SendMessage WindowHwnd, WM_CLOSE, -1, 0
End Sub |
|
|