LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Save and Restore Screen Layouts

Solved!
Go to solution

Hi,

 

Does anyone know of a straightforward way to save to file and read from file screen layouts which are not UIR files?  FileToArray and ArrayToFile do not suffice as they store arrays of only simple types, not structs.

 

Thanks,

Gayle

0 Kudos
Message 1 of 5
(3,711 Views)
Solution
Accepted by topic author GayleCRoth

I do not exactly understand you reference between "screen layouts" and "array of structures", but anyway, if you have an array of structures you can save it to disk by using this code.

 

 

// Structure definition

typedef struct {

   // Structure fields definition

} myStructure;

// Dynamic structure allocation

 s = calloc (numOfElements, sizeof (myStructure)));

// Struct saving

{

 char msg[512];
 FILE *stH = NULL;

 fH = fopen ("myfile.dat", "rb+");
 if (errno) goto Error;

 fwrite ((char *)&s, sizeof(myStructure), numOfElements, fH);
 if (errno) goto Error;

Error:

 if (errno) {
  strcpy (msg, "General I/O error found.");
 }
 if (fH) fclose (fH);
}



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 2 of 5
(3,706 Views)

Thank you.  Your solution will work well.  I'm using an array of structures to store information about the widgets the user placed on the screen, such as the location, foreground and background colors, etc.

 

- Gayle

0 Kudos
Message 3 of 5
(3,697 Views)

Hi Gayle,

 

Have you seen the SavePanelState / RecallPanelState function pair?

 

These may be the functions you are looking for.

 

Regards,

S. Eren BALCI
IMESTEK
0 Kudos
Message 4 of 5
(3,653 Views)

I have, and I've tried them.  They don't place any of the controls on the screen that I had created.  I contacted NI about this, sent them my code with SavePanelState and RecallPanelState, and they said that these functions save and restore the values in the controls but not their placement on the screen, font size, etc.  If these functions do save and restore the layouts of the widgets on the screen, etc., as well, please let me know.  Thanks.

 

- Gayle

0 Kudos
Message 5 of 5
(3,641 Views)