|
-
Feb 14th, 2000, 05:30 PM
#1
Thread Starter
Conquistador
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
-
Feb 14th, 2000, 06:25 PM
#2
Hyperactive Member
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)
-
Feb 15th, 2000, 02:04 AM
#3
Frenzied Member
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).]
-
Feb 15th, 2000, 04:35 AM
#4
Hyperactive Member
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
-
Feb 15th, 2000, 08:44 AM
#5
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|