Solved

How do I find the size of a form programmatically ?

Posted on 2014-11-18
6
195 Views
Last Modified: 2014-11-19
Hi,

I learned to size a form by using auto size and sizing a main panel on the form. This works well but really I should be able to grab the edges of a window and size it this way, then get the size of the window and resize my components. The first problem I encountered is that I cannot access form size programmatically. The other mystery is, which event should I use.
0
Comment
Question by:ChLa
6 Comments
 
LVL 3

Expert Comment

by:lopem
ID: 40450735
ChLa,

The form is also an object (like a button, for example). So your problem, I guess is very easy to solve. Put a form with a button and try on the click evento of teh button the next code:

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage('The size of the form is '+ inttostr(Form1.Width) + 'x'+ inttostr(Form1.Height));
end;


Hope this helps!
0
 
LVL 26

Accepted Solution

by:
Sinisa Vuk earned 500 total points
ID: 40450847
Best way is to align components according to form. Put panel and set Align to client, put other components on it. Then you can set another panel on same level to left or right.... Components can be resized using Anchor property ....
0
 

Author Comment

by:ChLa
ID: 40451801
This second answer works really well. Is an event triggered after the form has been rezised that I can use to do a few things ?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 26

Expert Comment

by:Sinisa Vuk
ID: 40451946
Components like Form, Panel, Frame, ... have OnResize event and you can use it for what you need.
0
 
LVL 19

Expert Comment

by:MerijnB
ID: 40452325
Alternatively you can set align to alCustom, and use the OnAlignPosition() event do to the aligning yourself.
0
 

Author Comment

by:ChLa
ID: 40452929
The Form OnResize event is working well for me now. At first when I tried it I was confused by the fact that the first event occurs when the form is created. I ignored the first event and now it is all good. Thank everyone for their help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
A short film showing how OnPage and Connectwise integration works.

932 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

10 Experts available now in Live!

Get 1:1 Help Now