|
Изменение заголовка любого окна |
|
|
Добавьте на форму 2 TextBox и 1 CommandButton.
Напишите внутри TextBox1 наименование окна, которое
вы хотите изменить. Напишите внутри TextBox2 новый
заголовок окна. 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_SETTEXT = &HC
Private Sub Command1_Click()
Dim target_hwnd As Long
Dim target_name As String
Dim new_caption As String
target_name = Text1.Text
target_hwnd = FindWindow(vbNullString, target_name)
If target_hwnd = 0 Then
MsgBox "Cannot find target"
Exit Sub
End If
new_caption = Text2.Text
SendMessage target_hwnd, WM_SETTEXT, 0, ByVal new_caption
End Sub
Private Sub Form_Load()
Text1.Text = "Работа с текстом"
Text2.Text = "New Caption"
End Sub
|
|
|
|
|
|
|