Saturday, December 1, 2012

Create your Windows 8 Start Menu

Create your Windows 8 Start Menu


Windows 8 remove the classic Windows Start button. Maybe you would like to have it back. It is possible if you get a new application but is not always free. I’ll show you that you could do your own Start Menu for Windows 8. There are a lot of steps and that is the reasons I’ll do many post. Each post will talk about 1 subject.


Windows 7 Start Button:

Windows 7 Start Button:

The first thing you need to if you want to program your own Start Menu, is getting Microsoft Visual Basic Express 2010 or Microsoft Visual Studio 2010 Professional. In my case, I will work with the profession edition and use the screen shoot from that software. The express edition will work too. So you could download it for fee from here: Download Visual Studio or Express Edition

Create your project in Visual Basic Express 2010 or Visual Studio 2010


I decided to start with a new project with the Windows Forms Applications Template. I named my project: SampleBasicProgram. Press Ok when you have finish.





SampleBasicProgram


Create your form in Visual Basic Express 2010 or Visual Studio 2010. I decided to place a button1 to do my test and a Status bar at the button to easily see the bounds of my form. Because we need to place the form over the Windows 8 taskbar, the statusBar will help me visualize it. The look of the form is not important, neither of the size.

SampleBasicProgram

Determine the position and the screen resolution


If you start your program, the form will display anywhere. We need to specify a precise position. Because the coordinates in Windows are base on the top left corner, we need to do some little mathematics to be able to place the windows 8 form at the right place.

I will use the screen method to get the size of my screen. With that information, I will be able to place my windows over my taskbar easily and automatically.

By the way, I would not recommend using an old Microsoft windows API shell32.dll  to get taskbar height. That way use very old technologies (C++) and unmanaged code. We have to be better than that.

Beside, the height is 40 pix or 32 pix because of the size of the icons inside.

To be able to make this work, you need to override the OnShown Function from the form class:


    Protected Overrides Sub OnLoad(e As System.EventArgs)
        MyBase.OnLoad(e)
        MyBase.Top = Screen.PrimaryScreen.WorkingArea.Bottom - Me.Height
        MyBase.Left = Screen.PrimaryScreen.WorkingArea.Left
    End Sub


That means that the form move while the form is about to load. You can’t put the same function inside the regular Load function because of the order of events. Your “Me.Height” inside the new function because the class isn’t created. So the best place and most simple way to do it is inside that event.

When you run your program, you will have something like this:

Create your Windows 8 Start Menu part 1

After, we need to do some decoration.



Next post : Create the Search TextBox

Next post : Windows 8 Search Box with UserControl
Next post : Extract icon from file
Next post : enhance button vb


Reference



1 comment: