Question about showing a form from unmanaged code

T

Tao

hi.. Group

Some unmanaged code invokes my code to show a form.

If I use ShowDialog() to show the form, form shows but main application
stops running. If I use Show() to show the form, main application runs but
my form does not get shown.


Does anyone have experience on how to handle this? Thanks
 
B

Ben Voigt

Tao said:
hi.. Group

Some unmanaged code invokes my code to show a form.

If I use ShowDialog() to show the form, form shows but main application
stops running. If I use Show() to show the form, main application runs but
my form does not get shown.


Does anyone have experience on how to handle this? Thanks

You need a message loop. If the main application does not provide one, you
will have to start one on a new thread. Your windows would then have to be
created from that thread as well.

Since COM objects, DDE, etc also require a message loop or work properly,
most applications do provide one.
 
G

Guest

Thanks Ben,

I am pretty new in this area, could you please point me some sample on how
to create a "message loop"?

My form is written in C# and a C++ component calls the form.

thanks again for your help.
 
B

Ben Voigt

Tao said:
Thanks Ben,

I am pretty new in this area, could you please point me some sample on how
to create a "message loop"?

My form is written in C# and a C++ component calls the form.

Is the C++ component your code? If so, what framework is it using if any
(MFC, WinForms, ATL, WTL, etc)?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top