[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 154
  • Last Modified:

Using VB, can I control the Title Bar contents of other programs?

Need to be able to control the TITLE BAR contents of other APPS.
Can I do it somehow with VB?
Any other suggestions?
0
rbend
Asked:
rbend
1 Solution
 
TimCotteeCommented:
You need to use the api function SetWindowText in order to be able to change the title bar contents.
0
 
VbmasterCommented:
I uploaded a 'Window Handling' Class to

http://www.cyd.liu.se/~freqv416/clsWindow.cls

Check it out, you can try to change the 'Caption' property to see the SetWindowText API in action.
0
 
rbendAuthor Commented:
VBMaster: please don't think I'm an idiot, just not that accomplished at VB programing.
1) I'm not aware of how to use a class.
   Can you walk me through it a little?
2) Will this change the Window Title of any apps window or just that of a VB app/?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
jjmartinCommented:
Try this:

Here are your public declarations:
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long


Here is the code.  This will launch a telnet session and change the caption in the title bar:

Private Sub Command1_Click()
    Dim lHandle As Long
    Dim H As Long

   
    Shell "telnet.exe"

    H = FindWindow("TelnetWClass", vbNullString)
    lHandle = SetWindowText(H, "JUNK")

End Sub

You should know that this method is not 100%.  The caption has the tendancy to change back to what it was before you changed it.
0
 
rbendAuthor Commented:
tried to substitute Notepad for Telnet but could not get it to work.
How would you do that?
0
 
jjmartinCommented:
If you do not know the WindowsClassName then you can use the orginal text in the title bar.  Substitute this:

H = FindWindow(vbNullString, "Untitled - Notepad")


This is passing a null string in place of the windows class name, and instead telling the find window API to look for a window with the title "Untitled - Notpad".
0
 
rbendAuthor Commented:
This seems ok.
The one I really needed to change was Microsoft Outlook Express and I tried several combinations of things but could not get it to work.
Thanks..
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now