Solved

Margins and aligned components

Posted on 1997-12-12
5
345 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 100 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

Independent Software Vendors: 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

689 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