Layout issues and size

Posted by Darren Parr on 28-May-2013 13:03


I have a strange issue that I think there is an elegant solution for...

I have an ultrapanel in a progress form which embeds a progress window (.w) procedure.

After running the ,w but before the window is realised, a callback creates a windowcontainer object and drops it into the panel by adding it to the panels controls collection. The windowcontainer is docked with dockstyle fill so that it consumes the full size of the panel. At this point I have elected to PAUSE 0.01. I shouldnt need to do this here but there is a reason it is proving necessary, Please read on for more info. All seems good at this point.

In a subsequent procedure in the window .w file, I calculate the size of the panel so that I can resize the window. On querying the size it returns the wrong size altogether. If I add a PAUSE 0.01 NO-MESSAGE to the routine which does the embedding before it returns all works OK. It almost like the size object needs to be recalculated and only a pause does this.

Is there a more elegant way of getting the size objects recalculated in a form or control. It looks like there is an asynchronous nature to these properties. For example setting any controls dock to fill (so that its size changes) and then querying the size immediately afterwards never works. It does work if you wait in some way. I need to almost block to allow the UI to catch up.

Any help is greatly appreciated.



All Replies

Posted by Admin on 28-May-2013 13:08



should do as well. Some Controls rely on WM_PAINT messages from the Windows message loop.PAUSE 0.01 or PROCESS EVENTS allow processing these messages.

Posted by Darren Parr on 28-May-2013 13:15


PROCESS EVENTS doesnt work at all. Its strange that the PAUSE does. Ive worked with activex controls for years and I could always rely on events not firing part way through my code execution. With .net this is not the case and an event could fire at any time and stop my code in its tracks. What fun...


Posted by jquerijero on 07-Aug-2013 12:35

What about calling your resize logic inside the Resize event of the panel?

This thread is closed