On Jan 24, 2005, at 8:57 AM, Scott Rock wrote:

I'm new to Palm development. I currently am using one form that has multiple buttons. When the app starts, button1 is shown. When button1 is clicked, it shows button2 and hides button1.

How can I make my app remember that button1 has already been pressed so when a user switches to another app and then back to mine, button2 is still shown?

Any help would be greatly appreciated.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/


As others have mentioned, the standard way to do this is using preferences.

You create a structure that encapsulates the state of your program, and during application startup (AppStart), you read the state back:

PrefGetAppPreferences(appFileCreator, appPrefID, &thePrefs, &prefsSize, true);

When your program is stopping, you save the preferences(AppStop):

        PrefSetAppPreferences (appFileCreator, appPrefID, appVersionNum,
                        &thePrefs, sizeof (thePrefs), false);

Be sure to code for the special cases of no prefs, which will occur the first time you install, in which case you have to set your program state, and changed preference format, such as when you add or change features. If you don't, you may end up with an obscure bug like I did, where the program runs fine on the simulator and emulator, but crashes on the device, where you had an old version installed before!

I was unable to get the version number to work properly, so I ended up adding a version string to the beginning of the preferences, and I check to see if the version is correct.

Hope that this helps.

DTL


-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/

Reply via email to