August 30th, 2010, 08:05 PM
displaying a user control from a dll
I'm trying to use some UI elements via a dll. So what I've done in VS is create a Windows Forms Control Library and defined a UI with the standard toolbox items. I build the dll and lib files successfully.
Next, I create a standard Windows Forms Application and include the project for the Windows Forms Control i just made. i link the lib file to the Forms Application project and build. in the Forms app, i have a single button that when pressed executes this code:
MyFormsControl ^c = gcnew MyFormsControl;
everything builds with 0 errors or warnings, but the UI i made for the control is never seen after hitting the button in the Forms application. I put a break point there and the code definitely gets hit. can anyone tell me why this doesn't work?
thanks in advance for any and all help. let me know if any further information is needed. i would also be more than happy to upload a zipped version of both projects if anyone thinks that'll help them figure out what's going on.
September 1st, 2010, 02:04 PM
Re: displaying a user control from a dll
Ok, i figured it out. apparently, you have to have a window/form to display the user control in. so in the dll function i export, i have a function that looks like this:
void __declspec(dllexport) myNameSpace::showMyControl()
MyFormsControl ^c = gcnew MyFormsControl();
Form ^f = gcnew Form();
f->Controls->Add( c );
Application::Run( f );
and that did the trick.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!