Tutorial :Frame behavior in Delphi application issue


I have an application that uses a frame extensively and needs to hide/show certain buttons depending on which form is active at the time. In order to keep the buttons neat and organized appropriately, I have put them on panels and show or hide the panels as needed for each form. My problem is when each form is initially created, the panels on the frame are out of order even though I am explicitly telling them which order to put themselves into. After I hide and re-show the form, the panels are in the correct order. Any suggestions on how to keep them in the proper order from the very beginning?


Instead of giving the panels explicit positions, try giving them alignments. They tend to stick better than way, and they do a better job of resizing if you resize the form.


You can also try using a stackpanel (or was it flowpanel?) as parent for the panels. Then you will have a order instead of a position to manipulate.


Maybe you can have a look at the DevExpress LAyoutControl? It helps us creating interfaces that always look good, no matter if we show or hide certain groups / panels. It even allows for run-time customization of the interface, if you want that!


You may try to organize them by coordinates i.e.: setting Top and Left. Unless your panels are aligned, this will always work (but it takes bit lot of work).


I had this problem and I found that the solution was to do this in FormCreate (or in a CMShowingChanged method of your frame):

MyPanel1.Align := alNone;  MyPanel2.Align := alNone;  MyPanel1.Align := alBottom;  MyPanel2.Align := alBottom;  

Restore in the order that you need - this seemed to sort out the order visually.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »