12-11-2002 05:06 AM
12-12-2002 10:20 AM
12-12-2002 01:12 PM
12-13-2002 10:02 AM
02-26-2016 09:46 AM
Sorry for replying to a very old thread. But I stumbled upon a novel way of handling loading and unloading of many non-child panels for an application that must work on a multi-monitor installation.
I have an application whose panels must all load on one or the other monitor. I've made the monitor "home" selectable in-applicaiton. However, ATTR_DEFAULT_MONITOR changes only work before LoadPanel. Hence, the need to execute DiscardPanel and then LoadPanel for each global panel handle. Yuck!
I love the array idea. So for my implementation, I created a define for MAX_PANELS equal to 50 and an array of this size.
Next, I utilze the UIR header macros for each panel, knowing that a 0 is by definition not a valid panel handle number. Then, I'm able to simply use for loops to both load and discard panels quickly:
// fist discard all the panel handles for (int i=0; i<MAX_PANELS; i++) { DiscardPanel(panels[i]); // reinit array too memset(panels, 0, MAX_PANELS); } // re-init the default monitor SetSystemAttribute(ATTR_DEFAULT_MONITOR,systemConfig.monitor); // now reinitialize all panels for (int i=0; i<MAX_PANELS; i++) uiChk(panels[i] = LoadPanel(0, "Panels.uir", i));
02-26-2016 10:36 AM - edited 02-26-2016 10:41 AM
Just a little note for what is probably just a typo: you must put memset () out of the loop, otherwise all panel past the first will not be discarded
Additionally, you could have a global int array which you can fill in at program start with the pane IDs of the only panels you want to always load and iterate on the elements of that array to load/unload them. This way you can handle panels that do not need to be always loaded in mmory but still are present in the .UIR file.
02-26-2016 11:01 AM - edited 02-26-2016 11:01 AM
Oops, yes big mistake there.
And yes, good suggestion on the panels that are drawing in the UIR but are not loaded/needed. Those would present a situation where a simple loop would crash.