Results 1 to 5 of 5

Thread: SET WINDOW TITLE TEXT??

  1. #1

    Thread Starter
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527

    Post

    first let's say there is "Microsoft Word - Book Review" open.
    Is there a way to change it to:
    "Microsoft Word - Book Review by da_silvy"

    please help me someone




    ------------------
    david
    Teenage Programmer


  2. #2
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386

    Post

    Sure, find the window using FindWindow (if I'm correct...) then yuo know the hWnd and then you can change the caption.
    Search this msgboard, I believe this question has been asked a 1000 times (I believe Aaron Young has posted a sample changing the caption of Notepad)

  3. #3
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Post

    Here's how to find the window based on it's known window text, and change the text using API functions. FindWindow finds the handle based on the name, and SetWindowText changes the text using that handle:

    Code:
    Option Explicit
    
    '******************
    ' API declarations
    '******************
    Declare Function SetWindowText Lib "user32.dll" Alias "SetWindowTextA" _
        (ByVal hwnd As Long, ByVal lpString As String) As Long
    
    
    Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" _
        (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
    
    
    '***********************************************************************
    ' Search for a window called "Microsoft Word - Book Review" and
    ' change it's title text to "Microsoft Word - Book Review by da_silvy"
    '***********************************************************************
    
    Dim hwnd As Long        ' receives handle to the found window
    Dim retval As Long      ' generic return value
    
    ' Attempt to locate a window called Microsoft Word - Book Review.
    ' Note how the CLng function must be used to force 0 as a Long data type.
    
    hwnd = FindWindow(CLng(0), "Microsoft Word - Book Review")  ' look for the window
    
    If hwnd = 0 Then
        ' could not find the window
        MsgBox """Microsoft Word - Book Review"" is not currently running."
    Else
        ' Change title bar text.
        retval = SetWindowText(Form1.hwnd, "Microsoft Word - Book Review by da_silvy")
    End If
    Hope that helps

    ~seaweed


    [This message has been edited by seaweed (edited 02-15-2000).]

  4. #4
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    I believe you need to add the following to refresh the window.

    Code:
    Declare Function DrawMenuBar Lib "user32" _
    (ByVal hwnd As Long) As Long
    
    DrawMenuBar lhwnd
    Wade

  5. #5
    Addicted Member Cbomb's Avatar
    Join Date
    Jul 1999
    Posts
    153

    Post

    I have made a program that does just what you are asking for You can get the EXE here: Changer.exe and the source code here: Changer Code

    With some changes this should help you out.

    ------------------
    Cbomb
    Teen Programmer
    Techie 8)



    [This message has been edited by Cbomb (edited 02-15-2000).]

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