I GIVE UP, how do I modify this code to call from one form to the other and back

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2004
Posts: 3
Reputation: V5dave is an unknown quantity at this point 
Solved Threads: 0
V5dave V5dave is offline Offline
Newbie Poster

I GIVE UP, how do I modify this code to call from one form to the other and back

 
0
  #1
Oct 17th, 2004
I finally give up. I have here two very simple forms that (for demonstration purposes) consist of a single click button. When you click on the button, the form becomes invisible, and the other becomes visible. you can keep going back and forth till your coffee needs re-heating in the the microwave having developed a really nice thick skin!!

BUT IT DOESN'T WORK!!!!

I obviously wanna do much more than this, but what I'm trying to do is to write successfully from one form to the other and back, then a whole world of possibilities are opened up to me. I have tried many ways (hence the comments) but always get compiler errors such as
error C2512: 'datapassing::Form1' : no appropriate default constructor available
amongst others.

Using Microsoft Visual C++.NET V2003

I could manage forms untill .NET decided to manage them for me!!


Form 1
  1. #pragma once
  2. #include "Form2.h"
  3.  
  4. namespace datapassing
  5. {
  6. //public __gc class Form2;
  7. using namespace System;
  8. using namespace System::ComponentModel;
  9. using namespace System::Collections;
  10. using namespace System::Windows::Forms;
  11. using namespace System::Data;
  12. using namespace System::Drawing;
  13.  
  14. public __gc class Form1 : public System::Windows::Forms::Form
  15. {
  16. public:
  17. // TellForm2Something( Form2* pForm2 );
  18. // void TellForm2Something( Form2* pForm2 )
  19. // {
  20. // pForm2->make_visible();
  21. // }
  22. Form2 *pFrm2;
  23. public:
  24. Form1(void)
  25. {
  26. InitializeComponent();
  27. pFrm2 = new Form2;
  28. }
  29.  
  30. public:
  31. void make_visible(void)
  32. {
  33. this->Visible = true;
  34. }
  35.  
  36. //STANDARD INITIALISATION AND DISPOSING CODE
  37.  
  38. private: System::Void button1_Click(System::Object * sender, System::EventArgs * e)
  39. {
  40. // TellForm2Something(Form2);
  41. pFrm2->Visible = true;
  42. this->Visible = false;
  43. }
  44.  
  45. };
  46. }


Form 2
  1. #pragma once
  2. #using <mscorlib.dll>
  3.  
  4. using namespace System;
  5. using namespace System::ComponentModel;
  6. using namespace System::Collections;
  7. using namespace System::Windows::Forms;
  8. using namespace System::Data;
  9. using namespace System::Drawing;
  10.  
  11.  
  12. namespace datapassing
  13. {
  14. public __gc class Form1;
  15. public __gc class Form2 : public System::Windows::Forms::Form
  16. {
  17. public:
  18. // TellForm1Something( Form1* pForm1 );
  19. // void TellForm1Something( Form1* pForm1 )
  20. // {
  21. // pForm1->make_visible();
  22. // }
  23. Form1 *pFrm1;
  24. public:
  25. Form2(void)
  26. {
  27. InitializeComponent();
  28. pFrm1 = new Form1;
  29. }
  30.  
  31. public:
  32. void make_visible(void)
  33. {
  34. this->Visible = true;
  35. }
  36.  
  37. //STANDARD INITIALISATION AND DISPOSING CODE
  38.  
  39. private: System::Void button1_Click(System::Object * sender, System::EventArgs * e)
  40. {
  41. pFrm1->Visible = true;
  42. //pFrm1->make_visible();
  43. //TellForm1Something(Form1);
  44. this->Visible = false;
  45.  
  46. }
  47.  
  48. };
  49. }
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC