How to detect which Window was selected when using Aero peek - wpf

I am not even sure how to ask this question...
I have a WPF app with a main window in full screen. It launches new windows in full screen and makes them a child of the main window upon some user interactions. If the user's machine only has a single monitor this child window is supposed to be the focus until closed. However, I have found that using Windows Aero if the user hovers over my application's taskbar icon a preview of both windows appear. This in itself is not an issue except if you try to select the main window of the app nothing happens because the child window is always on top but the peek functionality gives the illusion that the user can switch to the main window and it looks like a bug.
I would like to detect which window the user is selecting and, if it is the main window, simply close the child window. Alternatively I would like Aero to stop showing multiple windows if only one will work.
Anyone had any experience with this?

Related

wpf window.open, hide window when main view clicked

I am new to WPF and have two windows in a solution. Both are opened using Window.Open().
However there is a difference in behaviour that I don't understand. When one of the windows is opened, if you click the view that launched it the new window is minimised behind the main view, so you can interact with it.
The other window, when opened and you click the main view stays where it is and does not get hidden.
How can I get this window to show the same behaviour as the first?
I figured this out, by removing the parent child relationship in the window I was able to get the functionality I desired.

Custom Window Bar

I'm not sure that's the right way to say it, but what I want is to for my wpf main window to have it's own bar that will behave like a taskbar, and any children windows that will be open from the main one will be placed in that bar in a similar way like the taskbar works in windows - a rectangle showing the window name for example, on click it opens you the window, if you click minimize it will minimize it to the bar, and with some option, to get it out of the main window and move it to the real windows taskbar, with another option for putting it back in. The problem is I don't know if this is even possible, and I don't know the name of such an element, so if anyone can give me any tips I'll be really thankful.
I worked on an application years ago (.NET 3.0: first WPF release!) that did exactly that. We ran into a lot of issues getting it to work, but we were pretty successful in the end. One thing we didn't support was moving it to the Windows taskbar.
The best option would be to set an attached property on each Window. This would register a Window with your custom taskbar, so if you wanted to move the Window out of your custom bar, you'd set the property to false. Setting the property to true would add it to the collection of application windows, as well as register event handlers to track the state of the Window.
One of the major pain points for us was getting the Window animations correct. If you're not running in XP, this probably less of an issue, as the animations in Vista (or is it 7?) and above aren't really showing where a Window is going on minimize. In the end, we had to do a lot of low level Win32 (p/Invoke) work for this.
Take a look at AvalonDock and WPF MDI:
http://avalondock.codeplex.com/
http://wpfmdi.codeplex.com/

WPF Window that only shows in TaskBar

I'm not sure if what I want to do is appropriate, so I'll explain a little.
We've got a large application that takes a while to load. So we have a splash screen.
The Splash screen causes excessive load time on Remote Desktop (terminal server).
So to alleviate this, we want to hide the splash screen when loading on RDP.
But we still need to at least show the user that the application is loading.
So, I was thinking perhaps just show something in the Taskbar (not the system tray), as it will disappear once the application is fully loaded (and be replaced by the main form's Task icon).
However any WPF solution I've looked at, requires a visible form/window to go with the Taskbar status.
Is there any way of showing something in the Taskbar without showing a WPF window?
Or is there another way of showing application load status without something on the screen?
We had same problem.
On remote desktop, we did following steps...
We configured the Splash window to not allow resizing and have only Minimize and Close button.
We removed WindowStyle=None setting so that title bar of the Splash window appeared
We made the Splash window's width and height zero. This way all you see on screen is a small blue rectangle of the title bar with Text "Loading... Please Wait ..." and minimize and Close button.
We used Window's kernel calls to disable title bar's Close button too. This way user was not able to cancel the Splash window.
So all a user could do is to minimize or restore from taskbar.
When restored, all he sees is a title bar's blue rectangle with "Loading..." text. This way the window also claimed its place on the task bar but hid its splash animation and user is also aware that the splash screen is loading. For this you can also update the Title bar's text by appending more fullstops ...
Loading. Please Wait..
Loading. Please Wait...
Loading. Please Wait....
Loading. Please Wait..
I do think you need to look into the root cause of your issue. Possibly looking at threading and parallelism.
However, a simple solution to what you are asking would be to just create a hidden window. One that is transparent, no borders or anything. It could even bet set to a size of 0, 0. That way you would be able to get the taskbar item that you require.

Keep ncurses window on foreground

My application is using ncurses and has several windows that are continuously being updated.
In that application I have one window acting as a 'message box' (e.g. dialog) showing up when the user hits 'q', asking them if they want to shutdown. This works fine until the other windows are updated. At that point the other windows will be drawn over the dialog box making it (partly) invisible.
Calling wrefresh() on the dialog's window doesn't seem to help. How do I force the window to be on the foreground?
I had been reading manual pages all day, couldn't find anything. And of course, 5 minutes after asking my question I found the solution:
redrawwin(dialog_window);
wrefresh(dialog_window);
My dialog now stays on the foreground.

Tray Icons Keep On Popping Up

I have a WinForm program that checks a database for changes, and if there are any, it will open another WinForm telling the user what is happening (the popup WinForm has some special functionality making a MessageBox insufficient for this task). Each time one of these popup WinForms shows up, a new icon shows up in the system tray and does not go away even if you hover over it (this isn't a tray refresh issue).
What I'm wondering is how to get the popup WinForm to display no tray icon at all.
You might be doing something like 'new NotifyIcon' in the wrong places (like the constructor of your popup-form). It gets created, but if you never call NotifyIcon.Dispose() it will stay until you stop your program and hover you mouse over the icon.
Another cause might be that you have added the NotifyIcon as a component to the popup-form in the designer.

Resources