Website Design United States, Website Design California, Website Designing United States, Website Designing California

Change the caption of a window - Visual Basic 6

This will change the caption of any window, provided you have the window handle.
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_SETTEXT = &HC

Private Sub ChangeCaption(ByVal sTarget_Name As String, ByVal sNewCaption As String)
'What: Changes the caption of any given window
'Who: Eric D. Burdo
'When: 8/30/1999 9:40
Dim lTarget_hWnd As Long

'Find the target.
lTarget_hWnd = FindWindow(vbNullString, sTarget_Name) 'Try to find the window
If lTarget_hWnd = 0 Then 'If the window does not exist, then either it is not running, or the user
MsgBox "Cannot find target" 'Window doesn't exist. Let the user know
Exit Sub '>>>>>>>>>>>> 'leave now
End If
SendMessage lTarget_hWnd, WM_SETTEXT, 0, ByVal sNewCaption 'Change the caption using the SendMessage API
End Sub


WEB DESIGN INDIA
42 B Malviya Nagar , New Delhi-110017

Skype: manmeetsi
Email: support.webdesignindia@gmail.com
Tel: 91-011-40502005, 9810067295

 















 


© 2008-2009 dotnet4all.com