Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Well I want FormA to appear as the default form, but I want a control, like a checkbox to be checked to change the default loaded form to FormB, or to at least automatically hide the form the next time the program is run if the checkbox is checked. I imagine this would involve a setting, if so, what Type and Value would I use?
Posted
Comments
Sergey Alexandrovich Kryukov 1-Oct-13 0:10am    
What is "the default form"? Do you mean "main form", or something else?
—SA
Tyler Wellman 1-Oct-13 0:15am    
Not exactly, see the project is a game launcher, and it first opens a webpage form, but I want users to have the option to disable the form from appearing to go directly to the main form. as a convenience.
Sergey Alexandrovich Kryukov 1-Oct-13 0:23am    
So, this is not a System.Windows.Forms.Form, but a Web form, right? Or both? But then those forms are not alternatives to each other... What is the "default form"? A simple question, please answer. Don't be afraid to provide way more detail, otherwise nothing is clear...
—SA
Tyler Wellman 1-Oct-13 0:55am    
they are both regular windows forms, but the first "default" one contains a web browser which displays the games voting page. Some users don't like that appearing before they log into the game and I want to provide a way to basically disable it from start-up and just display the main form which is the actual game launcher. In example here is the start-up form http://i.imgur.com/tuBrDB5.png

And then here is the game launcher. http://i.imgur.com/fge7cMc.png

I want to try to make it so that when you check the "Hide this from start-up" checkbox on the first form (The first image, bottom left) next time the application is run, it does not display the voting form, but the launcher instead.

(sorry if this double posted, my reply didnt show up on my screen)
Tyler Wellman 1-Oct-13 0:38am    
they are both regular windows forms, but the first "default" one contains a web browser which displays the games voting page. Some users don't like that appearing before they log into the game and I want to provide a way to basically disable it from start-up and just display the main form which is the actual game launcher. In example here is the start-up form http://i.imgur.com/tuBrDB5.png

And then here is the game launcher. http://i.imgur.com/fge7cMc.png

I want to try to make it so that when you check the "Hide this from start-up" checkbox on the first form (The first image, bottom left) next time the application is run, it does not display the voting form, but the launcher instead.

Hiding won't help you much, will generate other problems. You should understand that you practically always need a main windows. Its behavior is somewhat different from others. For example, if you close main window, the whole application closes. There are other good reasons to keep you main form operational at all times. And you cannot really change the main form. Which form is main? The one used in the call to Application.Run.

You have about two options. First, consider this:
C#
void Main(string[] args) {

    bool skipWebbrowseWindow = // find it, for example, from args

    //...

    if (skipWebbrowseWindow) 
        Application.Run(new MyGameForm())
    else
        Application.Run(new MyIntroForm()); // and it will create other windows later
}
(Oh, sorry the C# sample, you hope you can easily translate it into VB.NET. When you look for help in .NET, you need to know at least some C#…)

I think better option is this: work only with one form at all times. (However, I don't count if you have few modal forms/dialogs, they are just fine.) I think this option is much, much better. What you planned to be forms should be controls on you only form, typically panels, but they can be also tab pages or something else. And the look of your main form will depend on which of those panels are on top and visible. You can arrange two or more in parallel, both visible, of you can show only one at a time. Here hiding will serve you well. And the navigation between those wonna-be-forms is all yours, you won't depend on weird Z-order of the Windows desktop. All application will be activated at once (with forms, you would need to use Owner properties of all non-mail forms, forgetting this feature by many make application Z-order really ugly, please try). There are more reasons to design it all in just one form. Especially for gaming, where people don't have time to mess up with the desktop. Honestly, choose this approach.

—SA
 
Share this answer
 
v2
Comments
Tyler Wellman 1-Oct-13 8:53am    
I have spent over a week writing and touching up this code, I have no intentions of rewriting it, I get it that using a single form may be more efficient but what you're suggesting will require an entirely new design and to move around a lot of my code, I don't have time for that, I just need the user to be able to disable the first form so the main form will appear first on the next run. I don't have the time or funding to redo this project.
Sergey Alexandrovich Kryukov 1-Oct-13 9:09am    
And what are you after that? If you don't want to redo the project, asking questions is useless. Why do you think somebody has to care about your time management?

There is no such things as miracle. "I just need" approach does not work.
Did I answer your question? Yes, I did. Now decide what to do with it. Pick a first approach, it won't require any considerable change...

—SA
Tyler Wellman 1-Oct-13 9:17am    
I posted my solution below, that was all I needed, turned out to be really simple, I do appreciate the help though, the point in asking was because I couldn't get it to work when I tried doing what I did below, but with the voting form. which did not work for some reason. Thanks a lot for the help.
Sergey Alexandrovich Kryukov 1-Oct-13 9:23am    
Very good. Thank you for the note.
—SA
I came up with my own solution that works just fine. I created a boolean setting named 'hidevote' and worked with this code under the launcher/main forms Load sub

VB
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

 If My.Settings.hidevote = True Then
       CheckBox2.Checked = True
       VOTE4US.Hide()
   ElseIf My.Settings.hidevote = False Then
       VOTE4US.Show()
   End If
End Sub



Then I wrote this under the closing/closed sub.

VB
Private Sub Main_FormClosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed
    If CheckBox2.Checked = True Then
        My.Settings.hidevote = True
    End If
End Sub

Private Sub Main_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
    If CheckBox2.Checked = True Then
        My.Settings.hidevote = True
    End If

End Sub
 
Share this answer
 
v4
You Need to Focus :

1- we will create a text file with the value of the form you want to save as Default
Withing the Checkbox Event of your Choice

VB
File.writealltext("MySetting", "FormA")
 or
File.writealltext("MySetting", "FormB")


2- Then We Will Create a Logic Function in the Main Form (Page_Load) Event

VB
Dim Setting as string = file.readalltext("MySetting")
If Setting="FormA" Then 
FormA.Hide 
FormB.Show
End if


That Will Check if the FormA is the Default form or Not , If Not it will Hide it and Show the FormB , any other case will Display The FormA as Usual so No Need for Extra If Conditional To Check

That's a Quickie and i Hope it Helped :)
 
Share this answer
 
Comments
Tyler Wellman 1-Oct-13 0:24am    
your solution has me a bit confused, I was hoping to have this done without a txt file if at all possible, with like an application settings entry. If that's possible. otherwise could you elaborate on your solution for me please? explain it in a bit more detail I mean.
Send a Screenshot of your app and i will Be able to Help Better

by understanding the Behavior you want the user to be able to do
 
Share this answer
 
Comments
Tyler Wellman 1-Oct-13 0:40am    
http://i.imgur.com/tuBrDB5.png

http://i.imgur.com/fge7cMc.png

The first form being the form I want users to be able to hide by choice. Preferably not by a setting saved as a .txt, but will do if that is the only way.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900