Results 1 to 10 of 10

Thread: TITLE BAR

  1. #1

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408

    Post

    IS THERE ANY WAY TO CHANGE THE NAME IN THE TITLE BAR OF A PROGRAM ALREADY RUNNING?

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Sure. MyForm.Caption = "New Title"

    ------------------
    Marty

  3. #3

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408

    Post

    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

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    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


  5. #5
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Post

    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).]

  6. #6
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    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.

    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
    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
    [email protected]
    [email protected]
    ICQ#: 51055819


  7. #7

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408

    Post

    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.

  8. #8

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408

    Post

    Does anybody know? Please Help!!!

  9. #9
    Hyperactive Member
    Join Date
    Jul 1999
    Location
    NY, USA
    Posts
    270

    Post

    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

  10. #10
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    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)

    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
    Following the same steps, you can easily change caption for any program running.

    ------------------

    Serge

    Senior Programmer Analyst
    [email protected]
    [email protected]
    ICQ#: 51055819

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width