|
-
Jun 15th, 2001, 01:21 AM
#1
Thread Starter
Addicted Member
How do I change the caption of....
Hi,
Just wondering what the code would be to find a window and change it's caption? I have the finding the window part down, and I can already change the "Start" button caption, but I am having troubles with other windows. For example: Changing the caption of Notepad to what ever string is typed into Text1.
Yes I am still new to programming, I only started 2 weeks ago, so all help is VERY much appreciated.
Thanx,
Scott
-
Jun 15th, 2001, 05:19 AM
#2
Frenzied Member
VB Code:
'first use findwindow to get the windows handle
Dim h as Long
h = FindWindow(classname,caption)
'then use
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Sub Form_Activate()
Dim MyStr As String
'Create a buffer
MyStr = String(100, Chr$(0))
'Get the windowtext
GetWindowText text1.hwnd, MyStr, 100
'strip the rest of buffer
MyStr = Left$(MyStr, InStr(MyStr, Chr$(0)) - 1)
'Set the new window text
SetWindowText h, MyStr
End Sub
-
Jun 15th, 2001, 10:04 AM
#3
I am working on something similar. It is a Routine to extract the text from a label on a Msgbox from another aplpication. The ultimate goal is to create a web-based interface for registering server scriptlets(through Scrobj.dll) on a server. I've used a variety of API's to shell out to RegSvr32.exe, but I need to retreive the result of any UI-based Error Messages. I can't use a batch file to spool output because I'd need someone sitting at the server to click the 'OK' button. (If I had that, then I might as well tell them to just manually register the scriptlet)
So far I've used EnumWindows to obtain a list of all the window handles, then GetClassName to get the window's class name, then once i find the class (Spy++ tells me that it's "Static"), I call GetWindowText with the current handle, but it returns nothing.
I've also tried Using SendMessage, supplying the constants WM_GETTEXTLENGTH and WM_GETTTEXT, but they return nothing as well.
-
Oct 10th, 2001, 01:23 PM
#4
-
Oct 11th, 2001, 05:44 AM
#5
Fanatic Member
-
Oct 12th, 2001, 10:12 PM
#6
Fanatic Member
about the message box problem, I don't think you can retrieve the text, but can't you do a screen capture of it with vb and send the capture back, then use send message to simulate the appropriate click based on a hyperlink in the webpage?
Basically, the server send a picture of the message box to the client, and has a link for button1 button2 button3 or button4.
You could also use sendmessage with wm_close to close msgboxes with OK buttons. I use that method with programs that have recuring nag screens.
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
|