Advertisement
2002ASP Windows API Call/ Explanation #6908

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

ИИ-обзор: 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.

Исходный код
original-source
'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
Оригинальные комментарии (3)
Восстановлено из Wayback Machine