?
Solved

How do I find the size of a form programmatically ?

Posted on 2014-11-18
6
Medium Priority
?
202 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
[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
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 27

Accepted Solution

by:
Sinisa Vuk earned 2000 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
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!

 
LVL 27

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

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month11 days, 3 hours left to enroll

770 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