hi all how can i do something like: System::Type^ a = int::typeid; int b = (a^) c;
Xeef
Posts
-
cast to a stored type -
still reflecting / major problemcan a reflected methode not return gcnew System::Windows::Forms::TextBox() but just base types like INT ??? if not mean it can return TextBox where do i go wrong ? myType = SampleAssembly->GetType("Memory.What"); myObj = System::Activator::CreateInstance( myType ); myMethod = myType->GetMethod("Name"); myMethod->Invoke( myObj , nullptr ); <<<--- here is the error i have a MessageBox::Show in Memory.What.Name wich is fiered and also shows TextBox->ToString() corect which shoud by returned (ToString is for testing in the messagebox dont get confused) An unhandled exception of type 'System.NullReferenceException' occurred in WhatsUp.exe Additional information: Object reference not set to an instance of an object.
-
Reflection how to cast to loaded typeunfortunaly no :( same error this is where i am in the moment : myType = SampleAssembly->GetType("Memory.What"); myObj = System::Activator::CreateInstance( myType ); System::Reflection::MethodInfo^ mi = myType->GetMethod("Ver"); mi->Invoke(myObj , nullptr ); so i can call the methode but its not to elegant there muss by some other way so that i can call it like : LoadedDLL->Ver();
-
Reflection how to cast to loaded typehi all
System::Reflection::Assembly^ SampleAssembly; System::Type^ myType; System::Activator::Object^ myObj; try { SampleAssembly = System::Reflection::Assembly::LoadFrom( Path ); } catch (System::IO::FileNotFoundException^ catchException) { Form->_TabCon->_PageStatus->StatusText->Text += catchException->ToString() + System::Environment::NewLine; return 1; } try { myType = SampleAssembly->GetType("Memory.What"); if (!myType) throw (System::String^) "Can´t locate Base Function [incompatible plug ???]"; } catch (System::String^ catchException) { Form->_TabCon->_PageStatus->StatusText->Text += catchException + System::Environment::NewLine; return 1; } myObj = System::Activator::CreateInstance( myType ); // creates the instance **What^ W = (What^)myObj;**
how can i cast to "What^" ? i tryed to have a .h .cpp file whit the same declaration as in "Memmory.what" but i get an error An unhandled exception of type 'System.InvalidCastException' occurred in WhatsUp.exe Additional information: Unable to cast object of type 'Memory.What' to type 'WhatsUp.What'. -
global or something likehup 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
-
global or something likeHmmmm 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
-
global or something likehi 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 -
2 way comunicaion betwean classesCool thx a lot ! :-D
-
2 way comunicaion betwean classeshi all topic says it how can i do something like : this ist NOT working but what ever i try i ending always by this problem -->
class1.h #pragma once ref class class1 { public: class1(void); class2^ c2; }; .cpp #include "StdAfx.h" #include "class1.h" #include "class2.h" class1::class1(void) { } class2.h #pragma once ref class class2 { public: class2(void); class1^ c1; }; .cpp #include "StdAfx.h" #include "class2.h" #include "class1.h" class2::class2(void) { }
-
classes a few questionsworking half way how can i get this out of class.h in to the class.cpp file : virtual int Show(void){return 1;}; virtual int Show(void)override{.... something like : virtual int Memory::Show(void)override{ wich isnt woking :((
-
classes a few questionshi all if some one whit knowledege coud sacrify 2-3 minutes it woud save me a day time ;) a have a class X now i wana make a class Y wich woud derive all methodes, variables of X and has new ones i wana ensure in X that certain methode are implemented in Y wich arent in X but declared i wana overwrite methodes of X in Y how do i write functions for operators that this works : Myclass a=Myclass(); a++; a=a*a; ... .. i was try to use System::String inside a struct and was geting erros that i cant use a managed type in a struct blabla i have solved this by using a class instead but woud by nice to know if there is a way around similair problems seams to ocure if i try to use them as static i woud like to have a static array in my class whit a pointer to all instances of this class this is important else way i have trubel if some one coud give me a 10-20 line example it woud by great just code no need for description
-
how do i remove a MouseEventHandler [modified]hi all stuckt agein hope i not highjack this hole topic :wtf:
void Disp::Lock_Down(System::Object ^o, System::Windows::Forms::MouseEventArgs ^e){ Lock->MouseMove += gcnew System::Windows::Forms::MouseEventHandler( this, &Disp::Lock_Drag ); MousePosition=MainF->MousePosition; } void Disp::Lock_Up(System::Object ^o, System::Windows::Forms::MouseEventArgs ^e){ >>>>>>>>>>>>>> not like this but how ??? :confused: Lock->MouseMove->Remove(this, &Disp::Lock_Drag); <<<<<<<<<<<<<< }
-- modified at 9:48 Friday 25th May, 2007 this worksvoid Disp::Lock_Down(System::Object ^o, System::Windows::Forms::MouseEventArgs ^e){ t = gcnew System::Windows::Forms::MouseEventHandler( this, &Disp::Lock_Drag ); Lock->MouseMove += t; MousePosition=MainF->MousePosition; } void Disp::Lock_Up(System::Object ^o, System::Windows::Forms::MouseEventArgs ^e){ Lock->MouseMove -= t; }
BUT i realy not like "t" is there a way to get it somehow else mayby out of Object ^o or MouseEventArgs ^e or how ever whit out the need to store it by my self -
datagridview data:-D thx a lot ! exctly what i need
-
datagridview datahi agein to all
array^row0 = {"11/22/1968","29"}; DataGridView1->Rows->Add( row0 ); row0[0]="2"; Object^ a= DataGridView1->DataSource; a[0]="123";
error C3915: 'System::Object' has no default indexed property (class indexer) how do i acces the rows after they are created / aplyed i havent try it but i am prety sure i coud overwrite it like DataGridView1->Rows->Add( somethingelse ); mayby not whit add :p it woud just append / push it in this case any way the question is how can i acces it streigt to replace data something like DataSource[row][col]= "my new value"; i not wana use databinding to a data base as the data are live generated and i dont think it woud make thinks easyer any way ;) on top if this is there any way to list the content and types whats in an object some recursive loop wich woud rotate truh all elements of the object by it an array a mullti dim array or what ever object combination -
conver size_t to System::Stringwow so much help in so short time thank you too
-
conver size_t to System::Stringcool ! thx a lot ! working so fare :-D System::String^ MeM::X(){ char a[200]; sprintf_s( a,200, "%d", stat.dwTotalPhys ); return gcnew System::String(a); }
-
conver size_t to System::Stringhi all new here and also to c++
MeM mem=MeM() textBoxeS[0] = gcnew System::Windows::Forms::TextBox; textBoxeS[0]->Size = System::Drawing::Size( 300, 40 ); textBoxeS[0]->ReadOnly = true; //textBoxeS[0]->Text = gcnew String(mem.X()); ???????????? textBoxeS[0]->BackColor = SystemColors::Window; MeM::MeM(void) { GlobalMemoryStatus (&stat); } System::String^ MeM::X(){ how do i cast / convert this ---->>>> char *a=(char*)stat.dwTotalPhys; return gcnew String(a); //System.ArgumentOutOfRangeExceptio //return const_cast(stat.dwTotalPhys); <<<<---------- PROBLEM HERE }
other question is there an AUTOindent function in visual C++ 2005 ? cheers rick