LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

LabWindows program remembering windows postion/maximize size between runs?

Is there some way to have a LabWindows GUI program remember the window position/size/etc. between runs? I was learning a little Visual Studio C# and it has a way to remember certain attributes (somewhere) that are retained between runs. Does LW have something like this?

0 Kudos
Message 1 of 7
(2,657 Views)

CVI does not have an automatic feature for this, but it offers you the tools to obtain it by your own.

 

The central point is to save windows position/size when it moves or sizes; this is what you need in the panel callback:

switch (event) {
	case EVENT_PANEL_SIZE:
		GetPanelAttribute (panel, ATTR_WIDTH, &Width);
		GetPanelAttribute (panel, ATTR_HEIGHT, &Height);
		SaveWindowSizePos ();
		break;
	case EVENT_PANEL_MOVE:
		GetPanelAttribute (panel, ATTR_TOP,  &Top);
		GetPanelAttribute (panel, ATTR_LEFT, &Left);
		SaveWindowSizePos ();
		break;
	}

 

SaveWindowSizePos () is a function to save attributes to disk so that you can restore it at the next execution.

 

When you need to display a panel you can simply do this:

panelHandle = LoadPanel (0, "MyUirFile.uir", panelID);
SetPanelPos (panelHandle, Top, Left);
SetPanelAttribute (panelHandle, ATTR_HEIGHT, Height);
SetPanelAttribute (panelHandle, ATTR_WIDTH,  Width);

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 7
(2,631 Views)

I forgot to say that  ATTR_WINDOW_ZOOM is the attribute to get if the window is maximized.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 7
(2,626 Views)

I understand. Is there any type of attribute load/save functionality in LabWindows? I suppose I could jam it in the .ini file I am using from the toolbox, if nothing else.

 

Edit: I suppose all I need to do is save the state on program shutdown, and then load and use it on startup. My career has mostly been working on embedded devices that do not have file systems so I am hoping to find a "recommended standard" for saving this type of data.

0 Kudos
Message 4 of 7
(2,596 Views)

One thing to consider: Multiple monitors that may or may not be present, or extended in a different arrangement. You could end up with it totally off-screen, I believe.

 

(If that happens, the kludgey workaround is to give it focus via the task bar, then press <Alt>Space and then the M key (for move), followed by the arrow keys. Try it on a visible window to see how it works.)

Message 5 of 7
(2,581 Views)

I have a number of programs I use that do that (I'm lookin' at you, CCS compiler). I've learned about the Windows hot-key ALT-SPACE, M to move them back on to the screen.

 

I would expect it would be easy for a program to detect "I'm not on a screen that is hooked up" and move, but ... apparently that's not easy to do 😉

 

0 Kudos
Message 6 of 7
(2,577 Views)

@AllenInIowa  ha scritto:

I understand. Is there any type of attribute load/save functionality in LabWindows? I suppose I could jam it in the .ini file I am using from the toolbox, if nothing else.

 

Edit: I suppose all I need to do is save the state on program shutdown, and then load and use it on startup. My career has mostly been working on embedded devices that do not have file systems so I am hoping to find a "recommended standard" for saving this type of data.


The IniFile tool is handy and robust and it offers the possibility to revise/edit data even outside of your app if needed. Another possibility is the use of CVIxml instrument to save in .xml format.

 

As per when to get window position/size, I resolved to do that when the window is sized/moved in the case the window is closed and opened again during program life.

When developing applications for machines on a production line with a single monitor with limited real estate, once the user finds a suitable setup with program windows he's happy if them are restored with the same aspect every time he needs them.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 7 of 7
(2,545 Views)