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
:confused:
------------------
david
Teenage Programmer
Printable View
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
:confused:
------------------
david
Teenage Programmer
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)
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:
Hope that helpsCode: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
~seaweed
[This message has been edited by seaweed (edited 02-15-2000).]
I believe you need to add the following to refresh the window.
WadeCode:Declare Function DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long
DrawMenuBar lhwnd
I have made a program that does just what you are asking for :D 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).]