Behaviour of GetWindow

I have a panel which contains a number of different controls such as popups, buttons, checkboxes and SetVariable options. Some of these controls will cause the panel to be re-created with a different size and a different number of controls but the top/left coordinate of the panel should always be at its last location.

I tried to use GetWindow PanelName wsizeOuter to get the V_left, V_top coordinates - this works on a Mac, but I get an offset of the panel from its previous position on Windows.

From the documentation it's not clear to me why this is and what would I need to do to get the position of the panel right on Windows?

Cheers
Christian
GetWindow wsizeOuter returns values in points, but control panels are positioned in pixels. On a Macintosh, those are the same. Use the function ScreenResolution to compute the correction factor:

Variable top = V_top*ScreenResolution/72
Variable left = V_left*ScreenResolution/72

Note that the /W positioning for a graph works in points.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
ChrLie wrote:
I have a panel which contains a number of different controls ... but the top/left coordinate of the panel should always be at its last location.....

From the documentation it's not clear to me why this is and what would I need to do to get the position of the panel right on Windows?


A Code Snippet that shows a "platform-agnostic" example of how to extend a panel in one direction (down) can be found here. It might help as a start for building what you want.

Also, you can draw and add controls outside of the normal panel size. They will be "invisible" until the panel is resized to encompass them. A good practice in such cases is also to set the disable state of any controls outside the panel size to either 1 or 2 until you resize to make them "visible" again (in which case, you would set their disable state to 0).

Finally, doing the following in your code is useful to help keep users from making changes:

// AT TOP OF PROCECURE FILE
// uncomment next line to edit panel size and controls
//#define TEST

// WITHIN THE PANEL CREATION FUNCTION
    NewPanel/N=MYNEWPANEL ...
#ifndef TEST
    ModifyPanel/W=MYNEWPANEL noEdit=1, fixedSize=1
#endif


HTH

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
John, thanks! That's it!

JJ,
Hiding controls by plotting them outside the panel doesn't work in my case, because I don't know in the beginning with how many controls I will end up. The controls are part of a 'filter set' with which data from chemical analyses are being processed. For some data I may need 3 filter sets, for others maybe 10.
However, the snippet looks indeed very useful! Thanks!

Christian
ChrLie wrote:
John, thanks! That's it!

JJ,
Hiding controls by plotting them outside the panel doesn't work in my case, because I don't know in the beginning with how many controls I will end up. The controls are part of a 'filter set' with which data from chemical analyses are being processed. For some data I may need 3 filter sets, for others maybe 10.
However, the snippet looks indeed very useful! Thanks!


For things like that, I often use a ListBox control. You can put the ListBox into a mode that has editable cells, so if you need to change the values it can be done. The ListBox easily accommodates a variable number of values, and scrolls when you have a large number of rows.

To see the possibilities, you can look at the Listbox Demo experiment, in File->Example Experiments->Feature Demos 2->ListBox Demo.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
johnweeks wrote:
... You can put the ListBox into a mode that has editable cells, so if you need to change the values it can be done. The ListBox easily ... scrolls when you have a large number of rows.


ok, I haven't worked with or didn't know about ListBox yet. This might be an option if the number of controls get exceedingly high, which I don't see coming at the moment, but still, good to know!
C