.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 13th, 2010, 05:30 PM
Wazakindjes Wazakindjes is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2010
Posts: 1 Wazakindjes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 59 m 30 sec
Reputation Power: 0
Multiple Forms Help

So I'm trying to code this program which uses multiple forms. You can switch between them with a button. You can switch back and forth, not only from Form1 to Form2. =3

So in short:
Form1 -> Click on button -> Form2 shows, Form1 hides -> Click on button -> Form1 shows, Form2 hides.
This is what I have:

Code:
#pragma once
#include "Form2.h"

ref class Form2;

namespace MultiForms
{
 public ref class Form1 : public Form
 {
 //Everything not involving Form2 in here
 private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e);
 };

 System::Void Form1::button2_Click(System::Object^ sender, System::EventArgs^ e)
 {
 Form1::Visible = false;
 Form2^ NewForm = gcnew Form2;
 NewForm->Visible = true;
 }
}


Now Visual Studio returns these errors (in both Form1.h and Form2.h (in Form2 it would be referring to Form1)):

Code:
error C2512: 'Form2' : no appropriate default constructor available

error C2027: use of undefined type 'Form2'
see declaration of 'Form2'

error C2227: left of '->Visible' must point to class/struct/union/generic type


If I comment out the lines containing "NewForm", I receive this error:

Code:
error LNK2005: "private: void __clrcall MultiForms::Form2::button2_Click(class System::Object ^,class System::EventArgs ^)" (?button2_Click@Form2@MultiForms@@$$FA$AAMXP$AAVOb  ject@System@@P$AAVEventArgs@4@@Z) already defined in MultiForms.obj
fatal error LNK1169: one or more multiply defined symbols found


I found out that it's because of the declaration without a body inside the Form class and the declaration WITH body outside the Form class. :\

What should I do?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > Multiple Forms Help


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap