Windows Develop Bookmark and Share   
 index > Windows Forms General > How do I display two Windows Forms Simultaneously (perfer the CLR CLI version of Code) (C++)
 

How do I display two Windows Forms Simultaneously (perfer the CLR CLI version of Code) (C++)

Basically brand new to Visual C++ How do I display two Windows Forms Simultaneously perfer the CLR CLI version of Code
Im Also interested in the MFC version as well
I can only get one window to load at a time
and I am unable to load more than two windows at all. Why is this?

// twoforms.cpp : main project file.

#include

"stdafx.h"
#include "Form1.h"
#include "Form2.h"
#include "Form3.h"

using
namespace twoforms;
[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());
Application::OpenForms(
gcnew Form2());
Application::OpenForms(
gcnew Form3());
return 0;
}

pablo36  Wednesday, September 30, 2009 7:55 PM
I can't give code because I don't know C++ well, but what you do is either:

A. Run Form2 and Form3 from inside Form1
B. Run Form1, wait till it closes then show Form2 with another Application.Run

The problem you're running into is that Application.Run is a blocking call, it stops there while Form1 is running and doesn't continue until it closes.
ScottyDoesKnow  Wednesday, September 30, 2009 8:00 PM
Your C++/CLI code is about 10,000 miles away from being close to something that would work. Visit your local library and check out a book about Windows Forms, this kind of code in just not guessable.

#pragma once
#include "Form2.h"
#include "Form3.h"
...
protected:
virtual void OnLoad(EventArgs^ e) override {
Form2^ f2 = gcnew Form2;
f2->Show();
Form3^ f3 = gcnew Form3;
f3->Show();
}


Hans Passant.
nobugz  Wednesday, September 30, 2009 8:42 PM
I can't give code because I don't know C++ well, but what you do is either:

A. Run Form2 and Form3 from inside Form1
B. Run Form1, wait till it closes then show Form2 with another Application.Run

The problem you're running into is that Application.Run is a blocking call, it stops there while Form1 is running and doesn't continue until it closes.
ScottyDoesKnow  Wednesday, September 30, 2009 8:00 PM
Your C++/CLI code is about 10,000 miles away from being close to something that would work. Visit your local library and check out a book about Windows Forms, this kind of code in just not guessable.

#pragma once
#include "Form2.h"
#include "Form3.h"
...
protected:
virtual void OnLoad(EventArgs^ e) override {
Form2^ f2 = gcnew Form2;
f2->Show();
Form3^ f3 = gcnew Form3;
f3->Show();
}


Hans Passant.
nobugz  Wednesday, September 30, 2009 8:42 PM

You can use google to search for other answers

Custom Search

More Threads

• Font families
• How to upgrade settings if app uses different strong name every revision.
• How does AutoScrolling work?
• Is IIS locally installed necessary?
• Change property from another form
• How to set ListViewItem coordinate in detail view
• Changing Statusbar from MDI Child
• ResourceManager and Translations
• How to work with crystalreports in dotnet2.0?
• How to read Window Adders Book (WAP) file of Outlook Express in C#.Net ?