Results 1 to 6 of 6

Thread: How to change caption of external windows

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Arrow How to change caption of external windows

    Hi all . could any one show me how i can change the caption of external window?Thanks

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: How to change caption of external windows

    You use the FindWindow API to get the handle of the window you want and then the SetWindowText API to change the text. If you search for these two APIs you'll find more than enough examples


    Has someone helped you? Then you can Rate their helpful post.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: How to change caption of external windows

    Quote Originally Posted by manavo11
    You use the FindWindow API to get the handle of the window you want and then the SetWindowText API to change the text. If you search for these two APIs you'll find more than enough examples
    thank u for reply. I do not want to change the text i mean change caption. Could u show me how ? i have no experince one changing caption of window.

  4. #4
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: How to change caption of external windows

    Open a notepad window and try the following :

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    4. Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
    5.  
    6. Private Sub Form_Load()
    7.     Dim hNotepad As Long
    8.    
    9.     hNotepad = FindWindow("notepad", vbNullString)
    10.     SetWindowText hNotepad, "test"
    11. End Sub

    Only, instead of using the "notepad" classname, you need to either change the classname to that of the window you want to change or use the caption of the window to find it's handle


    Has someone helped you? Then you can Rate their helpful post.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Arrow Re: How to change caption of external windows

    Thank u for u reply . It worked perfectly. Is there away to bring a window in front baced on its caption ?Thanks
    Last edited by tony007; Jun 15th, 2006 at 06:35 PM.

  6. #6
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to change caption of external windows

    VB Code:
    1. AppActivate "Untitled - Notepad"

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