Because I am very poor, I don't have any machines.ProgramAll completed in the simulator
This is my thoughts and examples on mobile development. Most of the things I learned are from Microsoft's webcast and msdn. Basically, they are not original, they are just sorted and published.
PreviousArticleAfter the development environment has been installed, write the first program today. First, go to vs2005.
Next, choose file-> New-> Project-> Visual C #-> smart device-> Windows Mobile 5.0 smartphone-> device application, select the SAVE project path, and click OK. Go to the Development page. Simulator
Pretty
It is customary to go To the toolbar to see a lot of controls, including common controls: lable, Textbox, picturebox, ComboBox, listview, Treeview, progressbar, checkbox, datetimepicker, linklable, webbrowser, container Control: panle, mainmenu control in the menu toolbar, and display control for Data Binding: bindingsource, DataGrid device components: imagelist, messagequeue, SerialPort, and timer. If you have developed computer Windows programs, these controls are very familiar.
The smartphone file system is a root directory instead of a drive letter. Operations in the program only support absolute paths. Operate in. netCompositionThe namespace used by the file and directory is system. the shgetspecialfolderpath function is used to obtain the path of a specified folder. The memory card is displayed in the "\ storage card" directory. The APIs used to operate the memory card include findfirstflashcard and findnextflashcard.
Some of the special APIs supported by smartphone are managed and local APIs,
First, we will introduce the Telephone Dialing hosting API in The namespace Microsoft. windwosmobile. phone in telephony. talk (string phonenumber) is mainly used to call a number, if you want to get more detailed dialing information to intelligently call the local API--TAPI, this will be detailed in future articles, it is mainly used to obtain outbound and inbound status operations. It must contain TAPI. h header file, introduced coredll. lib class library.
The second introduction is text message API, which is hosted by Microsoft in the namespace. windwosmobile. pocketoutlook. smsmessage in smsmessage. the send (smsmessage) function, while the local API contains smsopen, smssendmessage, smsgetphonenumber, smsclose, and other methods, including in SMS. h header file, which must be referenced by SMS. lib class library. The Managed class namespace Microsoft. windwosmobile. pocketoutlook not only supports sending text messages, but also supports sending emails, adding tasks, appointments, and contacts.
In. Net CF, some boxes are also included to make it easier to operate files on the mobile phone. Commonly Used boxes include the cameracapturedialog camera pair box, the choosecontactdialog contact pair box, And the selectpicturdialog select image dialog box. These dialog boxes will be applied later.
Next, we will write a program that includes the function of sending text message, dialing, and adding appointments.
First, add the menu items in the mainmenu of form1 in the project that was created at the beginning,
The following code is added to the click event of each menu item.
/**/ /// <Summary>
/// Call
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Private Void Menuitem5_click ( Object Sender, eventargs E)
{
Phone Myphone= NewPhone ();
Myphone. Talk ("0573-1234567");
}
/**/ /// <Summary>
/// Send SMS
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Private Void Menuitem3_click ( Object Sender, eventargs E)
{
Microsoft. windowsmobile. pocketoutlook. smsmessage smsm = New Smsmessage ();
Smsm. Body = " Hello World " ;
Smsm. to. Add ( New Recipient ( " Lao Yang " , " 133002121629 " ));
// Sent successfully to get a feedback
Smsm. requestdeliveryreport = True ;
Smsm. Send ();
}
/**/ /// <Summary>
/// Send email
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Private Void Menuitem4_click ( Object Sender, eventargs E)
{
Microsoft. windowsmobile. pocketoutlook. emailmessage emailm = New Emailmessage ();
Emailm. Subject = " Hello World " ;
Emailm. bodytext = " I typed .. " ;
Emailm. to. Add ( New Recipient ( " Big " , " Teaks@hotmail.com " ));
// Add attachment
// Attachment attach = new attachment ("\ luxv \ g.gif ");
// Emailm. attachments. Add (attach );
// Emailm. Send ("big ");
}
/**/ /// <Summary>
/// Add appointment
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Private Void Menuitem7_click ( Object Sender, eventargs E)
{
Microsoft. windowsmobile. pocketoutlook. outlooksession mysession = New Outlooksession ();
Appointment apment = New Appointment ();
Apment. Subject = " Test " ;
Apment. Body = " Dinner " ;
Apment. Start = Datetime. now;
Apment. End = Datetime. Now. adddays ( 4 );
Mysession. Appointments. Items. Add (apment );
Apment. showdialog ();
}
After writing this, you can learn the common functions of traditional mobile phones.
Code example
Note that the pre-installed Windows mobile5.0 is. Net cf1.1 SP3. To run the. NET cf2.0 program, install. Net CF 2.0 on your own.
The road is long and the distance is long.