When I set the main window's visibility to hidden, No icon is shown in taskbar, so I have no control over the window to show it again. I want for the application's icon to be visible even when I hide the window, and to show the window when I click it's button in the taskbar. (something like minimize behavior)
How can I achieve that using WPF and .Net 4.0 in C#?
Edit: I mean the icon in taskbar (usually in the left and middle of the horizontal taskbar) not the notifyicon in system tray.
So, based on "comments" section, what you are looking to do is minimize or hide a window but still show some windows or dialogues that the window opens. First if you want to keep your window in the task bar, you should minimize with:
this.WindowState = WindowState.Minimized
That can be called from anywhere within the form. As you mentioned, though, this will close hide any dialogues that have this window set as the parent. The key, then is to not use this window as the parent. Lets say your dialogues inherit from form. You want to use:
newWindow.Show();
I am guessing that you are calling "ShowDialog", which ties the window state to the parent window state. Try this out and hopefully it will help!
Edit
One more note: the same is actually true of MessageBoxes, but the way to control the parent form is with the first parameter of the MessageBox.Show() call. If you pass in a form as the first parameter, that will be the parent, otherwise the parent will not be set.
Related
I have a main WPF window. (henceforth, parent window). In this parent window I have a button. When button is clicked I open a custom messagebox window (henceforth, child window) in a position within parent window. When opening child window I pass as an argument the parent window, and another argument to indicate the child window where I want to locate it. Then within child window, according these parameters passed as arguments, I do some calculations based on the Top and Left coordinates of the parent Window.
I have seen that when parent window is maximized, then its Top and Left coordinates are not being updated, they are the same, I mean they keep unchanged keeping last values before parent window is maximized. Why?
As a result of this, when doing some calculations using Parent.Top and Parent.Left from child window, it is making my logic failing.
How can I obtain correct Parent.Top, Parent.Left and others like Parent.Height and Parent.Width from child window logic?
I use Visual Studio 2008 and NET 3.5 SP1.
I have created a window in C# by win api. And made it as child to another window. This parent window is an external program and I don't know its source code.
When i move my window inside parent window some parent's elements draw itself on my window.
For, better understanding i've made some screens.
This is before I move my window. My window is gray.
And this one is after moving my window over the "SeatOpen" button.
I have no idea how parent window can draw on my window.
So, why this is happening and how to fix?
The parent window is not drawing on your window... you are failing to draw on your window yourself -- your window is not responding to WM_PAINT messages for some reason so whatever garbage was on the screen remains there.
Try to redraw your window when location is changed and it is over Seat Open button.
I have a parent form and some child forms. Each of the child form has an icon at the top and left of the form. I would like to discard those icons but when I click on the icon property, I can only browse another icon and not delete the existing one. For that reason I set the showIcon property in each child form to false and the icons are not visible any more on the forms. So far so good.
My problem is that when a child form is open and maximized, the icon is shown. I want to make it go away and unfortunately I didn't find a way to do this. Any suggestions?
Thanks!
EDIT: I added a screenshot of the form, the unwanted icon is shown above menu strip. I want it to go away. When child form is NOT maximized, the icon disappears.
I guess you need to create a custom form border.
Please check http://geekswithblogs.net/kobush/articles/CustomBorderForms3.aspx
If I have a XAML window that I show with ShowDialog, is there a way to make it (not) appear in the taskbar?
The problem is that I can set the window to be topmost but if that window opens another dialog and I set that also to be topmost, I can put the second behind the first by clicking in the taskbar. This tends to confuse users.
In your child window, set the ShowInTaskbar property to false.
The Splashscreen/Loading-Window in my WPF application is set to Topmost="True". Now this windows in on top of all other windows even when you switch to another application (because loading will take some time). I don't want this kind of behavior.
If I set Topmost="False" the window in not topmost at all. But If you switch back to my application after working with with another application my customers sometimes don't realize the Loading-Windows is still working. The application appears to be unresponsive because the Loading-Window in the background is still the active window and it is modal.
I want to have the Loading-Window topmost but only if my application is in foreground. If you switch to another program the window should disappear and reappear topmost when you switch back.
You can try to use the "Owner" property of the window, with that the splash screen will always overlap the other windows.
I think maybe a change in the loading pattern of your MainWindow might help. If you can put to time consuming part of loading the window on a background thread then you can take this path:
Show MainWindow empty or bare bones (empty fields/grid etc)
Launch async load method to get data and populate main window
Create splash screen, set owner to self and show
make sure to close splash screen when load is complete.
that should keep the splash on top while load is being processed.
To clarify I will reanswer this question:
Martin Moser's answer is the correct one.
Set the owner property like:
secondarywindow.Owner = parent;
AND set TopMost to false.