Hey,
I started making a GUI tic-tac-toe game using windows forms in Visual Studios Express Edition 2008. I have made the board, it acts as expected, and added two new forms to the app. I have a method to check for wins but am running into trouble opening the new forms (X Wins! and O Wins!) once I find a win. How can I open the new form (inside the solution, owin.h or xwin.h) and quit the original one, restart (if they say play again), or quit if they say quit? In the main() method, it opens Form1 by doing this: Application::Run(gcnew Form1()); I've been around msdn's site and so far don't know what I'm doing. Thanks for taking a look,
Look I'm replying to myself, lol. I've been looking and working on it for awhile and think I've narrowed it down. I've changed the two dialog boxes to have 'true' set on the property IsMdiContainer... It's giving me a wierd error now, this is the syntax:
Hi, I'm using VS 2005, but it should be the same for 2008.
Not sure of why you are getting your error (I'd need to see more code realy), but the way i am showing multiple forms is to create and show an instance of the form class in the method that is designed to trigger them.
So in my case where I want a simple editor form to pop up when a button is clicked, and I have
1 2 3 4 5 6 7 8 9 10
void MainForm::EditorButtonClick(System::Object^ sender, System::EventArgs^ a)
{
//OptionsEditorForm is the class of the Editor Form,
//options is a variable declared in MainForm which holds the options I want to edit
optionsEditor = gcnew OptionsEditorForm(options);
//Instance Created
optionsEditor->ShowDialog();
//ShowDialog() so will be modal and only return when closed
//Scope is just this handler, so gc will free up when we exit
}
I'd say is one of the following:
You didn't put a ; at the end of a class.
Form1 is not declared.
Your compiler doesn't like you.
Believe it or not, the third option is more likely than you think. I've sometimes had to compile the same (valid) code several time because the compiler kept hanging in the middle, for some still unknown reason.
Ok, so here's what I want to do: Write a form that opens on a win/lose/tie and prompts them to: play agan or quit. If they hit enter, it closes the main form and reopens, esc quits. I believe I hav the logic down for checking for wins/loses/ties, so how do I maniplate the forms to do what I want? here is the code for the main file, the main form was too big:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// tictactoe.cpp : main project file.
#include "stdafx.h"
#include "Form1.h"
usingnamespace tictactoe;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew Form1());
return 0;
}
And here is a button (one to play the game) in the main for: