[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Launching a form from a form

Posted on 2011-03-08
8
Medium Priority
?
465 Views
Last Modified: 2013-11-20
I have an application developed under Microsoft Visual Studio .NET 2003 (Visual C++) with two forms, Form1 and Form2.

When I click a button on Form1 (Button2) I want to hide Form1 and show Form2. But how ?
(Yes, I am a newbie on this topic.. :-( ).


The code generated by MS Visual Studio .NET 2003 (Visual C++) is:


      private: System::Void button2_Click(System::Object *  sender, System::EventArgs *  e)
                   {                  
//                  Put some code in here to launch Form2.

                   }
0
Comment
Question by:toyboy61
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 600 total points
ID: 35072740
Form2^ frm = new Form2();
this->Hide();
frm->ShowWindow();



ps.  .Net code is not MFC - the two are rather different languages.
0
 

Author Comment

by:toyboy61
ID: 35072858
private: System::Void button2_Click(System::Object *  sender, System::EventArgs *  e)
                   {                  
                         Form2^ frm = new Form2();
                         this->Hide();
                         frm->ShowWindow();
                   }

When trying to compile this source code I get the following errors:

Form1.h(104) : error C2143: syntax error : missing ';' before '^'
Form1.h(106) : error C2065: 'frm' : undeclared identifier
Form1.h(106) : error C2227: left of '->ShowWindow' must point to class/struct/union
 type is ''unknown-type''
C:\Programfiler\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(3691) : error C2365: 'ShowWindow' : redefinition; previous definition was a 'formerly unknown identifier'

What have I done wrong here ? :-(

0
 

Assisted Solution

by:toyboy61
toyboy61 earned 0 total points
ID: 35073981
The following code compiled and run without errors.

                        Form2 * md1=new Form2();
                        md1->Activate();
                        md1->Show();


0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 45

Expert Comment

by:AndyAinscow
ID: 35079607
But that isn't C++ .net code - hw did it even compile?
0
 

Author Comment

by:toyboy61
ID: 35081538
I'm a newbie. I use Microsoft Visual Studio .NET 2003 IDE with Visual C++.
Your code (which of course is C++.net-code) did not compile (see error messages in an earlier posting), but my code snippet did compile and - surprisingly - it runs as well.

I started by choosing "Visual C++ Projects" and then "Windows Forms Application" as template. This template should be "A project for creating an application with a Windows user interface using Managed Extensions for C++.".  So maybe I'm not using .NET-code using this template at all - or.. ???
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 35081889
>>MS Visual Studio .NET 2003

Hmmm, is it using the older syntax?  Microsoft made some changes to C++.net very early on.  Be careful, you might be writing code that you would have difficulty porting to a newer version of visual studio.
0
 

Author Comment

by:toyboy61
ID: 35084432
It seems so. And I no intention of upgrading to a new version of Visual Studio now. I only want to make this program work on the Windows platform. Maybe I'll port it to Java later on.. :-))
0
 

Author Closing Comment

by:toyboy61
ID: 35126359
No additional comments.
0

Featured Post

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question