473,594 Members | 2,770 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Dec 13 '07 #1
4 4442
Lester,

You probably want to use the WindowInteropHe lper class:

http://msdn2.microsoft.com/en-us/lib...rophelper.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]
- mv*@spam.guard. caspershouse.co m

"Lester" <lk****@gmail.c omwrote in message
news:22******** *************** ***********@a35 g2000prf.google groups.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
Dec 13 '07 #2
With WindowInteropHe lper, 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]"
<m...@spam.guar d.caspershouse. comwrote:
Lester,

You probably want to use the WindowInteropHe lper class:

http://msdn2.microsoft.com/en-us/lib....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.c om
Dec 13 '07 #3
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]
- mv*@spam.guard. caspershouse.co m
"Lester" <lk****@gmail.c omwrote in message
news:94******** *************** ***********@d4g 2000prg.googleg roups.com...
With WindowInteropHe lper, 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]"
<m...@spam.guar d.caspershouse. comwrote:
>Lester,

You probably want to use the WindowInteropHe lper class:

http://msdn2.microsoft.com/en-us/lib....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.c om
Dec 13 '07 #4
Sorry, that should be "extended window style", not "extended window
handle".
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omwrote in
message news:DB******** *************** ***********@mic rosoft.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]
- mv*@spam.guard. caspershouse.co m
"Lester" <lk****@gmail.c omwrote in message
news:94******** *************** ***********@d4g 2000prg.googleg roups.com...
>With WindowInteropHe lper, 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]"
<m...@spam.gua rd.caspershouse .comwrote:
>>Lester,

You probably want to use the WindowInteropHe lper class:

http://msdn2.microsoft.com/en-us/lib....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.c om
Dec 14 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
445
by: RobJUK66 | last post by:
have a 3rd party .Net dll that wraps a set of further unmanaged dll's. The ..Net DLL basically uses pinvoke to wrap the calls. The low level dlls provide an API to talk to a complex device which appears as a USB hub (with a scanner, flash drive and some other bits and pieces). Using a VB.Net windows app, we call the main unmanaged API function (lets call it doStuff() ) and then call messagebox.show to pop up a modal results dialog. This...
4
10001
by: Paul Aspinall | last post by:
Can anyone advise how to display a form on top, and modal, without using ShowDialog?? Thanks
2
2550
by: cassidyc | last post by:
Hi, I was wondering if anyone has come accross this issue? And if they have any solutions I have that can create new copies of itself Form1 as = new form1(); af.show(); This form can also bring up a modal dialog (MessageBox)
10
2743
by: Guadala Harry | last post by:
I have a modal dialog that currently does all of the following except item 4. 1. lets users select a graphic from a list of thumbnails (and when selected, displays the full-size image in a preview DIV) 2. when users close the dialog, the application receives the URL to the selected graphic. 3. the modal dialog lets the users upload a new graphic if the dialog does not present them with one they are already happy with. 4. upon uploading...
1
355
by: Ganesh Ramamurthy | last post by:
Hi Experts, I am having a serious problem now. I am using IE for developing my asp.net application. My application need not run in Netscape. I have a peculiar problem. I have an aspx page from which when the user clicks on the save button, I am calling a javascript function which shows up a modal dialog box. I want the user to do certain varifications before the save. Inside the modal dialog, I have a datagrid which has a template...
1
1276
by: Lance | last post by:
I want to prevent a form from closing when the user clicks the form's Close button in the form's ControlBox (i.e., the button with the "X" in the upper-right corner of the form). Instead, I just want to hide the form. My idea is to do something like the following Protected Overrides Sub OnClosing(ByVal e As System.ComponentModel.CancelEventArgs e.Cancel = Tru MyBase.OnClosing(e Me.Visible = Fals End Su This technique seems to work...
4
9486
by: mpreston | last post by:
I'm following the example from the MSDN library on how to create modal dialog boxes in C#, but something isn't working properly. If I create a modal dialog box and show it using ShowDialog(), the main form behind the dialog box is still enabled and can operate normally. If I use MessageBox.Show() to show a message box, the main form is disabled until the dialog box terminates. How can I make a custom dialog box do this?
4
2892
by: Johnny Jörgensen | last post by:
In my current project I've got some DataGridViews containing multiple hidden columns. For some reason 8 of the 10 grids I've got on my form has suddenly started showing 1 of the hidden columns (not all of them). If I look at the grids in the designer, the columns ARE invisible, but still they're shown at runtime. I cannot figure out why. I've searched the entire project to see if I could find any code setting the columns visible, but...
2
3494
by: diogenes | last post by:
I have created many shortcut/popup (aka context, or right-click) menus for my application - instead of toolbars or standard drop-down menus. Within my custom menu, I am using =ShowMainMenu("item") in the On Action event where ShowMainMenu is a public function in frmMain, and "item" is a string mapping to a button click event. (error trapping omitted) Public Function ShowMainMenu(strItem As String) As Boolean
0
7874
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
7997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6646
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5738
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5402
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3853
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1469
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1203
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.