Option Explicit
'
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
'
Private Const WM_CLOSE As Long = &H10
Private Const HTCAPTION As Long = 2&
'
Private Const MON_TITRE As String = "Sans titre - Bloc-notes"
'
'
Private Sub Command1_Click()
Dim lHwnd As Long
lHwnd = FindWindow(vbNullString, MON_TITRE)
If lHwnd = 0 Then
MsgBox "Titre non-trouvé!!!"
Else
Call SendMessage(lHwnd, WM_CLOSE, HTCAPTION, ByVal 0&)
End If
End Sub