Recently i started developing windows form apps, actually i wanted to develop an app for windows 8 but i thought i won’t be useful for old users then, so i decided to build an app using windows forms and giving them the look of windows 8. But keeping in mind that we don’t have such an interesting navigation bar as in windows 8 we will give the look to the app as full screen but with windows taskbar also so that we can easily navigate between different running applications.
In this article we will learn to do the above mentioned task step-wise, we will change the form style so that we don’t have any borders as in traditional windows forms app, we will also find out the width of windows taskbar and also the location of the taskbar so that our app occupies the best fit location on the screen.
Step 1 : Firstly we will create a new windows form project.
Step 2 : Now we have to change the form border style so as to give it a better look. Navigate to the properties of Form1 and there change the FormBorderStyle to None.
Step 3 : You will notice the control box on the top is also gone which contains close and minimize buttons, so now we need to custom build them if we want them. Add a close picture and the minimize picture locate them where you want, now we need to add some code to make these images work accordingly.
For close : Close();
For minimize : this.WindowState = FormWindowState.Minimized;
Step 4 : Now we have to add an event on form load so as to force the application to load in full screen. Here is the main twist we can do it via WindowState = Maximized;
But, the above function will put your application above the taskbar, if it satisfies your condition then good else the below method will show the windows taskbar also. Now we will find the working area of the screen which includes the full screen except the windows taskbar which is our requirement. We will do this code in form load event.
After performing all this our task is completed, but again we have one challenge here i.e. the above code written will work only when the windows taskbar is at the bottom of the screen, so we will have to find the location of the taskbar also and set the location of the form according, to do so:
Navigate to properties of Form1 : StartPosition = Manual
Now comes the coding part, we will write this code in form1 load event, its just an amendment to the above code only a single line added:
That’s all done, Debug your app.
Cheers.