BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TitleBar Rectangle

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics)
View previous topic :: View next topic  
Author Message
Bart Huls
Guest





PostPosted: Thu Oct 09, 2003 7:13 am    Post subject: TitleBar Rectangle Reply with quote



Hi,

Can Someone tell me how to get the exact dimensions of the titlebar rect
making use of the
GetSystemMetrics functions

Regards,

Bart


Back to top
PaoloItaly
Guest





PostPosted: Thu Oct 09, 2003 10:13 am    Post subject: Re: TitleBar Rectangle Reply with quote




"Bart Huls" <b.huls (AT) REMOVEmeteo (DOT) nl> ha scritto nel messaggio
news:3f850a9e (AT) newsgroups (DOT) borland.com...
Quote:
Hi,

Can Someone tell me how to get the exact dimensions of the titlebar rect
making use of the
GetSystemMetrics functions

Regards,

Bart


TWidget: A Title Bar Button

~~~~~~~~~~~~~~~~~~~~~~~~~~~

Copyright 1998, 1999 by Robert R. Marsh, SJ
and the British Province of the Society of Jesus

[email]rrm (AT) sprynet (DOT) com[/email]
http://home.sprynet.com/sprynet/rrm

procedure TWidget.CalculateWidgetArea;
var
xframe: integer;
yFrame: integer;
xsize: integer;
ysize: integer;
i: integer;
Icons: TBorderIcons;
Style: TFormBorderStyle;
TotalGap: integer;
wr: TRect;
begin
if (Owner = nil) then
exit;
with (Owner as TForm) do
begin
// it will be different at design time
if (csDesigning in ComponentState) then
begin
Icons := [biSystemMenu, biMinimize, biMaximize];
Style := bsSizeable;
end
else
begin
Icons := BorderIcons;
Style := BorderStyle;
end;
if Style in [bsSizeToolWin, bsToolWindow] then
begin
if Style = bsToolWindow then
xframe := GetSystemMetrics(SM_CXFIXEDFRAME)
else
xframe := GetSystemMetrics(SM_CXSIZEFRAME);
if biSystemMenu in Icons then
inc(xframe, GetSystemMetrics(SM_CXSMSIZE));
if Style = bsToolWindow then
yframe := GetSystemMetrics(SM_CYFIXEDFRAME)
else
yframe := GetSystemMetrics(SM_CYSIZEFRAME);
ysize := GetSystemMetrics(SM_CYSMSIZE);
xsize := GetSystemMetrics(SM_CXSMSIZE);
end
else
begin
if Style in [bsSingle, bsSizeable, bsDialog] then
begin
if Style = bsSingle then
xframe := GetSystemMetrics(SM_CYFIXEDFRAME)
else
xframe := GetSystemMetrics(SM_CXSIZEFRAME);
if biSystemMenu in Icons then
begin
inc(xframe, GetSystemMetrics(SM_CXSIZE));
if (Style <> bsDialog) and (Icons * [biMinimize, biMaximize] <>
[]) then
inc(xframe, GetSystemMetrics(SM_CXSIZE) * 2)
else
if biHelp in Icons then
inc(xframe, GetSystemMetrics(SM_CXSIZE));
end;
if Style in [bsSingle, bsDialog] then
yframe := GetSystemMetrics(SM_CYFIXEDFRAME)
else
yframe := GetSystemMetrics(SM_CYSIZEFRAME);
ysize := GetSystemMetrics(SM_CYSIZE);
xsize := GetSystemMetrics(SM_CXSIZE);
end;
end;
// calculate TotalGap from other widgets
TotalGap := 2;
if WidgetNumber > 0 then
begin
for i := 0 to FOwnerForm.ComponentCount - 1 do
begin
if (FOwnerForm.Components[i] is TWidget) and
(((FOwnerForm.Components[i]) as TWidget).WidgetNumber < WidgetNumber) then
Inc(TotalGap, ((FOwnerForm.Components[i]) as TWidget).Gap);
end;
end;
inc(xframe, TotalGap + (WidgetNumber * (xsize - 2)));
// finally we calculate the size and position of the widget
GetWindowRect(FOwnerForm.Handle, wr);
FRightOffset := xFrame + xSize - 4 + Gap;
FWidgetRect := Bounds((wr.Right - wr.Left) - FRightOffset, yFrame + 2,
xSize - 2, ySize - 4);
end;
end;




Back to top
Dumboo
Guest





PostPosted: Tue Oct 21, 2003 11:58 am    Post subject: Re: TitleBar Rectangle Reply with quote



Quote:
Can Someone tell me how to get the exact dimensions of the titlebar rect
making use of the
GetSystemMetrics functions

i m having a much simple way, without using Win32 API


since the Height of the Title Bar is the area not under the Client area, we
can get it by subtracting the ClientHeight, from the original heihgt

ShowMessage(Height - ClientHeight);

and since the title bar is having same width os of the form, we dont have to
do anything just read the width of the Form

ShowMessage(Width);

hope this of some help to you :-)

-Dumboo



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.