Delphi implementation form build changes with the size of the form

Source: Internet
Author: User

On the internet to find out a lot of information to discuss how to implement components in the Dephi with the window size changes, but it is not satisfactory. Some people say that using the components of the Align + anchors these two properties to control, but I used, let me be shocked. Turn the four values below the anchors property to True. If the user uses the mouse to drag the window, then the component on the window is like in the life scholar's unrecognizable foot, basically there is no so-called facial features.

The following describes my method, the same my method is to see the information of netizens to be completed.

(1) Download Tformresizer components

I use a third-party plug-in Tformresizer, first download a easysize.rar, (Baidu, should not be difficult to find) after the decompression, the contents of its files are as follows:

I suggest that you should put Easysite source files, and easysize.d32, EASYSIZE.DCU these three files in your Dephi installation directory in the Lib directory, because this is basically dephi components. The default for this component is that the label does not change with the size of the window, and the other components change with the size of the window. If you want to choose the default way, then do not modify the source file, directly install this component. (Note here: He will turn true regardless of whether you previously set the AutoSize property of the label label).

2. Modify the Easysize source file

(1). In the construction method of the Tsingleresizer, i.e. in constructor tsingleresizer.create (Linkedcontrol, Parentform:tcontrol;incfont:boolean ; Minfs, Maxfs:integer) Comment out the last sentence in the method:

{But does not adjust the width of labels (to avoid
Interaction of label auto-sizing with Re-sizing)}
If Fcomponent is Tcustomlabel then
Fflexwidth: = false;

Comment out these few words above

(2). In procedure tsingleresizer.resize (Ownerheight, ownerwidth; HeightRatio, widthratio:double) method found in the last few lines:

{IF component is a label, save original AutoSize value,
and set value temporarily to False}
If Fcomponent is Tcustomlabel then
Begin
Oldautosize: = Getautosizeproperty (fcomponent);
Setautosizeproperty (Fcomponent, False);
End
{End w.k. Insert}

And

{begin W.K. Insert}
{IF component is a label, set AutoSize temporarily to
True, call Refresh, and finally restore original value. }
If Fcomponent is Tcustomlabel then
Begin
Setautosizeproperty (Fcomponent, True);
Tcustomlabel (fcomponent). Refresh;
Setautosizeproperty (Fcomponent, oldautosize);
End
{End w.k. Insert}

Comment out the above words in curly braces.

(3) At this point, the source file modification is complete

3. Install Formresizer this group:

Open Dephi Software, I use the Dephi7, click Component->install Component, the following interface appears:

Click the Browse button on the unit file name row to load the easysize source file you just extracted, click the OK button after completion, pop up the following interface: Click the Comile button, so on the Tag tab page appears on the WWW on the Formresizer component.                4. Add the following code in the Form window: (1) procedure tform2.formcreate (sender:tobject); BeginFormresizer1.   Resizefonts: = true; Sets whether the font changes depending on the size of the window.
Formresizer1.initializeform;End (2) Add the following code to the OnResize event of the form: procedure tform2.formresize (Sender:tobject);
Begin
Formresizer1.resizeall;
End Since then, the components in the window can change depending on the size of the window. http://blog.163.com/i_love_you_chai/blog/static/1708911082010112105057644/

Delphi implementation form build changes with the size of the form

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.