windows mobile5.0开发第一个.Net应用程序[xgluxv] 【转载】
Posted on 2010-04-29 16:21 Happy Coding 阅读(370) 评论(0) 编辑 收藏 举报由于本人非常穷 所以自己是没有机器的 所有的程序都在模拟器里完成
这是本人学习mobile开发的感想和例子 学习的东西大都来自微软的webcast和msdn,基本上不是原创.就是整理再发表.
前面的文章 已经安装完了开发环境,今天就开始写第一个程序。首先我们进入vs2005
然后是File->new->project->visual c#->smart device->windows mobile 5.0 smartphone->Device Application,选择保存工程路径,单击OK 工程建立完成。进入开发界面。模拟器的截图
挺漂亮的
习惯性的先到工具栏里看看 发现很多控件,其中包括了常用控件:Lable、TextBox、PictureBox、ComboBox、ListView、TreeView、ProgressBar、CheckBox、DaTeTimePicker、LinkLable、WebBrowser,容器控件:Panle,菜单工具栏控件 MainMenu,数据绑定显示控件:BindingSource、DataGrid 设备组件:ImageList、MessageQueue、SerialPort、Timer。如果开发过计算机windows程序 这些控件是很熟悉的了。
smartphone文件系统不是以盘符分的 就是一个根目录.程序中操作只支持绝对路径。在.net里操作文件和目录使用的名称空间为System.IO,而获取指定文件夹的路径要使用API,SHGetSpecialFolderPath函数,存储卡的是以"\Storage Card"目录形式出现,操作存储卡的的API有FindFirstFlashCard,FindNextFlashCard等。
在smartphone中支持的一些特用的API,分为托管和本地的API,
首先介绍一下电话拨号的托管的API,在名称空间Microsoft.WindwosMobile.Telephony其中的Phone.Talk(string PhoneNumber)主要用来呼叫一个号码,如果想得到更详细的拨号信息智能调用本地API--TAPI,这个将在以后的文章中具体介绍,主要是用来得到拨出和拨入的状态操作等,它需要包含TAPI.H头文件,引入CoreDll.lib类库。
第二个介绍是短信API,托管的API有在名称空间Microsoft.WindwosMobile.PocketOutlook.SmsMessage下的SmsMessage.Send(SmsMessage)的函数,而本地的API包含SmsOpen,SmsSendMessage,SmsGetPhoneNumber,SmsClose等方法,包含在sms.h头文件,需要引用sms.lib的类库。托管类的名称空间Microsoft.WindwosMobile.PocketOutlook除了可以发送短信的功能还包含了发送邮件,添加任务,约会和联系人的功能。
在.Net CF中还包含了一些对方框 使操作手机里的文件更容易操作,其中常用的有CameraCaptureDialog照相机对方框,ChooseContactDialog联系人对方框,SelectPicturDialog选择图片对话框。这些对话框的应用以后再说.
接下来将写一个程序包括发送短信 邮件 拨打电话和添加约会的功能
首先在一开始建立的工程中的Form1的MainMenu中添加如图的菜单项,
接着就是在各个菜单项的click事件中添加下边的代码
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
写完这些就可以把传统手机的常用功能学习到了.
需要注意的windows mobile5.0预装的是.net cf1.1 sp3,如果要运行.net cf2.0的程序,需要自己安装.net cf 2.0。
路漫漫其修远兮 吾将上下而求索