<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237057</link>
    <title>MATLAB Central Newsreader - Passing handles between GUIs via a loaded file</title>
    <description>Feed for thread: Passing handles between GUIs via a loaded file</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Mon, 06 Oct 2008 06:46:01 -0400</pubDate>
      <title>Passing handles between GUIs via a loaded file</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237057#603858</link>
      <author>William </author>
      <description>Hi,&lt;br&gt;
&lt;br&gt;
I have a GUI with pulldown menus and editable text boxes.  I am trying  to save the configuration of all the editable text boxes and pulldown menus to a file that can be loaded the next time the user wants to use the GUI.  &lt;br&gt;
&lt;br&gt;
I can run the GUI properly if I start from scratch(All of the handles operate normally).  The problem is, when I rerun the GUI and load in the configuration file, I get an 'Invalid handle object' error.  Does anyone know a way to do this?&lt;br&gt;
&lt;br&gt;
Currently, I am saving the handles structure from the previously open GUI into the configuration file.  I then reopen the GUI and load in the saved configuration file.  When the file is loaded, I am copying over the handles structure from the previously opened GUI.  I noticed that some of the numbers change slightly between the two handles (i.e. checkbox3 goes from 320.0040 to 320.0039).  Could this be causing the problem?  &lt;br&gt;
&lt;br&gt;
Please let me know if you know a way to save the configuration and data of a GUI into a config file that can be loaded back into the GUI so the user can pick up where he/she left off. &lt;br&gt;
&lt;br&gt;
Thanks!!&lt;br&gt;
&lt;br&gt;
Bill King</description>
    </item>
    <item>
      <pubDate>Mon, 06 Oct 2008 13:33:59 -0400</pubDate>
      <title>Re: Passing handles between GUIs via a loaded file</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237057#603896</link>
      <author>Steven Lord</author>
      <description>&lt;br&gt;
&quot;William &quot; &amp;lt;w_king10@yahoo.com&amp;gt; wrote in message &lt;br&gt;
news:gccc79$d4l$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I have a GUI with pulldown menus and editable text boxes.  I am trying  to &lt;br&gt;
&amp;gt; save the configuration of all the editable text boxes and pulldown menus &lt;br&gt;
&amp;gt; to a file that can be loaded the next time the user wants to use the GUI.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I can run the GUI properly if I start from scratch(All of the handles &lt;br&gt;
&amp;gt; operate normally).  The problem is, when I rerun the GUI and load in the &lt;br&gt;
&amp;gt; configuration file, I get an 'Invalid handle object' error.  Does anyone &lt;br&gt;
&amp;gt; know a way to do this?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Currently, I am saving the handles structure from the previously open GUI &lt;br&gt;
&amp;gt; into the configuration file.  I then reopen the GUI and load in the saved &lt;br&gt;
&amp;gt; configuration file.  When the file is loaded, I am copying over the &lt;br&gt;
&amp;gt; handles structure from the previously opened GUI.  I noticed that some of &lt;br&gt;
&amp;gt; the numbers change slightly between the two handles (i.e. checkbox3 goes &lt;br&gt;
&amp;gt; from 320.0040 to 320.0039).  Could this be causing the problem?&lt;br&gt;
&lt;br&gt;
I don't believe we state anywhere in the documentation that when a Handle &lt;br&gt;
Graphics object is saved to a FIG-file and reloaded its handle will remain &lt;br&gt;
the same.  Therefore I don't think you should make that assumption. &lt;br&gt;
Instead, I'd key off the Tag property of the objects -- save the appropriate &lt;br&gt;
data in a struct, then store those structs as fields of a main struct, with &lt;br&gt;
the Tag of the object being the fieldname in the main struct.&lt;br&gt;
&lt;br&gt;
For instance, if the main struct is saveddata, then saveddata.Pushbutton1 &lt;br&gt;
would be a struct containing the saved data for the object whose Tag is &lt;br&gt;
Pushbutton1.&lt;br&gt;
&lt;br&gt;
To restore the state, take advantage of the fact that this two-input form of &lt;br&gt;
SET works:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SET(H,a) where a is a structure whose field names are object&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;property names, sets the properties named in each field name&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;with the values contained in the structure.&lt;br&gt;
&lt;br&gt;
set(handles.Pushbutton1, saveddata.Pushbutton1)&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Steve Lord&lt;br&gt;
slord@mathworks.com </description>
    </item>
    <item>
      <pubDate>Tue, 07 Oct 2008 03:32:01 -0400</pubDate>
      <title>Re: Passing handles between GUIs via a loaded file</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237057#604025</link>
      <author>William </author>
      <description>Hi Steve,&lt;br&gt;
&lt;br&gt;
Thanks for the quick reply!  Am I correct in thinking that the way to save the entire handles structure of a pop-up menu is with:&lt;br&gt;
&lt;br&gt;
myStruct.popupmenu1 = get(handles.popupmenu1);&lt;br&gt;
&lt;br&gt;
I have now saved each handles structure for all of the components of my GUI.  The problem I am seeing now, is that when I use the command:&lt;br&gt;
&lt;br&gt;
set(handles.popupmenu1,myStruct.popupmenu1);&lt;br&gt;
&lt;br&gt;
I get the following error:&lt;br&gt;
&lt;br&gt;
Error using ==&amp;gt; set&lt;br&gt;
Attempt to modify read-only uicontrol property: 'BeingDeleted'.&lt;br&gt;
&lt;br&gt;
Is there something I need to disable to be able to copy the entire handles structure for each GUI component?&lt;br&gt;
&lt;br&gt;
I also want to add that during the opening function of my main GUI, I copy the entire handles structure into a new structure called hFig_main (hFig_main = handles;).  I have two other GUIs which work along this one and they use the handles structures hFig_plot and hFig_output.  In my main GUI, the code above is actually:&lt;br&gt;
&lt;br&gt;
myStruct.popupmenu1 = get(hFig_main.popupmenu1); and&lt;br&gt;
set(hFig_main.popupmenu1,myStruct.popupmenu1);&lt;br&gt;
&lt;br&gt;
Will this cause additional issues with copying the handles from each component.  My initial assumption is that it shouldn't cause issues.  I have been wrong many times before, however!&lt;br&gt;
&lt;br&gt;
Thanks again for your help!!&lt;br&gt;
&lt;br&gt;
Respectfully,&lt;br&gt;
Bill King</description>
    </item>
  </channel>
</rss>

