 |
|
|
 |
|
 |
I needed something like this, but I ran into a problem when I connected a second monitor - if you use Screen.PrimaryScreen the full screen image will always come up on - yes - the primary screen. I wanted to display a jpg inage full screen in a form. To make the image come up on the same monitor as the application, I passed the application's main form in to the image form's constructor as 'parent', like this:
public partial class FullScreenImage : Form
{
public FullScreenImage(Form parent)
{
foreach (Screen screen in Screen.AllScreens)
{
if (screen.Bounds.Contains(parent.Location))
{
this.Location = new Point(screen.Bounds.X, screen.Bounds.Y);
this.Width = screen.Bounds.Width;
this.Height = screen.Bounds.Height;
break;
}
}
Dave
|
|
|
|
 |
|
 |
FormWindowState.Maximized doesn't work in some cases if we want to cover the whole screen.
To cover whole screen I use Bounds of the screen -->
public partial class Form1 : Form
{
FormBorderStyle _borderStyle;
Rectangle _bounds;
bool _topMost;
bool _fullScreen = false;
public void DoFullScreen(bool fullScreen)
{
if (fullScreen == _fullScreen)
{
return; // Nothing to do
}
// update state flag
_fullScreen = fullScreen;
if (!fullScreen)
{
// restore previous settings
this.FormBorderStyle = _borderStyle;
this.Bounds = _bounds;
this.TopMost = _topMost;
}
else
{
// Save current settings
_borderStyle = this.FormBorderStyle;
_bounds = this.Bounds;
_topMost = this.TopMost;
// full screen
this.FormBorderStyle = FormBorderStyle.None;
Screen screen = Screen.FromControl(this); // get screen for form
this.Bounds = screen.Bounds;
this.TopMost = true;
}
}
}
Note: This solution has an issue: when a form was maximized before full screen, after exit from full screen it is restores previous state but when you click Restore Down (to Normal) system button, form will restore last bounds (full screen). I'll find solution for ths case later
modified on Monday, November 9, 2009 10:28 AM
|
|
|
|
 |
|
 |
Hi
This code works much better (had problems with the code in the article).
I rewrote it a bit so it's a property (which i find somewhat cleaner and allows F11 code like: FullScreen=!FullScreen).
private Boolean fFullScreen = false;
private FormBorderStyle _borderStyle;
private Rectangle _bounds;
private bool _topMost;
wvd_vegt
|
|
|
|
 |
|
 |
this article provides an overcomplicated alternative to a feature that's built into the framework. There's no need for it.
|
|
|
|
 |
|
 |
Hello,
Thanks for the efforts, but there is already a property inside the .net framework to do this:
this.WindowState = FormWindowState.Maximized;
just register the Keyup event and play with FormWindowState Enum.
Thanks.
Thank You
|
|
|
|
 |
|
 |
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
this.FormBorderStyle = FormBorderStyle.Sizable;
this.WindowState = FormWindowState.Maximized;
|
|
|
|
 |
|
 |
This indeed covers the whole screen when needed!
|
|
|
|
 |
|
 |
Whenever I go from one form to another, the form does take the full screen. The problem is that the top bar of the form that is being opened flashes (disappears and come back). You can notice that if you really watch the other form while it's being loaded.
I did lot of search about this issue. I noticed that it has been posted as a bug in compact framework 2.0. By the way, I never had that issue in compact framework 1.0 Visual Studio 2003. I only noticed it in compact framework 2.0 Visual Studio 2005.
I'm wondering if there is a way to work around it.
|
|
|
|
 |
|
 |
I was hoping this was exactly what I was looking for. However when I engage your "fullscreen" mode, the Start menu still shows up. I'd like the window to cover the whole screen. A way to do that? I'll play with it a bit and see if I can figure it out. Thanks though!
|
|
|
|
 |
|
 |
uh, like, yeah. it's not full screen.
|
|
|
|
 |
|
 |
hmm.. sigh..
found a bug or maybe i am not doing it right.
i have an MDI form, the new maximized form only max up to its parent window.
hmm. guess i'll try modal forms then. still looking for alternative.
|
|
|
|
 |
|
 |
GOT it! =) this.topmost = true;
|
|
|
|
 |
|
 |
Thanks all - works fine in 2005 as well.
|
|
|
|
 |
|
 |
Hello ;
It's good your code...
But, if I do second once(I press on F11 for second once), it generates an exeption !!!
|
|
|
|
 |
|
 |
Surprised the author never responded to, or fixed this. If you study the code for a minute, you'll quickly see that he forgot to set the '_bFullScreenMode = false;' in the else block of Form1_KeyUp(). Do that and you're good to go pressing F11 to your hearts content.
|
|
|
|
 |
|
 |
It throws nullref exceptions alot... and why not instead of displaying a whole differnt form, just change the settigns of the original for?
And this isn't really worthy of an article. All it is doing is explaing a very simple topic... but... whatever floats your boat.
/\ |_ E X E GG
|
|
|
|
 |
|
 |
Changing the original form is not a good idea because a form usually has many controls on it. And you might have to write a lot of resizing code.
You are right that this is a very simple topic - I wanted to demonstrate the use of the Owner property - which not many people are aware of.
|
|
|
|
 |
|
 |
slingman wrote:
you might have to write a lot of resizing code.
Why don't you just spend like 10 minutes and do (code free) it in your IDE? Unless your badass and doing your program by hand....
/\ |_ E X E GG
|
|
|
|
 |
|
 |
I think you are still not getting it. Let's say you have a form with all controls laid out on the form using the IDE. Now, you need to go into a full screen mode, you can change the WindowState of your mainform to Maximized, when your app is maximized, your controls might not be positioned right, unless you already have re-positioning code in your OnSize method.
What I am really trying to do here is to offer a simple solution for having an application go into a fullscreen mode.
Peace!
|
|
|
|
 |
|
 |
Why don't you just anchor the controls in the desgner?
/\ |_ E X E GG
|
|
|
|
 |