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. Multiple Forms

Multiple Forms

Scheduled Pinned Locked Moved Managed C++/CLI
c++delphihelpquestion
8 Posts 3 Posters 1 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.
  • P Offline
    P Offline
    Polar_Sheep
    wrote on last edited by
    #1

    Hi, I need use two forms in application. Is some easy way exists? I do that in Delphi, but in C++/CLI Win Form app is something understandable. I was googling for some easy practise, but not found it. Is there something who help me with piece of code for two forms?

    T 1 Reply Last reply
    0
    • P Polar_Sheep

      Hi, I need use two forms in application. Is some easy way exists? I do that in Delphi, but in C++/CLI Win Form app is something understandable. I was googling for some easy practise, but not found it. Is there something who help me with piece of code for two forms?

      T Offline
      T Offline
      teejayem
      wrote on last edited by
      #2

      you can use multiple forms in C++/CLI. Just right click on your project and click "Add new Item..."

      Don't be overcome by evil, but overcome evil with good

      P 1 Reply Last reply
      0
      • T teejayem

        you can use multiple forms in C++/CLI. Just right click on your project and click "Add new Item..."

        Don't be overcome by evil, but overcome evil with good

        P Offline
        P Offline
        Polar_Sheep
        wrote on last edited by
        #3

        Sure, but I cant use (in example) in Form1 -> Form1.Visible = true; OK Form2.Show = true; it doesnt know Form2 (I maybe use :: ) I must include something to Form1?

        D T 2 Replies Last reply
        0
        • P Polar_Sheep

          Sure, but I cant use (in example) in Form1 -> Form1.Visible = true; OK Form2.Show = true; it doesnt know Form2 (I maybe use :: ) I must include something to Form1?

          D Offline
          D Offline
          dybs
          wrote on last edited by
          #4

          You can create 2 separate forms just as teejayem suggested, but if you want them completely independent of each other (i.e. Form2 is not a child of Form1), then you need to modify your .cpp file that opens your main form. This file contains your main loop, and probably has a line like Application::Run(gcnew Form1()); You would need to change this to create your Form1 and Form2 objects, show them, and then start your application. You might need a DoEvents loop, but there might be a way around that. Dybs

          1 Reply Last reply
          0
          • P Polar_Sheep

            Sure, but I cant use (in example) in Form1 -> Form1.Visible = true; OK Form2.Show = true; it doesnt know Form2 (I maybe use :: ) I must include something to Form1?

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

            You have to include the form2.h in your form1.h file for you to be able to use it

            #include "Form2.h"

            also "Show" isn't a property, it is a method. You shouldn't be trying to assign a boolean to it

            Don't be overcome by evil, but overcome evil with good

            P 1 Reply Last reply
            0
            • T teejayem

              You have to include the form2.h in your form1.h file for you to be able to use it

              #include "Form2.h"

              also "Show" isn't a property, it is a method. You shouldn't be trying to assign a boolean to it

              Don't be overcome by evil, but overcome evil with good

              P Offline
              P Offline
              Polar_Sheep
              wrote on last edited by
              #6

              Thank you, it works, but there is still little problem. Form1::Visible = false; // I must create Form2, how can I do that? // Cannot use System::Windows::Forms::Form^ Form2 = gcnew System::Windows::Forms::Form; // It will be new form, but I need my Form2 Form2->Show(); // non-static member, I must use ->

              T 1 Reply Last reply
              0
              • P Polar_Sheep

                Thank you, it works, but there is still little problem. Form1::Visible = false; // I must create Form2, how can I do that? // Cannot use System::Windows::Forms::Form^ Form2 = gcnew System::Windows::Forms::Form; // It will be new form, but I need my Form2 Form2->Show(); // non-static member, I must use ->

                T Offline
                T Offline
                teejayem
                wrote on last edited by
                #7

                I'm guessing that is because your varaible name is the same as your class name. so the compiler is thinking your trying to call a static method. Change your variable name to something more unique

                System::Windows::Forms::Form^ myFrm2 = gcnew System::Windows::Forms::Form()

                myFrm2->Show()

                Don't be overcome by evil, but overcome evil with good

                P 1 Reply Last reply
                0
                • T teejayem

                  I'm guessing that is because your varaible name is the same as your class name. so the compiler is thinking your trying to call a static method. Change your variable name to something more unique

                  System::Windows::Forms::Form^ myFrm2 = gcnew System::Windows::Forms::Form()

                  myFrm2->Show()

                  Don't be overcome by evil, but overcome evil with good

                  P Offline
                  P Offline
                  Polar_Sheep
                  wrote on last edited by
                  #8

                  Oh, thank you for your help. I was googling with "c++\cli" AND "#include"Form2.h"" and I found solution. It was that what you wrote. Same name Form2. THANK YOU

                  modified on Sunday, August 24, 2008 1:43 PM

                  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