Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Circular Form Reference

Circular Form Reference

Scheduled Pinned Locked Moved Managed C++/CLI
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thenutz72
    wrote on last edited by
    #1

    Hey, I am trying to open form2 from form1. Then open a new form1 when form2 is closed. But adding the #include "Form1.h" header to form2.h is causing errors (undeclared identifier). I added these inclusion guards and tried using forward declaration. EIther that didn't work or I used it wrong, not sure I followed the correct syntax since all of the code is in the header files - the automatically generated code for Forms and controls. /*Form1.h*/ #pragma once #ifndef First #define First #include "Form2.h" private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { Form2 ^ frm = gcnew Form2; frm->Show(); this->Close(); } #endif /*Form2.h*/ #pragma once #ifndef Second #define Second #include "Form1.h" private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { Form1 ^ frm = gcnew Form1; frm->Show(); this->Close(); } #endif

    L E 2 Replies Last reply
    0
    • T thenutz72

      Hey, I am trying to open form2 from form1. Then open a new form1 when form2 is closed. But adding the #include "Form1.h" header to form2.h is causing errors (undeclared identifier). I added these inclusion guards and tried using forward declaration. EIther that didn't work or I used it wrong, not sure I followed the correct syntax since all of the code is in the header files - the automatically generated code for Forms and controls. /*Form1.h*/ #pragma once #ifndef First #define First #include "Form2.h" private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { Form2 ^ frm = gcnew Form2; frm->Show(); this->Close(); } #endif /*Form2.h*/ #pragma once #ifndef Second #define Second #include "Form1.h" private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { Form1 ^ frm = gcnew Form1; frm->Show(); this->Close(); } #endif

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Your post is wrong on so many levels it's difficult to know where to start. First, it is obvious you are a beginner. I don't know of any authoritative source for this but common sense tells me that Managed C++ development is not appropriate for beginners. Beginners probably need to learn C/C++ basics and consider CLI an advanced topic. Next, as a user, if an application is popping up windows all the time I am closing it and uninstalling it. There is absolutely no need to open up new top level windows just to display a different view. Tabs are also grossly abused, from an MDI or Configuration perspective they make sense, but not as a Primary UI design. Another thing, if you insist on this insanely poor path, the fundamental solution to a circular dependency problem is to introduce a third item to the picture and define the relationships such that the original two items are unrelated.

      item one item two
      \ /
      \ /
      \ /
      new item

      One other thing, you might want to start learning what Software Design Patterns are. Good luck :beer:

      modified on Tuesday, March 24, 2009 1:01 PM

      T 1 Reply Last reply
      0
      • L led mike

        Your post is wrong on so many levels it's difficult to know where to start. First, it is obvious you are a beginner. I don't know of any authoritative source for this but common sense tells me that Managed C++ development is not appropriate for beginners. Beginners probably need to learn C/C++ basics and consider CLI an advanced topic. Next, as a user, if an application is popping up windows all the time I am closing it and uninstalling it. There is absolutely no need to open up new top level windows just to display a different view. Tabs are also grossly abused, from an MDI or Configuration perspective they make sense, but not as a Primary UI design. Another thing, if you insist on this insanely poor path, the fundamental solution to a circular dependency problem is to introduce a third item to the picture and define the relationships such that the original two items are unrelated.

        item one item two
        \ /
        \ /
        \ /
        new item

        One other thing, you might want to start learning what Software Design Patterns are. Good luck :beer:

        modified on Tuesday, March 24, 2009 1:01 PM

        T Offline
        T Offline
        thenutz72
        wrote on last edited by
        #3

        Wow, talk about confused. For someone who doesn't know the answer you sure have a lot to say. Clearly, you misunderstand an attempt to simplify an example. As such you should consider not "answering" (loosely used, in your case) to people's posts.

        L 1 Reply Last reply
        0
        • T thenutz72

          Wow, talk about confused. For someone who doesn't know the answer you sure have a lot to say. Clearly, you misunderstand an attempt to simplify an example. As such you should consider not "answering" (loosely used, in your case) to people's posts.

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          thenutz72 wrote:

          Wow, talk about confused.

          Ok, let's talk about that. What are you confused about?

          thenutz72 wrote:

          For someone who doesn't know the answer

          Um, "the answer"? Really, there is only one way to solve your problem, interesting. What part of my post does not qualify as an answer?

          thenutz72 wrote:

          you should consider not "answering"

          First lets get one thing clear. So far there is not one thing you have said that I would consider let alone that suggestion. By the way if you continue to attempt to berate my reply it will end with me ripping your virtual head off and shoving it down your ignorant throat.

          T 1 Reply Last reply
          0
          • L led mike

            thenutz72 wrote:

            Wow, talk about confused.

            Ok, let's talk about that. What are you confused about?

            thenutz72 wrote:

            For someone who doesn't know the answer

            Um, "the answer"? Really, there is only one way to solve your problem, interesting. What part of my post does not qualify as an answer?

            thenutz72 wrote:

            you should consider not "answering"

            First lets get one thing clear. So far there is not one thing you have said that I would consider let alone that suggestion. By the way if you continue to attempt to berate my reply it will end with me ripping your virtual head off and shoving it down your ignorant throat.

            T Offline
            T Offline
            thenutz72
            wrote on last edited by
            #5

            Shut up, jackass.

            L L 2 Replies Last reply
            0
            • T thenutz72

              Shut up, jackass.

              L Offline
              L Offline
              led mike
              wrote on last edited by
              #6

              fuck off asshole

              1 Reply Last reply
              0
              • T thenutz72

                Hey, I am trying to open form2 from form1. Then open a new form1 when form2 is closed. But adding the #include "Form1.h" header to form2.h is causing errors (undeclared identifier). I added these inclusion guards and tried using forward declaration. EIther that didn't work or I used it wrong, not sure I followed the correct syntax since all of the code is in the header files - the automatically generated code for Forms and controls. /*Form1.h*/ #pragma once #ifndef First #define First #include "Form2.h" private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { Form2 ^ frm = gcnew Form2; frm->Show(); this->Close(); } #endif /*Form2.h*/ #pragma once #ifndef Second #define Second #include "Form1.h" private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { Form1 ^ frm = gcnew Form1; frm->Show(); this->Close(); } #endif

                E Offline
                E Offline
                erfi
                wrote on last edited by
                #7

                if you are creating a windows form application under CLR category then in Form1.h your code must be like this:

                #pragma once
                #include "Form2.h"

                namespace CircularForm {
                using namespace System;
                using namespace System::ComponentModel;
                using namespace System::Collections;
                using namespace System::Windows::Forms;
                using namespace System::Data;
                using namespace System::Drawing;
                .
                .
                .

                private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
                Form2^ f2 = gcnew Form2();
                f2->Show();
                this->Close();
                }

                but when the form1 is closed the managed memory of form2 will be released. the whole program will be ended. there is 2 way to do this: 1. don't close the form1, just hide form1 and when form2 is closed show it(form1) again. 2. add a new class (Form3) containing two objects (Form1 f1, Form2 f2). set it as startup form and control the f1,f2

                sometimes 0 can be 1

                1 Reply Last reply
                0
                • T thenutz72

                  Shut up, jackass.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  Mike is a well known here and has helpled lots of people, I suggeset you take what he has said constructively.

                  Visit http://www.notreadytogiveup.com/[^] and do something special today.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups