|
-
Mar 26th, 2009, 02:48 PM
#1
Thread Starter
Fanatic Member
FormBorderStyle to None when maximizing the form...
Argh! This is driving me nuts!
I have a normal form (FormBorderStyle = Sizeable).
When the user maximizes the form, the form's border should disappear and fully cover the screen. Like so:
vb Code:
Private Sub frmVideo_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged If Me.WindowState = FormWindowState.Maximized Then 'Remove border Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None 'Bring to front Me.TopMost = True End If End Sub
Problem is, when the form gets maximized and border changed to None, the form doesn't cover the whole screen.
The form gets the same height as when it is maximized with a titlebar on top. So, the form is about 20 pixels too short, leaving most of the Windows taskbar uncovered.
So, apparently, if the FormBorderStyle changes after the form has maximized, the change in size is not corrected.
Therefore, my question is: How do I change a form's size when it's maximized or how do I change the FormBorderStyle before maximization is finished?
Thanks for any help!
Alexander.
No matter how fool-proof your program is, there will always be a better fool.
Was a post helpful to you? Rate it!
-
Mar 26th, 2009, 03:37 PM
#2
Hyperactive Member
Re: FormBorderStyle to None when maximizing the form...
Try running your code in the Resize event of the form.
-
Mar 26th, 2009, 04:29 PM
#3
Thread Starter
Fanatic Member
Re: FormBorderStyle to None when maximizing the form...
I've tried that already, but to no avail...
No matter how fool-proof your program is, there will always be a better fool.
Was a post helpful to you? Rate it!
-
Mar 26th, 2009, 05:34 PM
#4
Re: FormBorderStyle to None when maximizing the form...
This should do it. This says "if the form is maximised, then change the borderstyle and then maximize";
Code:
Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Resize
If Me.WindowState = FormWindowState.Maximized Then
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.WindowState = FormWindowState.Maximized
End If
End Sub
-
Mar 27th, 2009, 04:12 AM
#5
Thread Starter
Fanatic Member
Re: FormBorderStyle to None when maximizing the form...
Nope, same problem.
But I have now solved the issue in a round-about way:
Code:
Private Resizing As Boolean = False
Private Sub HandleMaximizing() Handles Me.Resize
If Me.WindowState = FormWindowState.Maximized And Not Resizing Then
Resizing = True
Me.Hide()
Me.WindowState = FormWindowState.Normal
End If
If Resizing Then
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.WindowState = FormWindowState.Maximized
Me.Show()
Resizing = False
End If
End Sub
This will:
1. Hide the form.
2. Change it back Normal size, which triggers the resize-event again.
3. Change the border style to None.
4. Maximize the form again.
5. Make the form visible.
I hide the form, so the user won't see the form jumping all over the place. This still gives a short flicker, so it isn't ideal.
If anyone has a better solution, please let me know!
Alexander.
No matter how fool-proof your program is, there will always be a better fool.
Was a post helpful to you? Rate it!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|