Sign in to follow this  
NexusOne

[.net] How do i make a fullscreen window??

Recommended Posts

I'm having a world of trouble getting my Form to be fullscreen. I mean FULLSCREEN, not just maximized. I said WindowState = FormWindowState.Maximized and FormBorderstyle = FormBorderstyle.None but nothing seems to be able to hide the taskbar, which is always on top of my window no matter what; how can I get rid of it??

Share this post


Link to post
Share on other sites
You might have to PInvoke the Win32 functions that do this for you, or DirectX might well provide a method for it, if you're using that.

Share this post


Link to post
Share on other sites
No I'm not using DirectX or any other graphics APIs. I'm sure somewhere in .Net there must be a way to make a window fullscreen!

Share this post


Link to post
Share on other sites
Does the order in which you set those two properties matter?

I would imagine that setting the Borderstyle first then maximising should get it to work..

Otherwise, just set those during design time... That's always worked for me.

Share this post


Link to post
Share on other sites
I think the problem is because Maximized will set the window to the size of the screen, minus any toolbars. You need to get a way to draw over the toolbars, or a way to get rid of them.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You can create a "fake" fullscreen window getting information of the screen size, and positioning it manually.

In VB would be something like this:

Dim scrSize as Rectangle = Screen.PrimaryScreen.Bounds

Me.FormBorderstyle = FormBorderstyle.None
Me.TopMost = True
Me.StartPosition = FormStartPosition.Manual
Me.ClientSize = New Size(scrSize.Width, scrSize.Height)
Me.Location = New Point(0, 0)

Hope it helps...

Share this post


Link to post
Share on other sites
OK, I added TopMost = true, but it didn't help.

I also checked and the height I got from Screen.PrimaryScreen.Bounds really is the correct height of the screen, it doesn't leave out the toolbars (it's 768, which is correct for my screen).

all of this code seems to make it fullscreen-except-for-the-taskbar, and it also somehow breaks the refreshing of the window:

//"width" and "height" are correct
this.Size = new System.Drawing.Size(width, height);
this.Setstyle(Controlstyles.DoubleBuffer | Controlstyles.UserPaint |
Controlstyles.AllPaintingInWmPaint | Controlstyles.FixedWidth |
Controlstyles.FixedHeight, true);
this.Updatestyles();
this.FormBorderstyle = FormBorderstyle.None;
this.TopMost = true;
this.StartPosition = FormStartPosition.CenterScreen;
this.WindowState = FormWindowState.Maximized;
this.ClientSize = new System.Drawing.Size(width, height);
this.Location = this.DesktopLocation = new System.Drawing.Point(0, 0);

so apparently something is still missing- the window, which refreshes properly when not fullscreen, stops refreshing when it's set to be fullscreen. But the main problem is that the taskbar is still visible, even with all this code.

Share this post


Link to post
Share on other sites
Ok, its Win32 but I think this is the best shot unless someone knows for sure:
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=01

Ignore the OpenGL stuff and just focus on the Win32 calls. If I remember right, if you remove all the calls to OpenGL you still get a fullscreen window, meaning its done by Win32 (you can likely do it too then).

Sorry just seemed few others had answers. Can I ask why you want to do this? It would hide the menu also I do believe.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You shouldn't user WindowState = FormWindowState.Maximized.

Just leave a normal window. If you set the window to a maximized state, it doesn´t matter which size you set to the window, because the window will be _MAXIMIZED_, that is, using all the WorkingArea, which is the client part of the desktop (full size except docked windows sush as the taskbar)

Give a try to the code I posted earlier - it works!

Just a note: If you have a look at installshield installers, it uses "fullscreen windows" (with borders). If you maximize the window using the maximize button, the taskbar appears. XD

Hope this helps,


Augusto.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Another note...

When you set these control styles:

this.Setstyle(Controlstyles.DoubleBuffer | Controlstyles.UserPaint |
Controlstyles.AllPaintingInWmPaint | Controlstyles.FixedWidth |
Controlstyles.FixedHeight, true);

I suppose that you are calling Invalidate() somewhere to force the OnPaint function (or the Paint event) being called...

Share this post


Link to post
Share on other sites
Wow, removing "WindowState = FormWindowState.Maximized" worked!
The taskbar is now invisible.
I'm still trying to fix the refreshing... I'll post on my results

Share this post


Link to post
Share on other sites
I'm calling Invalidate() at the bottom of OnPaint() itself, as well as initially in the Form's constructor. I'm not sure why but in the fullscreen window it still doesn't refresh.

Share this post


Link to post
Share on other sites
Quote:
Controlstyles.UserPaint
If true, the control paints itself rather than the operating system doing so. If false, the Paint event is not raised. This style only applies to classes derived from Control.


So my guess is that the OnPaint event override is not being called. You can put a breakpoint in the OnPaint method to verify if this guess is correct. If you need this flag for double buffering, this comment in the docs might be of help:

Quote:
the preferred method for enabling double buffering, which yields the same result, is to set the DoubleBuffered property for the control to true.


Good luck! :)

Share this post


Link to post
Share on other sites
Actually, I checked and OnPaint() IS being called. OnPaint() doesn't really do anything, though, since nothing in the window actually needs updating. In my window is a large image. Instead of drawing the image, the whole image just appears white, until the window is physically moved (then the image shows up properly).

My code has always worked fine before, i.e. in all my existing non-fullscreen windows any images will be rendered properly from the moment the window appears. So why would making the window fullscreen change this? The only real change is that TopMost is true, but why would this affect whether an image renders?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Could you please post your OnPaint code, so I may help you better?


Augusto.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If all you need is to paint a still image, I think that you should be able to do it overriding OnPaintBackground...

Share this post


Link to post
Share on other sites
protected override void OnPaint(System.Windows.Forms.PaintEventArgs args){
pictureBox.updateImage(); //updates the bitmap of the picturebox
this.Invalidate();
}

It's not a still image; the image may be changed at any time

[Edited by - NexusOne on April 6, 2006 1:40:08 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this