Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-04

Form Height with Windows XP Themes

10 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

faber

Hi,
I need help with getting real size of window.
No matter whether I use a Windows XP composition or not, heigh of Forms is always the same, without computing borders and title bar. I need this to get bitmap of my form:

   c.Handle := GetWindowDC(Form1.Handle);
   r := Rect(0, 0, Form1.Width, Form1.Height);
   BitM.Width := Form1.Width;
   BitM.Height := Form1.Height;
   BitM.Canvas.CopyRect(r, c, r);

it that case width and height are smaller then real window size (width
- 7 , height - 26 in case without compositions)

How to get info about borders size and title bar (or if themes composition is used) ?

Reply by email

Gabor Boros
to faber

Hi,

Form1.ClientHeight, Form1.ClientWidth not a good solution for you?

Gabor

faber ?rta:

Show quoted text 17 lines
Hi, I need help with getting real size of window. No matter whether I use a Windows XP composition or not, heigh of Forms is always the same, without computing borders and title bar. I need this to get bitmap of my form: c.Handle := GetWindowDC(Form1.Handle); r := Rect(0, 0, Form1.Width, Form1.Height); BitM.Width := Form1.Width; BitM.Height := Form1.Height; BitM.Canvas.CopyRect(r, c, r); it that case width and height are smaller then real window size (width - 7 , height - 26 in case without compositions) How to get info about borders size and title bar (or if themes composition is used) ?

Reply by email

Zaher Dirkey
to Faber

Use GetWindowRect to get the window size from out
Use GetClientRect to get the inner rect that can draw in it. the deffrent between the 2 of rect is depend on the theme you are use, But you must notice the ClientRect is always has Left, Top = 0; so try to offset the WindowRect to 0, 0

Faber wrote 17 lines
> Hi, > > Form1.ClientHeight, Form1.ClientWidth not a good solution for you? > form1.ClientHeight is smaller then form1.Height, in my case 538 vs. 557 (19px) regards faber -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Zaher Dirkey -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100408/86ff9143/attachment.html>

Reply by email

Hans-Peter Diettrich
to John
In Lazarus, form1.height returns the client height not the form height so this doesn't work.

AFAIR the LCL doesn't handle the non-client areas of controls. I.e. Height and ClientHeight (typically) are identical.

DoDi

Reply by email

Paul Ishenin
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote
AFAIR the LCL doesn't handle the non-client areas of controls. I.e. Height and ClientHeight (typically) are identical.

Yes. Only GetWindowRect can return a full window rectangle.

Best regards,
Paul Ishenin.

Reply by email

Hans-Peter Diettrich
to Paul Ishenin
> AFAIR the LCL doesn't handle the non-client areas of controls. I.e. > Height and ClientHeight (typically) are identical. Yes. Only GetWindowRect can return a full window rectangle.

Why is this function not used to provide the correct sizes?

DoDi

Reply by email

Faber
to Zaher Dirkey: Use GetWindowRect to get the window size from out Use GetClientRect to get the inner rect…

Dnia 2010-04-08, o godz. 00:28:00
Zaher Dirkey napisa?(a):

Show quoted text 5 lines
Use GetWindowRect to get the window size from out Use GetClientRect to get the inner rect that can draw in it. the deffrent between the 2 of rect is depend on the theme you are use, But you must notice the ClientRect is always has Left, Top = 0; so try to offset the WindowRect to 0, 0

Thanks, GetWindowRect works as I need.

regards
faber

Reply by email

Mattias Gärtner
to Hans-Peter Diettrich: Why is this function not used to provide the correct sizes? DoDi

Zitat von Hans-Peter Diettrich :

Show quoted text 8 lines
Paul Ishenin schrieb: >> AFAIR the LCL doesn't handle the non-client areas of controls. I.e. >> Height and ClientHeight (typically) are identical. > > Yes. Only GetWindowRect can return a full window rectangle. Why is this function not used to provide the correct sizes?

I added some notes to the FAQ:

http://wiki.lazarus.freepascal.org/Autosize_/_Layout#Why_is_TForm.Width_equal_to_TForm.ClientWidth.3F

Mattias

Reply by email