Jump to content
Sign in to follow this  
Daniel Eiszele

Control Alignments

Recommended Posts

Hi @jarto, with reference to the attached project, I am having some issues with control alignments at runtime. Graphically, the below form looks fine in the IDE at design time and similarly if it is the main form at run time, or alternately created dynamically (refer image below).

image.png.23d1382eab6a4b54dae675c21bed5971.png

However, when it is a secondary form that is Auto Created at runtime then the editboxes do not adhere to their AlignClient status. (refer to the following image where editboxes are not client aligned).

image.png.24d07397d30b8a6814df2c10041c87e4.png

Please let me know if my explanation is unclear. Hopefully the graphics explain the problem well enough though.

 

Alignment Test.zip

Share this post


Link to post
Share on other sites

This is now fixed in the latest alpha. It required bigger changes but the end result should be better. Like I wrote earlier, the problem was that form1 (in this example) was hidden too early. Let me give you some background, so you guys know better about what's going on when an SMS app is starting:

If you have multiple forms, they all are constructed during startup. The main form is easy: Just build it and there it is. The other forms are trickier as they need to be built off screen and then hidden. The construction of all forms have to happen with visible=true as ClientRect, ClientWidth and ClientHeight will not otherwise return correct values.

In this example program, the form was built properly, but resizes were still going on when the form was hidden. That's because setting an alignment caused a delayed resize on the parent control. It has to be delayed as we don't want the parent control to realign all the child components right away when any of them changes alignment. That'd lead to flickering and tons of extra resizes.

The solution I took was to block all resizes and alignments while the form is being built from form's sfm-file. When all controls have been created and properties set, I recursively call resize and align once on controls from bottom up. In my tests it has worked well. Please let me know if this breaks your code.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×