How to create the UserControl of C# inside MFC CWnd at runtime

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have created C# customcontrol with COM behaviour and it was sucessfully created and I can able to used inside my MFC dialog based application by drag and drop the control.
The UserControl having the following classes:
1. ComReg.cs
2. CustomCtrl.cs
3. CustomClass.cs
4. ICustomInterface.cs
in the above CustomCtrl.cs is the C# usercontrol and having one pannel, inside the pannel i am going to draw a rectangle, here DrawRect was implemeted. Customclass is an another class having a static object of usercontrol and it has a public method of drawRect, through DrawRect i will call the custom contrl DrawRect by its static object, in my interface ICustonmInterface i have exposed the DrawRect method.
Once i build the above project it will provide .dll and .tlb.
In my dialog based application first i will drag and drop the control and then i have include the .tlb and i will create an instance for the interface through i will call the DrawRect.
Finally the dialog based application launches with custom control and draw a rectable inside the pannel.
MY QUESTION HERE IS, IS THERE A WASY I CAN CREATE THE CONTROL AT RUNTTIME UNDER CWnd class? instead of drag and drop
Advance thanks,
Karthikeyan S
Karthikeyan S

View the full article
 
Back
Top