Question Screen Bounds Problem

pjfatboy

Active member
Joined
Nov 30, 2012
Messages
35
Programming Experience
Beginner
Ok, I am using two monitors on my computer. In my project I have a button that will Max my form with no boarder. The problem I am having is; it spills my form over onto my other monitor just a bit. How do I stop this? Here is the code I am using to stop this but it doesn't work. Can someone help me out with this? Thanks
VB.NET:
[FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2].Width = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Screen[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2].PrimaryScreen.Bounds.Width[/SIZE][/FONT][/SIZE][/FONT]
[FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]        [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2].Height = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Screen[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2].PrimaryScreen.Bounds.Height[/SIZE][/FONT][/SIZE][/FONT]
 
I read your post again and maybe I misinterpreted it. Are you saying that you originally were setting the WindowState to Maximised but that was causing the problem?
 
How much is "just a bit"?

When you perform the maximized order, what are the values of your Me.Location.X and Me.Location.Y, and also, do the values of Me.Width and Me.Height match your screen resolution?
 
Just a bit is a strip about 50 pixels wide. Me.Location is 0,0 and width and height is set to 1024 x 768 but my screen resolution is 1680 x 1050 and the form WindowState is set to Maximized in the Properties. The app opens with a FormBorderStyle of Sizable. I have a button to set the borderstyle to none, that is when the form stretches over onto the other monitor.
 
Last edited:
in your borderstyle button, use this:

Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.WindowState = FormWindowState.Normal
Me.WindowState = FormWindowState.Maximized
 
Ok, that worked. Mind explaining to me why it worked? Also now my form flashes when it removes the border, looks choppy. Any way to stop this from happening like the old VB6 Redraw = False?
 
Last edited:
My apologies, it looks smooth and clean on my screen, otherwise i wouldn't have suggested it as a solution. The reason I decided to try this solution in order to help you with your problem was because logic dictated that if a form was set to maximized and max = the working area boundaries then if a form is not contained within these boundaries then it simple needs to be re-set.

As far as why the form size changes when you remove the borders, I'm actually not sure, I think one of the more experienced heads might be able to answer that one.
 
It's not all that bad. I think the reason it flashed is because I have some controls on the form that are set to invisible until a button is clicked. Those are the things that seem to flash when the form border is removed. Anyway I appreciate the help.
 
Back
Top