3 Replies - 3444 Views - Last Post: 07 March 2012 - 02:38 PM

#1 newbielol  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 02-March 12

Windows Form - Change program but keep same window?

Posted 06 March 2012 - 05:08 PM

c++ visual studio 2010-----

Alright, so I'm working on making a game. Only learning console app stuff in my class currently but I'm trying to make this in Windows Forms, like an actual game.

So I open the program at my login screen, then you click login (can't figure out how to make pressing the enter key do the same thing) and it opens the next window.

currently using this to switch to the next window

 private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
				 introvideo ^ form = gcnew introvideo;
						 form->ShowDialog(); 


It works fine.. however, I don't want to have 5000 windows open while playing this game. I already hide them from the taskbar but I don't want more than 1 window open at a time.

Is there a way to make the program change from login screen to another but keep it all in the same window?

Like when you open World of Warcraft, you login > then character selection > then it loads the actual game world. It does all of that without having to open/change windows.

Can anyone help explain this? Or link a tutorial on this type of thing?

thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Windows Form - Change program but keep same window?

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5439
  • View blog
  • Posts: 11,669
  • Joined: 02-June 10

Re: Windows Form - Change program but keep same window?

Posted 07 March 2012 - 10:32 AM

Quote

(can't figure out how to make pressing the enter key do the same thing)


Monitor the .KeyPressed event of the textbox.
If the KeyPress is equal to [Enter] then call the same method your "LogIn" button calls when it is clicked on.

Quote

I don't want more than 1 window open at a time.

Is there a way to make the program change from login screen to another but keep it all in the same window?


Sure, change the controls inside your Form's .Controls collection.

.Controls is the list of all the controls on the form. Just change them.

Make as many UserControls as you like. Then swap them out on your form.


myForm.Controls.Clear();
myForm.Controls.Add(myLoginControl);




Some of the tutorials below are for C# not C, C++, VB.NET [...]. But the conceptual stuff of classes, object oriented design, events etc. are not language specific and should give you enough guidance in theory of program development for you to be able to look-up specific code example in your chosen coding language.

Newbie/Rookie said:

I have a little programming experience but I need to write ...


You need to start there. I can't say "I have little experience in speaking Russian, but I have been assigned to write a mystery novel in Russian. Can you help me?"

We can help you by saying "First learn basic programming and the language of C#. Then take on assignments." Could someone here write this program for you? Sure. Could someone here map out all the processes you need to follow and do the Software Design part of this in the slim hope you could code it from there? Sure. But we don't volunteer to do the job that you're either getting paid for, or getting a grade for. You may want to read this.

For now, just work on the lessons. Do a self-teaching book from cover to cover. Then consider writing a program.

Don't try to create a useful working program to fit a need of yours (or a for-pay contract) as your introduction to coding project. When you are learning to code you don't know enough to code a program, let alone know how to engineer the architecture of a program. It would be like saying "I don't know how to read sheet music, or play an instrument. I think I'll write a 3 act opera as my first learning experience."

I don't say this to be mean. We've seen lots of new coders take this approach and we know it doesn't work. Trying to design your own programs before you understand the basics of the code language you've chosen just leads to problems, frustrations, and 'swiss-cheese' education (lots of holes).


Resources, references and suggestions for new programmers. - Updated Jan 2012
Spoiler

Was This Post Helpful? 1
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6039
  • View blog
  • Posts: 23,436
  • Joined: 23-August 08

Re: Windows Form - Change program but keep same window?

Posted 07 March 2012 - 10:35 AM

Moved to CLI C++
Was This Post Helpful? 0
  • +
  • -

#4 newbielol  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 02-March 12

Re: Windows Form - Change program but keep same window?

Posted 07 March 2012 - 02:38 PM

thanks a ton man! i appreciate it
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1