Author: Bradley
Today, people's communication and lifestyle have already changed huge changes. Look at the friends around you, you will not have digital products such as mobile phones, PDAs. Some products have also used the Windows CE operating system. Is it very difficult to prepare applications such as such mobile devices, especially handheld? In fact, if it is easier to develop with Visual Studio .NET 2003. This article uses the simplest way to tell you how to develop applications for mobile devices, as well as it and the development of normal Windows platform applications. Between the display - Set the program type Run Visual Studio .NET 2003, select the File | New | Project menu item to establish a new project. Select the Visual C # Projects folder, select Smart Device Application on the right (shown in Figure 1).
Here I name my program MyMobileApp and save it in the default location. Of course, you can also take any name you like for your mobile program.
The OK button of the Select the dialog will open the design wizard. In this dialog, you can choose to generate a PocketPC or a Windows CE application. You can also choose the application type. In this example you will select the Pocket PC and create a Windows Application application.
You can also see the list of this dialog box shows the device installed on your computer. You can see my Pocket PC device is a simulator. If you don't have a mobile device, you can also use the simulator to create an application, just like this example you have to do.
Select Pocket PC and Windows Application, click OK button, Visual Studio .NET 2003 will drive a busy moment and generate a standard item.
Basic PocketPC forms look like a normal Windows form. From the development view, it is almost exactly the same. The only difference is that some controls and commands cannot be used. In addition, you can see a ready-made menu component in the workspace.
Wear new shoes and walk the old road
- Establish an application
When I use new integrated development software, design platforms or programming languages, I will establish a simple standard "Hello World" program. This simple program only contains a button, a text box and a label. Click the button to copy the text in the text box and display it on the label. Although the practical significance of this program is very limited, it contains basic elements of establishing standard form applications.
First change some properties of your program. Click the form to display the form properties. Change the form name to MyMobileAppform to change the Text property to "My Mobile App".
Just like you do in a normal Windows Form application, add tags, text boxes, and buttons. The text box and tag of this example keep the default name. The TEXT attribute of the button is changed to "Do IT". Your form should look like Figure 2 (note that the entire programming software is not displayed).
Now the form has been designed, you need to add some code. Double-click the button as if you do in the standard application, add code to the Click event. The Button1_Click event will be placed in the Form1.cs file. Add the following black body code to this method:
Private void Button1_Click (Object Sender, System.Eventargs E)
{
Label1.text = textbox1.text "/ n" label1.text;
TextBox1.text = ""
}
You will find that this code is very simple. The first line statement places the current text of the text box to the beginning of the label. Another row to separate the new old label text.
The second line statement is used to clear the text in the text box. You will find that when you enter these statements, smart prompt information will help you program. These intelligent prompt information will only appear when establishing a mobile program in your standard program. This rating is clearly cleared. Then press the F5 key to compile your program, or select the Start option under the debug menu. It should be noted that if an error occurs, it is best to check the code to make sure the input is correct. In addition, I found that the Form1 in the main method will automatically change the name after the name of the form's properties window. At this time, you need to change it into MyMobileAppform.
If there is no error, the form will be compiled and deployed. You will see the following information in the compilation window:
------ Deploy Started: Project: MyMobileApp,
Configuration: Debug Pocket PC ------
A few seconds (or minutes, depending on your computer configuration), a dialog will pop up.
In this dialog, you can choose a available device that is connected to your computer for deployment. If you have a device, you can install the application on the computer as long as you are connected to your computer. If not, you can only deploy the program on the Pocket PC 2002 Emulator Simulator.
Special shell gives special you - using simulator running applications
Select the simulator and click the Deploy button. When the app is downloaded to the simulator, your system is busy. When the simulator is loaded first, it looks like a standard PocketPC display. You can only wait for you during the program download. Once downloaded, your simulator will be shown in Figure 3.
As you can see, the simulator's appearance and mode of operation is like a real handheld computer. You can enter text in the text box and press the Do IT button, you will see the text is added to the label. All operational effects are the same as expected.
Then close the simulator window. At this time, you will be asked to save the simulator status or close. If the simulator status is saved, the simulator will start faster when you re-run the program from Visual Studio .NET 2003.
A little more
- Add menu
Before the program, you need to do something. To add a PocketPC menu for your program. Back to the integrated development interface, open the designer and display the form. Your program contains a default MainMenu1 component. When you right-click on the MainMenu1 component, you will find that the form in the design area has changed, and there is a Type Here in a region. You can click on the word and enter the menu name to build your menu component. When you enter the menu name, the next and the above of this menu item will appear new menu items. Enter "Do IT" in the main text box.
Double-click the Do IT menu item to add code. This will create a menuitem1_click method in the code window. In this example, you need to add the following code line for this method:
Button1_click (sender, e);
This statement will call the same code as the DO IT button.
Now you can recompile and run the program. You will see the run interface and the original, but there is a Do IT menu at the bottom of the window. When you click on the Do IT menu item, run the effect and click on the Do IT button - as the code you have compiled.
If a deployment error occurs, check if the program running now is the previous version. This may happen if you save an emulator status rather than direct shutdown. Click Close button (× button in the upper right corner) to turn off the program running on the emulator before you can run a new program.
summary
As everyone's see, design a PocketPC or Windows CE application is very similar to establishing a normal Windows platform application. Of course, you will definitely be restricted by specific devices, such as small input screens, and lack some operational methods and functions. This simple introductory article is not enough, but you will find that the mobile device is programmed according to this article, and the Writing Standard (Non-mobile) Windows program is similar. Microsoft further strengthens mobile program development function in Visual Studio 2005. Unlike you the simple square form of you see in the previous development environment, you will see what you will see more like actual equipment. This makes it easier to see the operation of the program in a specific device. In fact, different devices in the new Visual Studio will display different appearances.