[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Margins and aligned components

Posted on 1997-12-12
5
Medium Priority
?
348 Views
Last Modified: 2010-04-04
Hi,

Is it possible to set the margin which Delphi 3 uses when it aligns components? If I align a component with, for example, alClient. Can I specify how much space (pixels)(instead of the default 2 pixels) I will have between the parent edge and my components edge?

/pivar
0
Comment
Question by:pivar
5 Comments
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1353433
I think that the 2 pixel edge is determined from the system metrics.  There is a way to get around this problem.  Put a panel on your form, and set BevelInner = bvNone, BevelOuter = bvNone, and Align = alClient.  Set the panel's BorderWidth to the value you require and put your control inside the panel.

Regards,
JB
0
 
LVL 22

Author Comment

by:pivar
ID: 1353434
Hi JimBob,

Your solution works, but I'm reopening the question because I would like another solution. I don't want to use panels because I have problems with scarce windows resources. And if I recall right, the panels uses windows resources.

Thanks,
pivar


0
 
LVL 4

Expert Comment

by:StevenB
ID: 1353435
 You could always set the width and height of your component yourself using OnResize.

  e.g.

  {For a border of 10 pixels arround your component, place the component such that Top and Left := 10}
  In the OnResize Put something like:
 
  *Component*.Width := ClientWidth-20;
  *Component*.Height := ClientHeight-20;

  Steven.

  {Just a comment for the moment, but if you like the answer then let me know}

0
 
LVL 4

Accepted Solution

by:
d003303 earned 200 total points
ID: 1353436
Hi,
I think there is no solution except the modification of the anchestor object TControl.
If you do so, you need Delphi Professional or C/S to modify the source.

I don't want to go too much in detail here, but the strategy is the following :

Best would be to set a global value for the indent, not one value for each corner. This has to be a new published property for TControl. In the property write handler, you have to call RequestAlign if the property was really changed.

The core modification is the protected method AlignControls of TWinControl (unit Controls). In the internal procedure DoPosition you modify the SetBounds-Values accordingly, incrementing or decrementing the bounds by the indent property value.

Hope this helps,
Slash/d003303
0
 
LVL 22

Author Comment

by:pivar
ID: 1353437
Hi d003303,

I've had the same thoughts. I just hoped there would be an easier way to do this, like a property to set somewhere, but I suppose this is the way to do it.

/pivar
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question