[RESOLVED] Issue with fullscreen code
Howdy!
I am having a issue with getting my Win form app to go into fullscreen - Well sort of.
See if you exit after you enter then enter again it works just fine - But when you go into it the first time it sitll shows some of the taskbar.
(See below)
Code:
Private Sub ToolStripButton5_Click(sender As Object, e As EventArgs) Handles ToolStripButton5.Click, FullScreenToolStripMenuItem.Click
ToolStripButton5.Visible = False
ControlBox = False
Me.WindowState = FormWindowState.Maximized
Me.Size = SystemInformation.PrimaryMonitorSize
Me.WindowState = 2
Me.Location = New Point(0, 0)
Me.TopMost = True
Me.FormBorderStyle = 0
Me.TopMost = True
ToolStripButton6.Visible = True
End Sub
'Exit FullScreen.
Private Sub ToolStripButton6_Click_1(sender As Object, e As EventArgs) Handles ToolStripButton6.Click, ExitFullScreenToolStripMenuItem.Click
Me.WindowState = FormWindowState.Normal
Me.Size = MaximumSize
Me.FormBorderStyle = FormBorderStyle.Sizable
ToolStripButton5.Visible = True
ControlBox = True
Me.TopMost = False
ToolStripButton6.Visible = False
End Sub
When you first load the application and every time - you have to go into - back out and back into fullscreen just for it to be right.
The code took me a few months to come up with. This being is because there is no native "Form.GoFullScreen"
Wished it was that easy - Sure there is a way for me to write a class maybe but rather not for now.
The code really isn't that hard to understand...But I just don't understand why it isn't working when I hit fullscreen the first time...
Some pictures:
Form load
1st FullScreen
2nd FullScreen
Updated the second screenshot to display fullscreen better
Re: Issue with fullscreen code
P.S. I know the stip menu overlaps Not really worried thats going away soon
Re: Issue with fullscreen code
Why do you even have this line? What is '2'? You will actively have to put that number in, and remove a specific enumeration....
Quote:
Originally Posted by
jdc20181
...
Code:
...
Me.WindowState = 2
...
...
To maximize your application just make the form maximized: you don't need to mess with the forms size or border.
Me.WindowState = FormWindowState.Maximized
Re: Issue with fullscreen code
He doesn't want to maximize the form, he wants to make it "fullscreen", i.e. the client area fills the full screen, no window decorations.
It does seem like there are extra things in there that aren't needed.
The following work for me.
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.Size = SystemInformation.PrimaryMonitorSize
Me.Location = New Point(0, 0)
Me.TopMost = True
Since you are processing things in an event handler for a control that you are manipulating, that might be an issue, I don't know.
I would try to do the control manipulation outside the control's event handler.
So, put the code into a sub, and then invoke the sub asynchronously to see if that helps.
For instance, create a sub named makeFullScreen and put the code in there.
In the event handler asynchronously Invoke the sub by using BeginInvoke:
Me.BeginInvoke( makeFullScreen)
That way your code will have left the event handler for the toolstrip before trying to hide the toolstrip.
Since the toolstrip would want to draw the button pressed in the up state when you release the button, but you've also told it to hide itself during the event, you've created a paradox for the code. Things you've told the form or controls to do that change their appearance don't happen while you're in your code. They happen later when the window gets the messages you've caused by calling those methods, or setting those properties.
Even doing the code outside the event may not guarantee the hiding and drawing don't conflict, but at least gives it a good chance to work, first time.
Re: Issue with fullscreen code
Quote:
Originally Posted by
passel
He doesn't want to maximize the form, he wants to make it "fullscreen", i.e. the client area fills the full screen, no window decorations.
It does seem like there are extra things in there that aren't needed.
The following work for me.
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.Size = SystemInformation.PrimaryMonitorSize
Me.Location = New Point(0, 0)
Me.TopMost = True
...
Ah I see. Well, you can still use maximized and border style none.
However...
Changing the border style of a form can cause funky things to happen, in VS2005 it was terrible, and caused events to loose their handlers. In 2010, it's better but can cause some errors (I can easily generate stack overflow errors when changing a form border style).
I believe changing the style causes the window handle to be recreated (thinking back to the C++ days), but could be wrong.
Re: Issue with fullscreen code
If this is something that is designed to run "kiosk mode", he can change all the window settings design-time. I've written a number of programs designed to be full-screen dominant, hiding the fact that there's even an operating system running underneath, or an easy way to access it. For things like shop-floor control systems, message-boards being displayed on large, airport style displays, and kiosks, this is just an everyday thing. passel pretty much nailed everything that needs to be done for the basics. Disabling, or making it hard to access the underlying operating system is trickier.
Re: Issue with fullscreen code
Quote:
Originally Posted by
passel
He doesn't want to maximize the form, he wants to make it "fullscreen", i.e. the client area fills the full screen, no window decorations.
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.Size = SystemInformation.PrimaryMonitorSize
Me.Location = New Point(0, 0)
Me.TopMost = True
Since you are processing things in an event handler for a control that you are manipulating, that might be an issue, I don't know.
I would try to do the control manipulation outside the control's event handler.
So, put the code into a sub, and then invoke the sub asynchronously to see if that helps.
For instance, create a sub named makeFullScreen and put the code in there.
In the event handler asynchronously Invoke the sub by using BeginInvoke:
Me.BeginInvoke( makeFullScreen)
That way your code will have left the event handler for the toolstrip before trying to hide the toolstrip.
Since the toolstrip would want to draw the button pressed in the up state when you release the button, but you've also told it to hide itself
Yep that is the goal - to make it "Fullscreen" by doing what I did it hides the task bar (But the issue is it doesn't do it the first time around)
Quote:
Originally Posted by
SJWhiteley
Ah I see. Well, you can still use maximized and border style none.
However...
Changing the border style of a form can cause funky things to happen, in VS2005 it was terrible, and caused events to loose their handlers. In 2010, it's better but can cause some errors (I can easily generate stack overflow errors when changing a form border style).
I believe changing the style causes the window handle to be recreated (thinking back to the C++ days), but could be wrong.
The code hides the task bar because there is no Me.GoFullScreen() Function - So The code is different than what you have been describing.
Quote:
Originally Posted by
Jenner
If this is something that is designed to run "kiosk mode", he can change all the window settings design-time. I've written a number of programs designed to be full-screen dominant, hiding the fact that there's even an operating system running underneath, or an easy way to access it. For things like shop-floor control systems, message-boards being displayed on large, airport style displays, and kiosks, this is just an everyday thing. passel pretty much nailed everything that needs to be done for the basics. Disabling, or making it hard to access the underlying operating system is trickier.
Kisok mode? I have no clue what that is - The project is my browser project. It is a function that all major browsers have.
If y'all wanna see what it does you can always download it and try it yourself : http://beffsbrowser.tk
The screenshots made the demo - so you don't need to download but - if you wish ^ there is teh website - Currently in version 1.6.0
Thanks.
I am gonna try The suggestion passel said.
And seeing what the reduced code does.
However -
The code should make the taskbar disappear. With the taskbar it isn't fullscreen.
Thanks again.
Re: Issue with fullscreen code
Quote:
Originally Posted by
SJWhiteley
Why do you even have this line? What is '2'? You will actively have to put that number in, and remove a specific enumeration....
To maximize your application just make the form maximized: you don't need to mess with the forms size or border.
Me.WindowState = FormWindowState.Maximized
I think this is a older method to make the screen max (Not liek fullscreen max but max size or something) But not certain - I tried googling to get a good answer but I honestly have no clue. This is a bug I am trying to patch up - Written a while ago.
Re: Issue with fullscreen code
Not sure what I did wrong - but
Expression does not produce a value. Is what I get...
http://screenshot.sh/n8ex90B2ZfUdw
Re: Issue with fullscreen code
Well good news is the menu stip isn't overlapped anymore (Thanks so much!) Bad news is I can't seem to get it to do it the first time :( Still.
Re: Issue with fullscreen code
Did you try what Passel suggested?
I've done this, as well, for a splash screen like form that had to behave a bit differently than a real splash screen. I had the settings in design mode rather than in code, so I didn't do the Size or Location, but it's still about the same.
Re: Issue with fullscreen code
Quote:
Originally Posted by
Shaggy Hiker
Did you try what Passel suggested?
I've done this, as well, for a splash screen like form that had to behave a bit differently than a real splash screen. I had the settings in design mode rather than in code, so I didn't do the Size or Location, but it's still about the same.
I used the code - And it fixed the overlap of the menu strip (which is great)
but idk how to invoke it - Because of what I said in post 10...
Re: Issue with fullscreen code
I don't know that I can offer anything more at this point. I can't look at your links, or any of the images you posted as they are blocked from my work. If I remember, I'll look at them some hours from now so I can see what you're referring to.
Re: Issue with fullscreen code
odd they are blocked....That is the screenshot program I use ScreenShooter. They save only easy peasy...But that is appreciated -
Re: Issue with fullscreen code
Generally, big business is assuming that file and photo sharing sites are not business related, so doesn't allow access without getting a waiver. Just one of those facts of life, which is one reason posting an image on this forum would be preferred, and it will probably have a longer access, and be more immediate in any case. But large screen captures are discourages, as they will be reduced when posted so can be impossible to read if too large an area is captured.
1 Attachment(s)
Re: Issue with fullscreen code
Hello,
See attached project.
Re: Issue with fullscreen code
Quote:
Originally Posted by
kareninstructor
Hello,
See attached project.
I am using VS 2013 (cause 15 won't install it was being dumb) hopefully this will still work.
I really appreciate you taking the time to do this
Thanks!!
Re: Issue with fullscreen code
Quote:
Originally Posted by
jdc20181
I am using VS 2013 (cause 15 won't install it was being dumb) hopefully this will still work.
I really appreciate you taking the time to do this
Thanks!!
If you can't load the project I have the same project in VS2012 (original project) on OneDrive,
https://1drv.ms/u/s!AtGAgKKpqdWjhE1QMO-gN8sVEsgK
Re: Issue with fullscreen code
It does still work but I don't understand how you came up with "NormalMode" theres no code for it...Like there is for make fullscreen.
Re: Issue with fullscreen code
Quote:
Originally Posted by
jdc20181
It does still work but I don't understand how you came up with "NormalMode" theres no code for it...Like there is for make fullscreen.
The code is the last method in FormExtensions
Re: Issue with fullscreen code
Thanks!
So - What do I need to make it fully functioning in my project migrating the essentials?
From what I can tell (Just recomfirm and I will be marking this resolved)
- I need the code in the Form Extensions (For the sake of NormalMode.)
- The MakeFullScreen Sub code.
Will the "MakeFullScreen" code be enough?
Thanks again (just trying to understand your code I am still learning even though I have been programming for nearly 2 years)
Re: Issue with fullscreen code
Edit: I think I got it working just fine now, again Thanks for your help. I am always trying to learn. I have had many people use my browser so making it the best quality I can for my user base is important.
Thanks!
Re: [RESOLVED] Issue with fullscreen code
Ok so I changed the code from what i had to normalmode() but it still hides the task bar when I Exit fullscreen....