|
-
Sep 12th, 2000, 12:59 PM
#1
Thread Starter
Member
Okay, just a simple question and a simple procedure:
I use Windows 98 2nd ed. and Visual Basic 6. How to make my application to scan if there can be found a certain window, e.g a window called "notepad". If this window is deteceted (also if it is minimized), how to make my app to change its title? For example "notepad" --> "!NoTEPAD!". So the program runs a loop, which should not reserve all resources of the system. It should check this certain window e.g. every 1 minute.
-
Sep 12th, 2000, 01:10 PM
#2
Guru
You can use FindWindow and SetWindowText.
Code:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String) As Long
Sub ChangeTitle(ByVal sFrom As String, ByVal sTo As String)
Dim hWndToChange As Long
hWndToChange = FindWindow(vbNullString, sFrom)
Call SetWindowText(hWndToChange, sTo)
End Sub
Usage:
Call ChangeTitle("Untitled - Notepad", "UnTiTlEd ~ !NoTEPAD!")
Or something like that. 
If you want it to search ClassNames instead, then replace:
Code:
hWndToChange = FindWindow(vbNullString, sFrom)
With:
Code:
hWndToChange = FindWindow(sFrom, vbNullString)
For example, Windows Calculator's ClassName is always "SciCalc", but the caption can vary (on localized versions of Windows, the caption is "Calculator" in a different language, but the ClassName is always "SciCalc").
So sometimes you might want to look for ClassNames instead. 
As for the delay, use a timer!
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
|