Problems with modal dialog when calling C# from C++

L

Lester

I have main application (with main window) created in C++/MFC. From
there I call function in C# class library to display a modal WPF
dialog. Dialog shows up OK, but it doesn't behave really modal. While
it is not possible to go to the main window by clicking directly on it
(dialog keeps focus), the application shows twice in the taskbar (1
entry for main window, 1 entry for the WPF dialog). Through the
taskbar I can switch to main window and even though it behaves
disabled, this definitely doesn't look profesional. The application is
supposed to show up in the taskbar only once.

I tried to pass from C++ a window handle to C#, using it to construct
NativeWindow and pass it as an owner, however, Window.Owner doesn't
accept NativeWindow type.

Any ideas how to make this work?

Thank you,

LK
 
L

Lester

With WindowInteropHelper, it is not possible to get the focus back on
the parent (C++) window. However, both windows (parent C++ and child
C# WPF dialog) still show in the taskbar.

Is there any way to remove WPF dialog from the taskbar, or prevent it
from showing up there?

Thank you,

Lester
 
N

Nicholas Paldino [.NET/C# MVP]

Lester,

With the window handle, you will have to make it so that the extended
window handle does not have the WS_EX_APPWINDOW bit set, so that it doesn't
appear in the taskbar.

Or, you could create a .NET form, host the WPF control in that, and then
set the ShowInTaskbar property of the form to false.
 
N

Nicholas Paldino [.NET/C# MVP]

Sorry, that should be "extended window style", not "extended window
handle".


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Nicholas Paldino said:
Lester,

With the window handle, you will have to make it so that the extended
window handle does not have the WS_EX_APPWINDOW bit set, so that it
doesn't appear in the taskbar.

Or, you could create a .NET form, host the WPF control in that, and
then set the ShowInTaskbar property of the form to false.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Lester said:
With WindowInteropHelper, it is not possible to get the focus back on
the parent (C++) window. However, both windows (parent C++ and child
C# WPF dialog) still show in the taskbar.

Is there any way to remove WPF dialog from the taskbar, or prevent it
from showing up there?

Thank you,

Lester
 

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