global or something like
-
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 -
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::FormUsually 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).
-
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::FormIt was better you asked (Managed) C++/CLI forum.
WhiteSky
-
It was better you asked (Managed) C++/CLI forum.
WhiteSky
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
-
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).
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 proccessingfcheng 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
-
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