FindWindow
Aus API-Wiki
Version vom 29. März 2009, 14:43 Uhr von Nils Thomsen (Diskussion | Beiträge)
Die druckbare Version wird nicht mehr unterstützt und kann Darstellungsfehler aufweisen. Bitte aktualisiere deine Browser-Lesezeichen und verwende stattdessen die Standard-Druckfunktion des Browsers.
Die API-Funktion FindWindow sucht ein Fenster mittels 2 Parameter und gibt deren Fensterhandle zurück.
Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Parameter
lpClassName
- Gibt den Klassennamen an, nach der gesucht wird. Ist der Klassennamen unwichtig, so wird vbNullString verwendet.
lpWindowName
- Gibt den Fensternamen an, nach dem Gesucht wird. Ist der Fenstername unwichtig, so wird vbNullString verwendet.
Rückgabewerte
Die Funktion gibt einen wert vom Typ long zurück und beinhaltet das Handle des gefundenen Fensters. Wurde das Fenster nicht gefunden, so ist der Wert 0.
Beispiel
Der Aufruf ist simpel. In diesem Beispiel wird das Fenster des Windows Taschenrechners gesucht.
Dim Handle As Long
Handle = FindWindow(vbNullString, "Rechner")
If Handle <> 0 Then
MsgBox "Der Windows-Rechner ist geladen!", vbInformation, "Fenster gefunden!"
Else
MsgBox "Der Windows-Rechner ist nicht geladen!", vbInformation, "Fenster nicht gefunden!"
End If
Hinweise
Diese Funktion findet immer nur das erste Fenster mit dem angegebenen Titel oder Klassennamen. Sind nun zwei Fenster mit gleichem Titel geöffnet, so kann die Funktion nur das erste Fenster finden.
Betriebsystem
Die Funktion ist unter folgenden Betriebssystemen funktionsfähig:
- Windows NT 4.0
- Windows NT 5.0 (2000)
- Windows XP (ab SP2)
- Windows Vista (nur x64)
Verweise
- ActiveVB Tipp 0003
- ActiveVB Tipp 0111
- ActiveVB Tipp 0201
- ActiveVB Tipp 0214
- ActiveVB Tipp 0274
- ActiveVB Tipp 0304
- ActiveVB Tipp 0333
- ActiveVB Tipp 0337
- ActiveVB Tipp 0343
- ActiveVB Tipp 0382
- ActiveVB Tipp 0449
- ActiveVB Tipp 0489
- ActiveVB Tipp 0515
- ActiveVB Tipp 0528
- ActiveVB Tipp 0567
- ActiveVB Tipp 0573
- Microsoft Knowledge-Base KB107689 - HOWTO: Programmatically Disable Microsoft Excel Control Menu Commands
- Microsoft Knowledge-Base KB129388 - INFO: How Null String Pointers Behave in Visual Basic
- Microsoft Knowledge-Base KB153025 - FIX: Microsoft Excel 95 Doesn't Respond Correctly to GetObject
- Microsoft Knowledge-Base KB153463 - HOWTO: Close Applications from Visual Basic
- Microsoft Knowledge-Base KB168204 - HOWTO: Kill an Application with System Menu Using VB
- Microsoft Knowledge-Base KB168768 - VBA: Assigning Word Styles to the PowerPoint Slide Master
- Microsoft Knowledge-Base KB172369 - Viewer Quit Method Does Not Close Viewer (PPT97)
- Microsoft Knowledge-Base KB176391 - HOWTO: Programmatically Close a Single Instance of a Windows-Based Program
- Microsoft Knowledge-Base KB185730 - HOWTO: Prevent multiple instances of a 32-bit VB application
- Microsoft Knowledge-Base KB186431 - HOWTO: Bring an Application Window to the Top with Focus
- Microsoft Knowledge-Base KB210500 - HOWTO: Make Microsoft Access Windows Stay on Top of Other Windows (ACC2000)
- Microsoft Knowledge-Base KB210605 - HOWTO: Determine If a Specific Windows Program Is Running (ACC2000)
- Microsoft Knowledge-Base KB213502 - HOWTO: Disable Microsoft Excel Control Menu Commands programmatically (XL2000)
- Microsoft Knowledge-Base KB238245 - HOWTO: Call the ShellExecute Windows API Function (WD2000)
- Microsoft Knowledge-Base KB242308 - HOWTO: Find a Window Handle from an Instance Handle
- Microsoft Knowledge-Base KB258511 - HOWTO: Obtain the Window Handle for an Office Automation Server
- Microsoft Knowledge-Base KB290150 - HOWTO: Hide and Unhide the Windows Taskbar programmatically (OFFXP)