How do I launch a winforms form from a DLL correctly?
Posted
by rodent31337
on Stack Overflow
See other posts from Stack Overflow
or by rodent31337
Published on 2010-05-26T16:33:03Z
Indexed on
2010/05/27
23:41 UTC
Read the original article
Hit count: 187
There's another question similar to mine, but I wanted to gather some specifics:
I want to create a DLL that is called from unmanaged code. When the unmanaged functions are called in the DLL, I want to collect information and show it in a kind of form.
What I'd like to do is, when DllMain() is called, and the reason is DLL_PROCESS_ATTACH, I would like to instantiate a form. This form should be run on a separate thread. When my function FOO() inside my DLL is called, I would like to take the information from FOO(), dispatch it to the form for rendering.
So, more specifically:
i) What is the proper way to create a DLL project and have the ability to have Windows forms created in the designer be available to the DLL?
ii) What is the correct way to give this form its own thread and message processing loop?
iii) How do I dispatch information from the unmanaged DLL functions to the form, or, alternatively a managed class that can update its own state and the form?
The form inside the DLL is sort of a "monitor" for data passing in and out of the DLL, so I can keep track of errors/bugs, but not change the core functionality of the DLL functions that are available.
© Stack Overflow or respective owner