Sunday, December 17

How to Make Your Own Windows Mobile Programs – Guide 3

Google+ Pinterest LinkedIn Tumblr +

Create and Run a Simple Windows Application In Managed Code  

In this walkthrough you will create, build and run a simple Hello World application in Visual Basic. What we are trying to do is just to make an aplication which will say a message Hello World and then you can just Quit this application. ( Note that this is a very simple program but if you want to learn visual basic you must start form the easy one first.) . In order to do this you need all the things i said at the Guide 1. Here is a screenshot on what we will try to do now..

How to Create a Windows Application project

Step 1: Open Visual studio 2008 and on the File menu, point to New, and then select Project.

Step 2:  In the Project Types pane go to Other languages–> Visual basic. Then click on the Smart Device branch. In the Name box, name the project something unique to indicate the application’s purpose. In the Location box, enter the directory in which you want to save your project, or click the Browse button to navigate to it. Then select Smart Device Project. Hit ok.

Step 3: Select Windows Mobile 6 Professional SDK project type. And be sure you have selected .NET Compact Framework Version 3.5. In the Templates pane, choose Device Application and then hit ok.

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

How to build the application

Step 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.

Step 2: Double-click on the word “Quit” to go to the event handler for the menu option.

Step 3: Add the following code to handle the event:        

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


End Sub  

Right now it should be like this :

Step 4: Add the following code to the Form1 class to display “Hello World”:        

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    

And now it should be like this :

Now we have the source code we want. And our application is basically ready.


1. At step 4 on how to build the application you can see this:  ‘ . When a line starts with an apostrophe that means that this is a comment . If you want you can just delete this green letters.   

2. If you would like to change the name of the application ( so not to be Form 1 but whatever you want ) at the tab that you see that virtual mobile click anywhere on the virtual mobile and at the right down properties change the one that says Text: Form1 to Text: Whatever your name want to be.. See screenshot here ( it is a big image so i give you a link )

3. You can see if you have an error ( something wrong in your source code ) if you click Error list. If you have an error double click it and It will show you where is the error. Try to to fix it.

The next guide explains how to make this code an application.

Guide 1 –> Here

Guide 2 –> Here

This is guide 3

Guide 4 –> Here


About Author

Leave A Reply