To create a Windows Application project
1. On the File menu, point to New, and then select Project.
2. In the Project Types pane, expand the Visual Basic or Visual C# branch. Then expand the Smart Device branch. Select the Windows Mobile 5.0 Pocket PC project type.
3. In the Templates pane, choose Device Application Project.
4. 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.
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.
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:
VB
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
Application.Exit()
End Sub
C#
private void menuItem1_Click(object sender, EventArgs e)
{ Application.Exit();
}
3. Add the following code to the Form1 class to display “Hello World”:
Visual Basic
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
C#
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 Configurations dropdown, located in the toolbar, select Debug.
5. From the Target Device dropdown, located in the toolbar, select your device to test the application on. Select Windows Mobile 5.0 Pocket PC Emulator.
6. Build your project by selecting Build Solution from the Build menu. Check the results of the build in the Output window. Fix errors as needed until the project builds successfully.
Continue Reading →
Popularity: 10% [?]