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. C / C++ / MFC
  4. global or something like

global or something like

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 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.
  • X Offline
    X Offline
    Xeef
    wrote on last edited by
    #1

    hi all i have a bunch of classes mostly extended base classes like Form, TabControl... all of them needs to know abouth each other in the moment i have _TabCon = gcnew TabCon( this ); //this points to MainFrom Controls->Add( _TabCon ); ... .. TabCon::TabCon( MainForm^ F) { Form = F; .. . so all classes know MainForm and MainForm know all classes is there a better way ? whit out the need of Form = F; in each class something like static global MainFromLink = MainForm; so that i can reach this from anywhere MainFrom is ref class MainForm: public System::Windows::Forms::Form

    F H 2 Replies Last reply
    0
    • X Xeef

      hi all i have a bunch of classes mostly extended base classes like Form, TabControl... all of them needs to know abouth each other in the moment i have _TabCon = gcnew TabCon( this ); //this points to MainFrom Controls->Add( _TabCon ); ... .. TabCon::TabCon( MainForm^ F) { Form = F; .. . so all classes know MainForm and MainForm know all classes is there a better way ? whit out the need of Form = F; in each class something like static global MainFromLink = MainForm; so that i can reach this from anywhere MainFrom is ref class MainForm: public System::Windows::Forms::Form

      F Offline
      F Offline
      fcheng
      wrote on last edited by
      #2

      Usually the reason for one control's class "needing" to know about another control is because of the data stored in the class, and has nothing to do with the control itself. If this is your situation, then consider collecting the key data together in one "data" class, and accessing that class via the CWinApp object (or a global variable).

      X 1 Reply Last reply
      0
      • X Xeef

        hi all i have a bunch of classes mostly extended base classes like Form, TabControl... all of them needs to know abouth each other in the moment i have _TabCon = gcnew TabCon( this ); //this points to MainFrom Controls->Add( _TabCon ); ... .. TabCon::TabCon( MainForm^ F) { Form = F; .. . so all classes know MainForm and MainForm know all classes is there a better way ? whit out the need of Form = F; in each class something like static global MainFromLink = MainForm; so that i can reach this from anywhere MainFrom is ref class MainForm: public System::Windows::Forms::Form

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #3

        It was better you asked (Managed) C++/CLI forum.


        WhiteSky


        J 1 Reply Last reply
        0
        • H Hamid Taebi

          It was better you asked (Managed) C++/CLI forum.


          WhiteSky


          J Offline
          J Offline
          John R Shaw
          wrote on last edited by
          #4

          Thank you! I have forced classes (friends) to know about each other (one time), but I considered it to be bad programming. Either it is global or it is not.

          INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

          X 1 Reply Last reply
          0
          • F fcheng

            Usually the reason for one control's class "needing" to know about another control is because of the data stored in the class, and has nothing to do with the control itself. If this is your situation, then consider collecting the key data together in one "data" class, and accessing that class via the CWinApp object (or a global variable).

            X Offline
            X Offline
            Xeef
            wrote on last edited by
            #5

            Hmmmm looks like in the moment : namespace WhatsUp { MainForm::MainForm( ) { Size = System::Drawing::Size( 600, 600 ); MinimumSize = System::Drawing::Size( 600, 600 ); _TabCon = gcnew TabCon( this ); Controls->Add( _TabCon ); _TabCon->_PageStatus = gcnew PageStatus( ); _TabCon->Controls->Add ( _TabCon->_PageStatus ); _TabCon->_PageSetup = gcnew PageSetup( ); _TabCon->Controls->Add ( _TabCon->_PageSetup ); _PlugLoad = gcnew PlugLoad( this ); _IniLoad = gcnew IniLoad ( this ); } } [System::STAThreadAttribute] int main(array^ args) { System::Windows::Forms::Application::EnableVisualStyles(); System::Windows::Forms::Application::SetCompatibleTextRenderingDefault(false); System::Windows::Forms::Application::Run( gcnew WhatsUp::MainForm() ); } ... .. namespace WhatsUp { IniLoad::IniLoad( MainForm^ F ) { Form = F; Form->_TabCon->_PageStatus->StatusText->Text += "Proccessing ini File" + System::Environment::NewLine; PageSetup and PageStatus are derived TabPages i have a few textboxes on them as output this are populated by PlugLoad, IniLoad and many others IniLoad loads an xml cheks it and give singel nodes to PlugLoad for future proccessing and so on so all classes by it a derived like PageSetup or a base class like IniLoad needs to comunikate whit each other either to write something on screen or to hand over data for future proccessing

            fcheng wrote:

            then consider collecting the key data together in one "data" class

            i think this is basicli what MainForm do it has a referenc / pointer to all used classes i was basicly hopoing to by abel to prevent IniLoad::IniLoad( MainForm^ F ) Form = F; and use instead some global referenc to it but i can´t make managed things global is there some EASY way to know who has called this class IniLoad::IniLoad( ) Form = System::SomeFunction->The->oneWho->CalledMe; whit out to use assembler

            1 Reply Last reply
            0
            • J John R Shaw

              Thank you! I have forced classes (friends) to know about each other (one time), but I considered it to be bad programming. Either it is global or it is not.

              INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

              X Offline
              X Offline
              Xeef
              wrote on last edited by
              #6

              hup some how i didnt saw the 2 abowe replays :confused: this managed unmanaged clr cli mfc ... is so confusing to me in the moment :confused: no idea in what i am programing :^) just that i am using visual c++ :-D

              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