Form covers taskbar when maximized

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've noticed that a form will cover the taskbar when it is maximized if its
ControlBox property is set to false (even if the "Keep the taskbar on top of
other windows" option is selected). You can reproduce this by showing the
following form:

Public Class Form1
Inherits Windows.Forms.Form
Public Sub New()
MyBase.New()
Me.ControlBox = False
Me.WindowState = FormWindowState.Maximized
End Sub
End Class

What I want is for the form to behave as it does when ControlBox is set to
true (except that I want the ControlBox to be hidden).

Thanks for any help!
Lance
 
Hi Lance,

I performed a test based on your sample code on both Windows Server 2003
and Vista, but didn't reproduce the problem.

I found that only if the "Keep the taskbar on top of other windows" option
is NOT selected, the form will cover the taskbar.

Could you tell me what the OS is you're using?


Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Lance,

I have performed another test on Windows XP, but I didn't reproduce the
problem.

I suggest that you perform tests on other machine to see if the problem
still exists. You may also have a try moving the statements of setting
ControlBox and WindowsState property of the form to the form's Load event
handler.

Hope this helps.


Sincerely,
Linda Liu
Microsoft Online Community Support
 
Hi Linda,

I tried my code on two other computers with WinXP, SP2 and they both acted
the same. One thing that I noticed is that the form only covers the taskbar
if its Text property is set to an empty string. If the Form's Text property
is not an empty string then the title bar will be shown which appears to
prevent my issue from occuring. I suspect that this is why Terry's
suggestion of calling InitializeComponent appears to work (because the form's
Text property is set to "Form1").

I also tried setting ControlBox and WindowState in the the Form.Load event
but that did not fix the problem.

When attempting to reproduce the issue make sure that there isn't any
designer code, such as in Form1.Designer.vb. If this file exists, then just
delete it and then verify that Form1.vb only contains my sample code:

Public Class Form1
Inherits Windows.Forms.Form
Public Sub New()
MyBase.New()
Me.ControlBox = False
Me.WindowState = FormWindowState.Maximized
End Sub
End Class

Thanks again for looking into this.
Lance
 
Hi Lance,

Thank you for pointing out the key point of the problem. I have set the
Text property of the form to an empty string (the ControlBox property to
false and WindowState property to Maximized), and did see that the form
covers the taskbar.

(FYI, I also found that if I set the WindowState property of the form to
Normal, the form has no title bar when it shows up.

I searched our inner database and found a document saying that setting the
Text property to an an empty string and ControlBox property to false is a
good way to get rid of the title bar on a form and this behavior is by
design. )

A workaround of your problem is to set the Text property of the form to a
non empty string in design-time, and then set this property to an empty
string in the form's Load event handler and after the code of setting the
ControlBox and WindowState properties if they are located in the Load event
handler.

The following is a sample.

Public Class Form1
Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.

Me.WindowState = FormWindowState.Maximized
Me.ControlBox = False
End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Me.Text = ""
End Sub
End Class

-or-
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Me.WindowState = FormWindowState.Maximized
Me.ControlBox = False
Me.Text = ""
End Sub
End Class

Please try my suggestion and let me know the result.


Sincerely,
Linda Liu
Microsoft Online Community Support
 
Back
Top