Saját form elemeinek elérése, C++

Saját form elemeinek elérése, C++
2011-06-12T00:33:54+02:00
2011-10-16T01:20:52+02:00
2022-11-23T09:00:42+01:00
Delphi_Fan
Sziasztok!

Hogy érhetem el VS2010-ben C++/CLI-ben az MDIChild formom komponenseit?

Ezzel próbálkoztam:
namespace fm { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace System::Net; /// <summary> /// Summary for Form1 /// </summary> public ref class Form1 : public System::Windows::Forms::Form { public: contentList cL; Form1(void) { InitializeComponent(); // //TODO: Add the constructor code here // } ...
Így hivatkozom a cL-re, ami még működik:
private: System::Void CreateFileWindow(){ cL.MdiParent = this; cL.Dock = System::Windows::Forms::DockStyle::Fill; cL.Show(); }
A contentList.h-ban van egy ilyen:
public: array<System::String^>^ GetSelectedListOFLV(){ int selCount = 0; if(LV_Left->Focused == true){ //Ha a progi lefordul, LV_Left = null :( selCount = GetSelectedCount(LV_Left); } else { selCount = GetSelectedCount(LV_Right); } array<System::String^>^ theList = gcnew array<System::String^>(selCount); if(selCount > 0){ int idx; int j; if(LV_Left->Focused == true){ for(idx=0; idx<selCount; idx++){ for(j=0;j<LV_Left->Items->Count;j++){ if(LV_Left->Items[j]->ForeColor == System::Drawing::Color::Red){ theList[idx] = Pane_Left->Text + LV_Left->Items[j]->Text; idx++; } } } } else { for(idx=0; idx<selCount; idx++){ for(j=0;j<LV_Right->Items->Count;j++){ if(LV_Right->Items[j]->ForeColor == System::Drawing::Color::Red){ theList[idx] = Pane_Right->Text + LV_Right->Items[j]->Text; idx++; } } } } } return theList; }
Így próbálok dolgozni vele egy másik formon:
contentList cL = (contentList)this->ActiveMdiChild; array<System::String^> ^SelItems = cL.GetSelectedListOFLV();
- Ez az ami nem fordul le.
contentList^ cL = (contentList^)this->ActiveMdiChild; array<System::String^> ^SelItems = cL->GetSelectedListOFLV();
- Így lefordul.
Amennyiben nem fordul le, ez a hibaüzi:

1>c:\vs2010\akta menedzser\fm\fileOperations.h(231): error C2440: 'type cast' : cannot convert from 'System::Windows::Forms::Form ^' to 'fm::contentList'
1> Conversion requires a constructor or user-defined-conversion operator, which can't be used by const_cast or reinterpret_cast
1>c:\vs2010\akta menedzser\fm\fileOperations.h(231): error C3673: 'fm::contentList' : class does not have a copy-constructor
1> fm.cpp
1>c:\vs2010\akta menedzser\fm\fileOperations.h(231): error C2440: 'type cast' : cannot convert from 'System::Windows::Forms::Form ^' to 'fm::contentList'
1> Conversion requires a constructor or user-defined-conversion operator, which can't be used by const_cast or reinterpret_cast
1>c:\vs2010\akta menedzser\fm\fileOperations.h(231): error C3673: 'fm::contentList' : class does not have a copy-constructor


Mi a baj?

Üdv.: Delphi_Fan
Mutasd a teljes hozzászólást!
Mutasd a teljes hozzászólást!

Tetszett amit olvastál? Szeretnél a jövőben is értesülni a hasonló érdekességekről?
abcd