CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2010

    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.


  2. #2
    Join Date
    May 2010

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.