Remembering form used

closed account (Gy7oizwU)
Hi All

I have a small app that i created with windows forms. When i run the exe, a form opens. From there, i have the option to open one of two more forms. Now it gets a bit irritating to keep selecting which form you want to use each time i open the app. I want to implement a "Remember Selection" checkbox. So on the first form, i want to select is remembered and the next time you start the app, the form you had opened previously is then displayed.

IE - Parent form opens on execution of the exe. You then open the desired child forn. When i close the app, i want it to remember which child form was used and open that child form the next time i run the app.

What is the best way to do this?

Thanks
You may want to consider using the registry for this. You'd store your app state in HKCU:SOFTWARE\<your name>\<app name>.
closed account (Gy7oizwU)
Thanks. Any idea where i can get a tutorial or walkthrough?
You may want to Google for a tutorial or walkthrough?

Use RegCreateKeyEx to create/open your registry subkey.
Use RegQueryValueEx to read a value.
Use RegSetValueEx to write a value.
Use RegCloseKey to close the handle when you're done.
closed account (Gy7oizwU)
Ok, so i know how to write to the registry after an event and read from the registry, but i have no idea how to implement this in my app. Not sure what data to save to remember which form to open?
A string with the form name would be the most obvious choice. Registry entries are key,value pairs - not sure how the details of the Windows Forms API works for them, but if you can save to and read, you should be able to read a specific key at startup and then select the correct window to show from there.
Topic archived. No new replies allowed.