C++ / CLI compatibility
Grokiff opened this issue · 2 comments
Hi,
Thanks a lot for your Dark UI Components library.
I try to use it within a C++ / CLI project in Visual Studio.
I Try to use DockPanel with DockToolWindows
I have created a Form inherited from DarkToolWindow :
public ref class TFrmToolTest : public DarkToolWindow
{
public:
TFrmToolTest(void)
{
this->InitializeComponent();
//
//TODO: ajoutez ici le code du constructeur
//
}
[...]
};
It works fine, In the VS designer, I see my ToolWindow and I can edit it.
My problem :
In my main class (main form), I have created a DarkToolWindow List :
List<DarkToolWindow^>^ ToolWindows;
this->ToolWindows = gcnew List<DarkToolWindow^>();
After that I add a TFrmToolWindow in the list :
this->ToolWindows->Add(gcnew TFrmToolTest());
The runtime error occurs when I try to itterate the list in a for loop to add the ToolWindow to the DarkPanel Components list :
for each (DarkToolWindow ^ toolWindow in this->ToolWindows)
this->DockPanel->AddContent(toolWindow); // <- Runtime error
The error is :
System.Collections.Generic.KeyNotFoundException :
I never had this kind of error before and I can't find a solution.
Do you have an idea of the problem ?
Thanks a lot
KeyNotFoundException is raised when you attempt to reference a dictionary entry by a key which does not exist.
The first line of code to reference a dictionary in AddContent() is:
DarkUI/DarkUI/Docking/DarkDockPanel.cs
Line 153 in 31603ae
DarkDockPanel automatically generates the following regions when it is instantiated: Document, Left, Right, and Bottom, so I would assume that your TFrmToolTest class does not have a valid DefaultDockArea property set. (A form's initial DockArea value is set by DefaultDockArea)
I'm not sure how this works in C++, but in the C# example the DefaultDockArea is set through the visual designer. The generated code looks like this:
Try setting this through the designer or manually in your code. If this does not fix the problem, can you please attach your call stack so I can look in more detail?