Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleSet another application's caption
DescriptionThis example shows how to set another application's caption in Visual Basic 6.
Keywordscaption, title, SendMessage, application title
CategoriesWindows, Software Engineering, API
 
The program uses FindWindow to get the target's window handle. Then it uses SendMessage with the WM_SETTEXT message to set the caption.
 
Private Sub Command1_Click()
Dim target_hwnd As Long
Dim target_name As String
Dim new_caption As String

    ' Find the target.
    target_name = txtCaption.Text
    target_hwnd = FindWindow(vbNullString, target_name)
    If target_hwnd = 0 Then
        MsgBox "Cannot find target"
        Exit Sub
    End If

    new_caption = txtNewCaption.Text
    SendMessage target_hwnd, WM_SETTEXT, 0, _
        ByVal new_caption
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated