0
votes

I have a (Delphi bug?) that is annoying me for months: in one of my apps I have some controls (tedit, tbutton, etc) on a TPanel. Every time I close the project and reopen it I find the controls moved few pixels up. After 20-30 closings the controls are almost out of the panel so I have to drag them back. Anybody encountered such a problem? How to fix it?

I have Delphi XE.


Update:
Actually I have encountered this in two of my projects. Both involve controls on a TPanel.
If I compile the project the controls, in the exe, the controls are at the wrong position also.
I have a TEdit that is aligned to the top (of the TPanel) and its bottom is anchored to the bottom. The bottom will also 'forget' its correct position and move to the top.


Update:
Bug confirmed. It appears when the user changes the Bevel properties of the panel!

3
How can we reproduce this?David Heffernan
I don't know (sorry). I is only in two projects. I try right now to copy paste the whole TPanel in the same form to see if the copy behaves the same way.Server Overflow
I know, my question might be too localized. I was just hopping somebody else had a similar problem (and solution).Server Overflow
Just to confirm that the bug really exists. I had same issue happening to me in one of my projects some time ago.rsrx

3 Answers

2
votes

This issue is reported in Quality Central #106320 for Delphi XE2, in June 2012.
Its status is still 'need feedback', there is no sample project, but it looks as if has to do with descendant forms.

I suggest that once you have determined the exact location that you want the components to be in, you adjust their position in the FormCreate.
Then, in designmode you can just 'approximately' correct the position quickly, knowing that they will come out right at run-time.

Robs suggestions also sound worth a try.

BTW Should you manage to make a sample project, maybe others can then determine if it is fixed in later versions.

1
votes

There is evidently some conflict between anchors and position, possibly involving form inheritance. I expect it has something to do with the order that various positioning constraints are applied in, as well as when the parent control's border size or margin gets updated. Besides, aligning to the top and anchoring the bottom sounds like a recipe for problems. Instead, consider clearing the alignment setting and anchoring the top and sides; it should give the same effect. Alternatively, put a spacing control (e.g., a TShape) aligned to the bottom of the panel, and then align the edit control to the client area, which should give the same effect as anchoring to the bottom.

Nonetheless, this should be easy to work around. In your form's OnCreate event handler, move your components to their correct positions by calling SetBounds on them. To stop further movement during the development cycle, you should probably clear the anchors, and then re-set them at run time.

1
votes

It happened to me also in D7. I found that whenever I have open design time forms and change the resolution of desktop or minimize the IDE the bottom aligned controls are get pushed downwards, sometimes out of the form.

In order to prevent that kind of I use nowadays the same way HTML pages are designed.

Each of my forms have a layout that are divided with tPanels (like or tags used in html) tPanels are aligned according to their design.

Might not be the same problem but I think the solution I've found might work for you too.