Right clicking on form opens the System Menu (Close, Minimize, etc.) - c#

I have a WPF window with WindowStyle="None" and ResizeMode="CanResizeWithGrip" and when I rightclick somewhere on the form, I get this showing up (I forgot what the control itself is called..)
The control which asks me if I want to Move, Size, Minimize, Maximize or close the window.. I'm wondering how I can get rid of this.
Any ideas?

Related

WPF: open a window in maximized state from the start

I want to open a window in WPF that is already maximized as soon as it is visible.
I tried the obvious:
<Window Title="My window" WindowState="Maximized" ...>
...
</Window>
however, if I do this the window doesn't open maximized. It opens at its default size and then, half a second later, gets maximized. Is there a way to bypass this and open the window maximized from the start?
EDIT: not a duplicate of the linked question, I'm doing it the same way as the accepted answer there. My problem isn't that it doesn't work, the problem is that it doesn't work "fast enough": with that solution the window opens not maximized and then gets maximized a split second later. I want to know if there's a way to open it ALREADY maximized.
How you open the window ?
Try this.
win1 = new Window1();
win1.Show();
win1.WindowState = WindowState.Maximized;

Show icon in taskbar for hidden windows

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.

Only show X and minimize button on wpf

I don’t want the user to resize the window so I did ResizeMode="NoResize". But then the minimize button also disappears and only the X button is visible. Is there a way to keep the minimize button?
WPF Windows Overview. ResizeMode="CanMinimize"

How to bring up a message popup in C#?

Most recently, while at my mom's house, a phone call came in and the caller ID popped up in a banner on her TV (Comcast). I've seen a similar functionality when the McAfee brings up a virus warning. It was a translucent popup window with the company logo, message and a button or two.
I'd like to mimic this behavior (via C#). This will event driven. My experience in C# is pretty limited, so I'm still feeling out the different libraries. Are there any ideas on where I should start?
I recommended to use WPF. Create new window, that will popup and set next properties:
WindowStyle="None"
AllowsTransparency="True"
Opacity="0.5" //50% transparent
Topmost="True"
Background property will set color of window.
Place on window any controls what you need.
Create this window and show when some event happens:
YourWindow popup = new YourWindow(/*possible args for message on popup, for example*/);
popup.Show();
To place your window in bottom-right corner, as all popups, use next code in windows Loaded event:
this.Left = SystemParameters.WorkArea.Width - this.Width;
this.Top = SystemParameters.WorkArea.Height - this.Height;
How to make animation of window movement you can read in other questions.
If your app is running in the background, you can simply pop up a window and set it to topmost.
Exactly what you do beyond that is going to depend on what type of UI are using (WPF/WinForms.) WPF makes it easier to build a transparent form, as described here:
http://blogs.interknowlogy.com/2007/06/20/transparent-windows-in-wpf-2/
Transparency in WinForms is a little bit harder, but there are some posts about it:
Partial transparency with C# .NET 3.5 WinForms?
A couple of things you will want to do with your pop-up window:
Disable the minimize/maximize/close buttons
Disable the borders
Just put those in your form so it looks better.
-- Dan

Non-resizable windows with windowStyle=None

Basically, I want to create a window that looks like the following:
alt text http://www.thex9.net/screenshots/2009-10-15_1347.png
However, the window shouldn't be resizable (the one in the screenshot is) but must retain the glass border. The XAML for the window in the screenshot is as follows:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="WpfApplication1.MainWindow"
x:Name="Window" Title="MainWindow" WindowStyle="None">
<Grid x:Name="LayoutRoot"/>
</Window>
Is it possible to create a window which looks similar to the one in my screenshot but is not resizable? Any help would be very much appreciated.
Probably you can get desired result by:
ResizeMode=
XAML object property which can take have following states:
NoResize - A window cannot be resized. The Minimize and Maximize buttons are not displayed in the title bar.
CanMinimize - A window can only be minimized and restored. The Minimize and Maximize buttons are both shown, but only the Minimize button is enabled.
CanResize - A window can be resized. The Minimize and Maximize buttons are both shown and enabled.
CanResizeWithGrip - A window can be resized. The Minimize and Maximize buttons are both shown and enabled. A resize grip appears in the bottom-right corner of the window.
One way to accomplish a fixed size Window while retaining the border is to set the Min[Width|Height] and Max[Width|Height] properties to be the same value. The border will still show the resize cursor, but the user will not be able to change the size of the Window.
If the fact that the border still indicates that it's resizable bothers you, the next step is to set the ResizeMode="NoResize", but then you have to start drawing your own Aero glass if you want to retain the glass edges.

Categories