Einzelnen Beitrag anzeigen

Benutzerbild von Ultimator
Ultimator

Registriert seit: 17. Feb 2004
Ort: Coburg
1.860 Beiträge
 
FreePascal / Lazarus
 
#2

Re: Vom Handle zur Position und Größe einer Form

  Alt 16. Jan 2005, 11:23
Ich glaube, da ist getWindowRect das richtige für dich

Zitat:
The GetWindowRect function retrieves the dimensions of the bounding rectangle of the specified window. The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.

BOOL GetWindowRect(

HWND hWnd, // handle of window
LPRECT lpRect // address of structure for window coordinates
);

Parameters

hWnd

Identifies the window.

lpRect

Points to a RECT structure that receives the screen coordinates of the upper-left and lower-right corners of the window.
Noch was zum o.g. Rect:

Zitat:
The RECT structure defines the coordinates of the upper-left and lower-right corners of a rectangle.

typedef struct _RECT { // rc
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECT;


Members

left

Specifies the x-coordinate of the upper-left corner of the rectangle.

top

Specifies the y-coordinate of the upper-left corner of the rectangle.

right

Specifies the x-coordinate of the lower-right corner of the rectangle.

bottom

Specifies the y-coordinate of the lower-right corner of the rectangle.
[edit] Noch schnell n Beispiel, es geht nämlich einfach mit nem TRect als _RECT
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var MyRect:TRect;
begin
GetWindowRect(Form1.Handle,MyRect);
ShowMessage('Links oben: X: '+inttostr(MyRect.TopLeft.X) +', Y: '+ inttostr(MyRect.TopLeft.Y)+
  #10#13+'Rechts unten: X: '+inttostr(MyRect.BottomRight.X)+', Y: '+inttostr(MyRect.BottomRight.Y));
end;
Julian J. Pracht
  Mit Zitat antworten Zitat