Window Manipulation
This code will show you how to retreive a handle of an open window and how to manipulate that window once you have it's handle.
AI
KI-Zusammenfassung: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Quellcode
'Add a command button to a form, set the command
'button's name to Command1, then add this code
'to your form's code.
Private Sub Command1_Click()
Dim lhWnd As Long 'Holds the handle to the window
'The FindWindow parameter is as follows:
'lpClassName: This is the name of the class
' Use the Spy ++ utility to retreive
' this information
'lpWindowName: This is the caption of the window
lhWnd = FindWindow("Minesweeper", "Minesweeper")
Text1.Text = lhWnd
'Make sure we have a valid handle
If lhWnd <> 0 Then
'Flash the window by inverting it
'If it has focus, then remove focus
'If it doesn't have focus, give it focus
FlashWindow lhWnd, 1
End If
If lhWnd <> 0 Then
'Change the window's caption
SetWindowText lhWnd, "ChangedSweeper"
End If
End Sub
Originalkommentare (3)
Wiederhergestellt von der Wayback Machine