Solved

Margins and aligned components

Posted on 1997-12-12
5
336 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
Comment Utility
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
Comment Utility
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
Comment Utility
 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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now