Fremde Fenster in den Vordergrund setzen
[Windows 95/98/NT/2000]

08.07.2000


Mit wenigen API-Aufrufen ist es möglich, 
       fremde Fenster in den Vordergrund zu setzen.

       Hier am Beispiel des Rechners (calc.exe):

ERFORDERLICHE OBJEKTE
   2 CommandButtons (Command1, Command2)

 FORM-CODE
   Private Declare Function FindWindow Lib "user32" Alias _
      "FindWindowA" (ByVal lpClassName As String, _
      ByVal lpWindowName As String) As Long
   Private Declare Function SetWindowPos Lib "user32" _
      (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, _
      ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
      ByVal cy As Long, ByVal wFlags As Long) As Long
   Private Sub Command1_Click()
      wHandle = FindWindow(vbNullString, "Rechner")
      Call SetWindowPos(wHandle, -1, 0, 0, 0, 0, 3)
   End Sub
   Private Sub Command2_Click()
      wHandle = FindWindow(vbNullString, "Rechner")
      Call SetWindowPos(wHandle, -2, 0, 0, 0, 0, 3)
   End Sub
   Private Sub Form_Load()
      Command1.Caption = "Vordergrund"
      Command2.Caption = "Zurücksetzen"
   End Sub