Click to See Complete Forum and Search --> : TITLE BAR
PITBULLCJR
Dec 9th, 1999, 10:16 PM
IS THERE ANY WAY TO CHANGE THE NAME IN THE TITLE BAR OF A PROGRAM ALREADY RUNNING?
MartinLiss
Dec 9th, 1999, 10:22 PM
Sure. MyForm.Caption = "New Title"
------------------
Marty
PITBULLCJR
Dec 10th, 1999, 01:07 AM
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
Serge
Dec 10th, 1999, 01:34 AM
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
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)
Yonatan
Dec 10th, 1999, 06:25 AM
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:
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: RZvika@netvision.net.il
ICQ: 19552879 (http://www.icq.com/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).]
Serge
Dec 10th, 1999, 11:55 AM
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.
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
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.
------------------
Serge
Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)
PITBULLCJR
Dec 11th, 1999, 02:07 AM
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.
PITBULLCJR
Dec 12th, 1999, 12:33 AM
Does anybody know? Please Help!!!
Compwiz
Feb 21st, 2000, 03:41 AM
Public Const HWND_BROADCAST = &HFFFF&
use that hWnd
------------------
Tom Young, 14 Year Old
tyoung@stny.rr.com
ICQ: 15743470 (http://wwp.icq.com/15743470) Add Me (http://wwp.icq.com/scripts/search.dll?to=15743470) ICQ Me (http://wwp.icq.com/scripts/contact.dll?msgto=15743470)
AIM: TomY10 (http://www.aol.com/aim/aim30.html)
PERL, JavaScript and VB Programmer
Serge
Feb 21st, 2000, 04:03 AM
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)
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
Following the same steps, you can easily change caption for any program running.
------------------
Serge
Senior Programmer Analyst
sdymkov@microage.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.