locked
Add a Windows Form to a VC++ code that creates a DLL RRS feed

  • Question

  • Hello everybody,

    I have a question that will be evry greatful if somebody can help me.

    There exists a VC++ code that generates a DLL file and this DLL file is used by another software (It is a software for simulation of Robots).

    Now my task is to modify this code in a way to show a graphical output, dependent on the outputs of the robotic software....

    I thought I can handel  this by adding a windows form to the exisiting project. But seems the project doesn't accept any windows forms, because  when I add a windows form in it, it makes some errors regarding the hearder files of this form.

    Now my question is..... Is it possible to add a windows form to a project that generates a DLL? OR I am doing something wrong in making this form?

    Thank you in advance for any help

    Tuesday, February 28, 2012 2:07 PM

Answers

  • It is only possible to add a windows form to a project of type Windows Forms or a .net managed class library.  If your project is an unmanaged C++ DLL project, then you can only create windows in an unmanaged way, i. e. the usual Win32 API way, such as adding a new dialog box as a resource, or simply using RegisterClassEx() and CreateWindowEx() to create the window yourself, then pump messages for those windows using GetMessage(), TranslateMessage() and DispatchMessage().


    Jose R. MCP

    • Marked as answer by Helen Zhao Wednesday, March 7, 2012 2:07 AM
    Tuesday, February 28, 2012 5:19 PM
  • Hi Aragorn_29,

    As far as I know, we can add a form or dialog into a DLL.
    About adding a windows form into a DLL, please refer to the following steps:
    1->Create a CLR class library project.
    2->Add a new windows form into it. Make it as a public class.
    3->Build the application. Then you will see a DLL in the solution directory.

    About adding a dialog resource into a DLL, I suggest you refer to these steps:
    1->Create a MFC DLL, and choose "Regular DLL using Share MFC DLL" option.
    2->Right click the project name in Solution Explorer, and then add a new MFC class whose base class is CDialog.
    3->Right click the project name in Solution Explorer again, and choose Class Wizard to add some methods, member variables or messages for the new dialog class.
    4->Build the application.

    I hope you can get useful information from this reply. If you have any questions, please feel free to let me know.
    Have a nice day!


    Helen Zhao [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Helen Zhao Wednesday, March 7, 2012 1:41 AM
    Thursday, March 1, 2012 5:59 AM

All replies

  • It is only possible to add a windows form to a project of type Windows Forms or a .net managed class library.  If your project is an unmanaged C++ DLL project, then you can only create windows in an unmanaged way, i. e. the usual Win32 API way, such as adding a new dialog box as a resource, or simply using RegisterClassEx() and CreateWindowEx() to create the window yourself, then pump messages for those windows using GetMessage(), TranslateMessage() and DispatchMessage().


    Jose R. MCP

    • Marked as answer by Helen Zhao Wednesday, March 7, 2012 2:07 AM
    Tuesday, February 28, 2012 5:19 PM
  • Hi Aragorn_29,

    As far as I know, we can add a form or dialog into a DLL.
    About adding a windows form into a DLL, please refer to the following steps:
    1->Create a CLR class library project.
    2->Add a new windows form into it. Make it as a public class.
    3->Build the application. Then you will see a DLL in the solution directory.

    About adding a dialog resource into a DLL, I suggest you refer to these steps:
    1->Create a MFC DLL, and choose "Regular DLL using Share MFC DLL" option.
    2->Right click the project name in Solution Explorer, and then add a new MFC class whose base class is CDialog.
    3->Right click the project name in Solution Explorer again, and choose Class Wizard to add some methods, member variables or messages for the new dialog class.
    4->Build the application.

    I hope you can get useful information from this reply. If you have any questions, please feel free to let me know.
    Have a nice day!


    Helen Zhao [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Helen Zhao Wednesday, March 7, 2012 1:41 AM
    Thursday, March 1, 2012 5:59 AM
  • Hi,

    I have created CLR  Class Library project and added the Windows Form class to the project and the output as dll. How can i access/invoke the form from my atl project. Please help me.

    Wednesday, October 24, 2012 1:21 PM