Board index » delphi » Q. What size is this Window?

Q. What size is this Window?

I want to be able to find the bounding box of a Window.
I could use GetWindowRect, but I want to find what the size of the Window would be if it were
displayed in Normal format regardless of how it is actually being displayed.

I realize I could use Show(HWindow, sw_Normal) first and then measure it, but I'm trying to
avoid this step.

Here's my reason for asking.  I want to store the dimensions of the Window in an INI file.
 I will store its Normal size and will also store whether it is maximized, minimized, etc.
 Seeing as the writing to the INI file will be done just before the application terminates,
I don't want to have to waste time redisplaying the Window just before it gets destroyed.

Thanks in advance.

Malcolm J. Jones
TELUS Corporation

 

Re:Q. What size is this Window?


Quote
mjon...@ent.agt.ab.ca wrote:

: I want to be able to find the bounding box of a Window.
: I could use GetWindowRect, but I want to find what the size of the Window would be if it were
: displayed in Normal format regardless of how it is actually being displayed.

[....]

: Thanks in advance.

: Malcolm J. Jones
: TELUS Corporation

I use the following code (in TPW):

var
  Placement: TWindowPlacement;
begin
  FillChar(Placement,sizeof(TWindowPlacement),0);
  Placement.length:=sizeof(TWindowPlacement);
  if GetWindowPlacement(HWindow,@Placement)<>bool(0) then
      <extract the info - Placement.rcNormalPosition is a TRect which
     contains the rectangle for the window when its normalized.>

Hope this helps,

Eyal Doron

Other Threads