?
Solved

Margins and aligned components

Posted on 1997-12-12
5
Medium Priority
?
346 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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month8 days, 16 hours left to enroll

764 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