This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

In this walkthrough you will create, build and run a simple Hello World application in Visual Basic or C#.

To create a Windows Application project

  1. On the Filemenu, point to New, and then select Project.

  2. In the Project Types pane, expand the Visual Basicor Visual C#branch. Then expand the Smart Devicebranch. Select the appropriate Windows Mobile 6project type.

  3. In the Templatespane, choose Device Application.

  4. In the Namebox, name the project something unique to indicate the application's purpose. In the Locationbox, enter the directory in which you want to save your project, or click the Browsebutton to navigate to it.

The Windows Forms Designer opens, showing Form1 of the project you created.

To build the application

  1. In the Windows Forms Designer, click on the MainMenu1 control in order to start editing the menu. Click in the menu area on the form where it says "Type Here" and type "Quit" and press Enter. You may need to scroll the form down in order to view the menu area.

  2. Double-click on the word "Quit" to go to the event handler for the menu option. Add the following code to handle the event:


    Copy Code
    Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e
    As System.EventArgs) Handles MenuItem1.Click
    End Sub


    Copy Code
    private void menuItem1_Click(object sender, EventArgs e)
  3. Add the following code to the Form1 class to display "Hello World":


    Copy Code
    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
    System.Windows.Forms.PaintEventArgs) Handles Me.Paint
      ' Create string to draw.
      Dim drawString As [String] = "Hello World"
      ' Create font and brush.
      Dim drawFont As New Font("Arial", 10, FontStyle.Regular)
      Dim drawBrush As New SolidBrush(Color.Black)
      ' Create point for upper-left corner of drawing.
      Dim x As Single = 10.0F
      Dim y As Single = 10.0F
      ' Draw string to screen.
      e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y)
    End Sub


    Copy Code
    protected override void OnPaint(PaintEventArgs e)
      // Create string to draw.
      string drawString = "Hello World";
      // Create font and brush.
      Font drawFont = new Font("Arial", 10, FontStyle.Regular);
      SolidBrush drawBrush = new SolidBrush(Color.Black);
      // Create point for upper-left corner of drawing.
      float x = 10.0F;
      float y = 10.0F;
      // Draw string to screen.
      e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y);
  4. From the Solution Configurationsdropdown, located in the toolbar, select Debug.

  5. From the Target Devicedropdown, located in the toolbar, select your device to test the application on. For this walkthrough, select Windows Mobile 6 Classic Emulator.

  6. Build your project by selecting Build Solutionfrom the Buildmenu. Check the results of the build in the Outputwindow. Fix errors as needed until the project builds successfully.

To run and debug the application

  1. Set your desired breakpoints. You can set a breakpoint by clicking in the left margin of the line of code you want to set the breakpoint on or by placing the cursor on a line of code and selecting Toggle Breakpointfrom the Debugmenu. F9will also toggle breakpoints.

  2. Select Connect to Device from the Tools menu to set up communication with the debugging device, in this case the Windows Mobile 6 Classic EmulatorClick the Connectbutton.

  3. The emulator window will open and start up. It may take a minute or so to set up the connection with the emulator. Click Closeon the Connecting dialog when the connection has been successfully made.

  4. Select Start Debuggingfrom the Debugmenu or press F5to start the application. The executable and any other needed files will be transferred to the emulator. It may take a minute or so to transfer the files.

  5. You can now run your program on the target device and debug it in the Visual Studio environment. You can use the Continue (F5), Step Over (F10), Step Into (F11), and Step Out (Shift+F11)commands to walk through the code.

  6. To stop debugging, you can exit your application or select Stop Debugging (Shift+F5)from the Debugmenu.

  7. When you are ready to build the release version of your project, you can change the Solution Configurationdropdown to Releaseand rebuild the project to build the release version.

  8. When you close the emulator, you are given the option to save the emulator state. By saving the state, you can decrease the emulator start up time the next time you launch the emulator.

See Also