Setting Up

Now that we have a very broad idea of what we are going to create we need to set up the environment where all the work will be done.

The application will be written in VB.NET. So the first thing is to create the folders where the work will be done. To do this I opened up Visual Studio and created a blank solution called MidnightHour. That’s what I will call my new masterpiece.

I had decided that I will use, at least at this stage, an Access database, so I may as well create it now. In the MidnightHour folder that was created by Visual Studio I created a database and called it Hour.mdb. I am not doing anything with it yet, so I won’t add any tables at this stage.

There are a number of subsystems within the application but I am still going to need a Windows form to serve as an entry point to the application. At this stage I haven’t designed that yet, so I will just create a main form with a menu that does nothing more than exit the application. When I create each of the subsystems I will add a menu item which I can use to access each system. It might make sense to design this now but I would rather do some coding than graphic designing, so I will do it later.

What I will have to do, though, is create a template form from which I will inherit all my other forms. There are a few reasons for this. First, because this is going to be used on my computer I can set the colours to whatever I want. I don’t like the Windows control background colour much, so I set the background colour to white. But there are more important reasons.

First, I want to have a standard look to my windows forms. Same colour, same font, same icon, and, most importantly, a standard border, or padding between the window border and the window controls.

To accomplish the first tasks I set the background color of my template form, called BaseForm, in this case to white, attach an icon, and change the font to Tahoma – I think it looks much better than the default Microsoft sans-serif.

Then change to View Code and select BaseForm events in the Class drop-down list. In the Methods drop-down list I select Paint. This will fire whenever the form is painted. I added the following code:

If Me.DesignMode = True Then
          Dim myPen As Pen = New Pen(Color.Red)
          e.Graphics.DrawLine(myPen, 25, 0, 25, Me.Height)
          e.Graphics.DrawLine(myPen, Me.Width - 25, 0, Me.Width - 25, Me.Height)
End If

The last thing I want to do with the Visual Studio designer is to ensure that controls get a Windows XP look. Controls such as the Button can have a number of Styles which are set with the FlatStyle property. If you set this style to System you can have apply XP themes to these controls. But in order for these themes to apply you need a file called applicationname.exe.manifest. This is an XML file and it contains the following code:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0"></assembly>
< description>Windows Forms Common Control manifest</description>
  <dependency>
    <dependentassembly>
      <assemblyidentity type="win32"
      name="Microsoft.Windows.Common-Controls"
      version="6.0.0.0"
      processorArchitecture="X86"
      publicKeyToken="6595b64144ccf1df" language="*" />
    </dependentassembly>
  </dependency>
</assembly>

The last thing to do prior to any coding is to set up LLBLgen, my O/R mapper of choice. I won’t go into the details of doing that here because all O/R mappers are set up differently. But because I don’t have anything in the database it doesn’t do much yet. All I have done is create the folders and set the preferences.

I told LLBLGen to create a data access layer, and called it DAL. It creates a number of folders for me and created a new VB.NET project called DAL. I now have to add it to the solution and set some references to it.

And that is the end of setting up.

Comments are closed.