Position fremder Fenster ermitteln
[Windows 95/98/NT/2000]

27.12.2000


Ähnlich wie die Größe kann man auch die Position
    fremder Fenster feststellen.

ERFORDERLICHE OBJEKTE
   1 Timer (Timer1)

FORM-CODE

   Private Declare Function FindWindow Lib "user32" Alias _
      "FindWindowA" (ByVal lpClassName As String, ByVal _
      lpWindowName As String) As Long
   Private Declare Function GetWindowRect Lib "user32" _
      (ByVal hwnd As Long, lpRect As RECT) As Long
   Private Type RECT
      Left As Long
      Top As Long
      Right As Long
      Bottom As Long
   End Type
   Private Rec As RECT
   Private Sub Form_Load()
      'hier am Beispiel Rechner
      Shell "calc.exe"
      Timer1.Interval = 250
   End Sub
   Private Sub Timer1_Timer()
      wHandle = FindWindow(vbNullString, "Rechner")
      GetWindowRect wHandle, Rec
      'Position in einer Variable speichern
      x= Rec.Left
      y= Rec.Top
   End Sub

 


Download - 2 KB