I
am working on a new application architecture in VC++ 2005 and I would
like to load my own custom controls dynamically. How do I do this I
have attempted several different methods but to no avail.
More
Information: I have a set of custom controls which I built using the
"Windows Forms Control Library" project selection. The controls are stored as
DLLs. Normally these controls are linked to through the IDE/project
settings and placed onto the form at design time, however, I need to be
able to load them dynamically at runtime based on certain events.
Basically the controls will operate as plug-ins. Is this possible Is
there a better way
There is an example in VB.NET that shows how
to load VB forms stored in DLLs at runtime and display them
dynamically, which is essentially what I am trying to do in C++. Here
is a link (only follow up to step 9): http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnadvnet/html/vbnet10082002.asp
Since
I found no equivilent method in VC++ 2005 I am assuming that using
custom controls could be the solution. If anyone can help or offer a
suggestion it would be most appreciated. Thanks!

Loading Custom Controls or Windows Forms at Runtime
argodev
Here is a simplified example:
Assembly ^myAssembly = Assembly::Load("XYZ"); // load the assembly from the control DLL
Type ^myType = myAssembly ->GetType("Form1.Form1Control"); // gets the object type
Object ^myObj = Activator::CreateInstance(myType ); // creates the instance
this->Controls->Add((Control ^)myObj ); // puts the control on the form
You can also get at all the properties and methods of the created object using the PropertyInfo and MethodInfo objects in the namespace.
Does anyone know if this would be easier another way, or if there is an alternative I'd love to explore different ways to do this.