AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Vom Handle zur Position und Größe einer Form
Thema durchsuchen
Ansicht
Themen-Optionen

Vom Handle zur Position und Größe einer Form

Ein Thema von Jelly · begonnen am 16. Jan 2005 · letzter Beitrag vom 22. Mai 2005
Antwort Antwort
Benutzerbild von Jelly
Jelly

Registriert seit: 11. Apr 2003
Ort: Moestroff (Luxemburg)
3.741 Beiträge
 
Delphi 2007 Professional
 
#1

Vom Handle zur Position und Größe einer Form

  Alt 16. Jan 2005, 11:11
Irgendwie komm ich nicht weiter.

Über GetActiveWindow erhalte ich das Handle der gerade aktive Form. Ich kann mit diesem Handle aber direkt nix anfangen. Ich suche nach ner Möglichkeit, aufgrund dieses Handle auf die Position und Größe des Fenster zu schließen, aber irgendwie hab ich da keine Ahnung, wie diese ganzen API Befehler heissen.

Zum Hintergrund, ich will einen Screenshot des aktuellen Fenster mache, und diesen und desse Thumbnail als JPG zu speichern.
  Mit Zitat antworten Zitat
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
Benutzerbild von Jelly
Jelly

Registriert seit: 11. Apr 2003
Ort: Moestroff (Luxemburg)
3.741 Beiträge
 
Delphi 2007 Professional
 
#3

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

  Alt 16. Jan 2005, 11:50
Danke, genau das hab ich gesucht... Klappt einwandfrei...
  Mit Zitat antworten Zitat
Aike

Registriert seit: 2. Okt 2004
319 Beiträge
 
#4

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

  Alt 22. Mai 2005, 19:40
Wie ist denn das Handle den "Windows-Fensters"? (sozusagen der explorer.exe (nicht der Datei-Manager)
Achim
  Mit Zitat antworten Zitat
marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#5

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

  Alt 22. Mai 2005, 19:45
Der Explorer macht ganz viele Fenster auf, aber das prominenteste ist wohl der Desktop - meinst du den?

hWnd := GetDesktopWindow; Grüße vom marabu
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:52 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz