Change Caption


‘get handle top-level window
Private Declare Function FindWindow Lib “user32” alias “FindWindowA” (ByVal lpClassName as String, byVal lpWindowName as string) as long

‘sent message to window
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

‘constanta set text window
Private Const WM_SETTEXT= &HC

Private Sub cmdSet_Click()
Dim lTargetHandle as long
Dim strTarget as string
Dim strNewCaption as string

strTarget=Me.txtWindow.Text

‘find target (window)
lTargetHandle=FindWindow(vbNullString,strTarget)
If lTargetHandle=0 then
msgbox (“Target Not Found”)
Exit Sub
End if

strNewCaption=Me.txtCaption.Text
‘set caption target
SendMessage lTargetHandle, WM_SETTEXT, 0, byVal strNewCaption
End Sub

One response to “Change Caption

  1. Pingback: Trackback

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s