 |
|
|
|
| Author |
Message |
Lester
Joined: 13 Dec 2007 Posts: 2
|
Posted: Wed Dec 12, 2007 10:23 pm Post subject: Problems with modal dialog when calling C# from C++ |
|
|
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
Archived from group: microsoft>public>dotnet>languages>csharp |
|
| Back to top |
|
 |
Nicholas Paldino [.NET/C#
Joined: 08 Aug 2007 Posts: 71
|
Posted: Thu Dec 13, 2007 3:33 pm Post subject: Re: Problems with modal dialog when calling C# from C++ |
|
|
Lester,
You probably want to use the WindowInteropHelper class:
http://msdn2.microsoft.com/en-us/library/system.windows.interop.windowinterophelper.aspx
Once you pass the instance of your Window that you want to show, you can
use the Handle and Owner properties to set the owner of the window, and to
get the handle to work with.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
"Lester" wrote in message @a35g2000prf.googlegroups.com...
>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 |
|
| Back to top |
|
 |
Lester
Joined: 13 Dec 2007 Posts: 2
|
Posted: Thu Dec 13, 2007 3:37 pm Post subject: Re: Problems with modal dialog when calling C# from C++ |
|
|
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
On Dec 13, 7:33 am, "Nicholas Paldino [.NET/C# MVP]"
wrote:
> Lester,
>
> You probably want to use the WindowInteropHelper class:
>
> http://msdn2.microsoft.com/en-us/library/system.windows.interop.windo...
>
> Once you pass the instance of your Window that you want to show, you can
> use the Handle and Owner properties to set the owner of the window, and to
> get the handle to work with.
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - m...@spam.guard.caspershouse.com
> |
|
| Back to top |
|
 |
Nicholas Paldino [.NET/C#
Joined: 08 Aug 2007 Posts: 71
|
Posted: Thu Dec 13, 2007 7:49 pm Post subject: Re: Problems with modal dialog when calling C# from C++ |
|
|
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]
- mvp@spam.guard.caspershouse.com
"Lester" wrote in message @d4g2000prg.googlegroups.com...
> 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
>
> On Dec 13, 7:33 am, "Nicholas Paldino [.NET/C# MVP]"
> wrote:
>> Lester,
>>
>> You probably want to use the WindowInteropHelper class:
>>
>> http://msdn2.microsoft.com/en-us/library/system.windows.interop.windo...
>>
>> Once you pass the instance of your Window that you want to show, you
>> can
>> use the Handle and Owner properties to set the owner of the window, and
>> to
>> get the handle to work with.
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - m...@spam.guard.caspershouse.com
>> |
|
| Back to top |
|
 |
Nicholas Paldino [.NET/C#
Joined: 08 Aug 2007 Posts: 71
|
Posted: Fri Dec 14, 2007 1:59 am Post subject: Re: Problems with modal dialog when calling C# from C++ |
|
|
Sorry, that should be "extended window style", not "extended window
handle".
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
"Nicholas Paldino [.NET/C# MVP]" wrote in
message @microsoft.com...
> 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]
> - mvp@spam.guard.caspershouse.com
>
>
> "Lester" wrote in message
> @d4g2000prg.googlegroups.com...
>> 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
>>
>> On Dec 13, 7:33 am, "Nicholas Paldino [.NET/C# MVP]"
>> wrote:
>>> Lester,
>>>
>>> You probably want to use the WindowInteropHelper class:
>>>
>>> http://msdn2.microsoft.com/en-us/library/system.windows.interop.windo...
>>>
>>> Once you pass the instance of your Window that you want to show, you
>>> can
>>> use the Handle and Owner properties to set the owner of the window, and
>>> to
>>> get the handle to work with.
>>>
>>> --
>>> - Nicholas Paldino [.NET/C# MVP]
>>> - m...@spam.guard.caspershouse.com
>>>
>
|
|
| Back to top |
|
 |
|
|
| Related Topics: | How to get the current running modal dialog of my applicatio I have shown a modal dialog, it works well commonly. But when I watch programs from ¡°Running Program List¡± panel, with the modal dialog shown, there are two program names listed for the application. One is the title of the main form; another is the titl
Problems with calling an external dll Can anyone see why this causes a I can't figure out what I'm doing wrong, please can somebody help me???.... Here is my code
Problem opening several modal forms Hello My application opens several modal forms (the modal Form1 opens the modal Form2 that opens the modal Form3 and so on), but, the third and the successives modal forms.... are not modal!!! Seems that there's a maximum number of modal forms, is it poss
Trying to Display a non-modal VB6 Form of an AcitveX DLL in Hallo NG, I'm trying to Display a VB6 6 of an ActiveX DLL in c Sharp. I use therefore the SetParent API function. After this function call I get always the error message "Non-modal forms cannot be displayed in this host application from an ActiveX DLL, Ac
Error interoping with non-modal forms Here's what I'm trying to do: I have a .NET app (exe) that's instantiating a COM dll's object. That COM object, in turn, loads and displays a VB6 form, non- modally. When running this code through VB6's IDE, it works fine. When trying to run it throug |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|