0

This answer explain how to make a splash screen which I did already : How to build splash screen in windows forms application?

But I want something that, on first time that the user runs the program, he will get a window with an explantion inside like command keys, what to do, how to use the program and then click OK.

When he then runs the program again, he does not get the help window, and it just goes straight into the the application.

I'm not quite sure what I need to do here, could anyone help me?

Community
  • 1
  • 1
joneK
  • 241
  • 1
  • 4
  • 13

2 Answers2

1

Leave something persistent on the computer when the program is run the first time. A file or registry entry are the most obvious options.

For a registry key, in pseudo code, on startup do this:

If (registry key not present)
{
   show instruction dialog
   add registry key
}

For a file:

If (file '%APPDATA%\myApp\file' does not exist)
{
   Show instruction dialog
   Create file '%APPDATA%\myApp\file'
}

Implementation, registry key:

protected override void OnShown(EventArgs e)
{
   var key = Registry.CurrentUser.CreateSubKey(@"Software\TestCompany\TestApp\");
   if (key.GetValue("FirstRun") == null)
   {
      ShowDialog(new HelpDialogForm());
      key.SetValue("FirstRun", "false");
   }         
}

As usual, add necessary error handling to this. The above method overrides OnShown, i.e. it is assumed it is declared in your main/startup Form.

Anders Forsgren
  • 10,827
  • 4
  • 40
  • 77
  • Downvoter care to comment? I'm assuming the actual implementation is easy enough to find by a simple web search. The answer would be cluttered by having the actual implementation I think. – Anders Forsgren Jun 07 '13 at 21:32
  • I assume the -1 is because there needs to be a bit more instruction. It is not entirely clear how the registry is helpful to do this. – IAbstract Jun 07 '13 at 21:32
  • The answer would be **much improved** if the actual implementation were given. :) – IAbstract Jun 07 '13 at 21:33
  • If a simple web serch is enough, then no need this pseude code. See the comment of @newStackExchangeInstance – I4V Jun 07 '13 at 21:33
  • `Downvoter care to comment?`, really can't you guess why? – EZI Jun 07 '13 at 21:42
  • Really, no. The question isn't very clear but I was assuming the asker wanted to know a) how to persist something and b) how to use this in trivial logic. Yes, I actually think the "if" statement was a large part of the problem here... – Anders Forsgren Jun 07 '13 at 21:48
  • @AndersForsgren and you don't answer that part. – EZI Jun 07 '13 at 21:50
  • Also: I don't think the poster is helped by code they can copy and paste into their code, like was obviously done with the splash screen code. I wanted to point in the right direction mentioning "show dialog" and "registry". – Anders Forsgren Jun 07 '13 at 21:51
  • @QtX I meant simply the control flow, not the impl of the actual if statement. But OK I'll (reluctantly) add the bits. I'm just not very keen on adding copy-pasteable code. Asker won't be helped by this... – Anders Forsgren Jun 07 '13 at 21:57
0

Option 1: You might want to use a check box option "Do not show this window again" at the bottom of your help window. You will have to save this value as a setting in the database or as an environment variable, which will be used to decide whether to show or not the next time the user logs in.

Option 2: You will have to store something like "IsFirstEntryToApp" which will be a default true and set to false immediately after the user logs into the app. This will be your hint to show the help window.

Most applications go with option 1.

EDIT: You can also save the state as Enviroment Variable for simple scenarios See How do I get and set Environment variables in C#?

            var alreadyLoggedInAtleastOnce = System.Environment.GetEnvironmentVariable("HasUserLoggedInIntoMyAppAtleastOnce",EnvironmentVariableTarget.User);

        if (alreadyLoggedInAtleastOnce != "True")
        {
            //This is the first login. Set the variable so that it is available the next time user logs in
            System.Environment.SetEnvironmentVariable("HasUserLoggedInIntoMyAppAtleastOnce", "True", EnvironmentVariableTarget.User);

            MessageBox.Show("This is your help window");
        }
Community
  • 1
  • 1
SKG
  • 1,432
  • 2
  • 13
  • 23