Hi Ana,
This question was asked before. The solution that usually is given is to
make your form bordless, without caption, etc. Yes, this works, but this is
not the only way to make the form coverring the taskbar.
You can have a form full screen event if it has thick border and caption.
The conditions that your form has to meet are:
1. to be maximized
2. the client rectangle to be big enough to cover the entire screen. Pay
attention on the requirement that the CLIENT RECT has to be that big.
That means the caption and the WindowsForm's menu and status bar have to be
off the screen. However, if you use third party menu and status bar controls
they are usually implemented as normal controls hosted in the form's client
area and they can be visible.
If you meet those requirements Windows will hide the taskbar for you.
For more info read this KB in MSDN
ms-help://MS.MSDNQTR.2003FEB.1033/enu_kbwin32sdk/en-us/win32sdk/Q179363.htm
In Win32 to make the form that big you have to handle WM_GETMINMAX info
messages. Form class handles
that message for you and provide properties MaximumSize and MaximizedBounds
that can be used. Note: Both have to be set in order to be able to cover the
taskbar
The problem is how to calculate the bounding rectangle of the Form in a way
to accommodate client rectangle as big as the screen. I haven't found method
that returns that info so I'll give you one idea how to calculate it
yourself. BTW there is a method you can use to set the size of the client
rectangle and it will calculate the bounding rectangle for you but I can't
see any way to use it for the case.
So here is my solution. Copy and paste this method in your form class. Run
the application and maximize the form it has to cover the entire screen.
Perhaps it is not the best way to do the calculation. Because if the menu
wraps at the moment of calculation the result will be far from perfect. The
other solution could be to use PInvoke and call AdjustWindowRectEx or
AdjustWindowRect API.
If you or any one in the group has better solution for this calculation it
would be really helpful if make a post
However here is the code.
protected override void OnLoad(EventArgs e)
{
base.OnLoad (e);
Point clientTL = this.PointToScreen(new Point(ClientRectangle.X,
ClientRectangle.Y));
Point clientBR = this.PointToScreen(new Point(ClientRectangle.X +
ClientRectangle.Width, ClientRectangle.Y + ClientRectangle.Height));
Point frameTL = this.Location;
Point frameBR = new Point(this.Location.X + this.Width, this.Location.Y +
this.Height);
int topXDelta = clientTL.X - frameTL.X;
int topYDelta = clientTL.Y - frameTL.Y;
int bottomXDelta = frameBR.X - clientBR.X;
int bottomYDelta = frameBR.Y - clientBR.Y;
Rectangle newFrameBounds = Screen.GetBounds(this);
newFrameBounds.Inflate(topXDelta + bottomXDelta, topYDelta +
bottomYDelta);
newFrameBounds.Location = new Point(-topXDelta, -topYDelta);
this.MaximumSize = newFrameBounds.Size;
this.MaximizedBounds = newFrameBounds;
}