IS THERE ANY WAY TO CHANGE THE NAME IN THE TITLE BAR OF A PROGRAM ALREADY RUNNING?
Printable View
IS THERE ANY WAY TO CHANGE THE NAME IN THE TITLE BAR OF A PROGRAM ALREADY RUNNING?
Sure. MyForm.Caption = "New Title"
------------------
Marty
Hey thanks serge but one problem I am not good at programming so I put in your code and then I read that you said I had to use the window handle. What is the window handle? and also how could you use the FindWindowEx? I don't know how to do api so well. Thanks
Can you tell me exactly what program you're trying to change the caption for? I'll try to get it working for you.
Regards,
------------------
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819
You have to know the ClassName of the application you want to change the title of.
To find out, you can use a utility called Spy++.
You can use either FindWindow or FindWindowEx to get the hWnd, then use SetWindowText (or basically the same: SendMessage with WM_SETTEXT) to replace the title.
Example:
------------------Code:Option Explicit
Private Declare Function FindWindow Lib "User32.DLL" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowText Lib "User32.DLL" Alias "SetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String) As Long
' The ClassName of the Notepad which comes with Windows is "Notepad".
Private Const NotepadClassName = "Notepad"
' Other ClassNames you can use:
Private Const CalculatorClassName = "SciCalc"
Private Const VBClassName = "wndclass_desked_gsk"
Private Const DosWindowClassName = "tty"
Private Const FreeCellClassName = "FreeWClass"
Private Const MineSweeperClassName = "Minesweeper"
Private Const SolitaireClassName = "Solitaire"
Private Sub Command1_Click()
Dim hWindow As Long
' First, find the hWnd:
hWindow = FindWindow(NotepadClassName, vbNullString)
' Then, change the title:
Call SetWindowText(hWindow, "Visual Basic on a REALLY bad day!")
End Sub
Yonatan
Teenage Programmer
E-Mail: [email protected]
ICQ: 19552879
AIM: RYoni69
[Don't notice what it says down there... Nobody ever edited this message!]
[This message has been edited by Yonatan (edited 12-10-1999).]
If you want to change the program other then yours then you can use SetWindowText API. First you would have to know the window handle (hWnd) of the window you want to change the caption for.
Where WindowHwnd is the window handle of the program you want to change the captioh for. If you need to find the window first, then you can use FindWindowEx API to get the hWnd.Code:Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Sub Command1_Click()
SetWindowText WindowHwnd, "New Caption"
End Sub
------------------
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819
Well I saw a program out there that it changed the name of every program running at that apparent time. So for intance if I had lets say Aol running and then freecell then a folder called "Windows" It would change them all to "haha i changed your title bar name". I can't find where I found this it was a long time ago. Well Thanks for all your help. If you could get this going for me I would be truely grateful.
Does anybody know? Please Help!!!
Public Const HWND_BROADCAST = &HFFFF&
use that hWnd
------------------
Tom Young, 14 Year Old
[email protected]
ICQ: 15743470 Add Me ICQ Me
AIM: TomY10
PERL, JavaScript and VB Programmer
For AOL it is very easy to do what you want (for FreeCell I'm not sure, don't have it installed, therefore I can't find out the ClassName for it)
Following the same steps, you can easily change caption for any program running.Code:Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Sub Command1_Click()
Dim lAOL As Long
lAOL = FindWindowEx(0, 0, "AOL Frame25", vbNullString)
If lAOL Then
Call SetWindowText(lAOL, "Ha ha ha, I've changed the capton")
End If
End Sub
------------------
Serge
Senior Programmer Analyst
[email protected]
[email protected]
ICQ#: 51055819