| < Day Day Up > |
You can now save the application and test it. Figure 24.3 displays the application as an example of how it should appear. You can test the various options to see how well it
Figure 24.3:
The application being executed.
| < Day Day Up > |
| < Day Day Up > |
This chapter
| < Day Day Up > |
| < Day Day Up > |
Download CD Content
In this chapter, we take a look at the basics of building a utility for simulating a joystick. The basic concepts behind the joystick are to eliminate the need for a real joystick to be connected to the Tablet PC to play
| Note |
The source code for the projects are located on the CD-ROM in the PROJECTS folder. You can either type them in as you go or you can copy the projects from the CD-ROM to your hard drive for editing. |
As you already know, the general idea behind this application is to simulate a joystick. Most games that support joysticks also offer the user the ability to use a keyboard. Obviously, there might be times that a Tablet PC
Our approach is to develop an application based around the
SendKeys
method. By using
SendKeys
, we have the ability to send keystrokes to other applications. We can assign keys for the various directions and
Figure 25.1:
The joystick will look like this.
| < Day Day Up > |
| < Day Day Up > |
Begin by creating a new VB Window Forms application. As you can see in Figure 25.1, the GUI is quite simple. We use a background image on a form to simulate the appearance of a joystick. The image is available on the CD-ROM that is included with the book in the Chapter 25 project folder. After assigning the background to the image, resize the form to approximate its dimensions. The
The following Label controls need to be created with the following
lblUp
lbl45
lblRight
lbl135
lblDown
lbl225
lblLeft
lbl315
The previous labels handle the directional elements for the joystick. There are a few remaining labels that we need to add. First, we need to add labels called lblReturnPos and lblDelay, which help to control how long the application waits between virtual keystrokes. The last two steps are to add a Timer control, a StatusBar control, and an InkEdit control to the form. The InkEdit control will be used to change the values of the directions as the
Figure 25.2:
The final GUI.
| < Day Day Up > |