Windows mobile l.jpg
This presentation is the property of its rightful owner.
Sponsored Links
1 / 56

Windows Mobile 原生代码开发的新功能 PowerPoint PPT Presentation


  • 205 Views
  • Uploaded on
  • Presentation posted in: General

Windows Mobile 原生代码开发的新功能. 高惠杰 合作伙伴技术支工程师 合作伙伴支持部 微软全球技术支持中心 大中华区. 我们将会讨论的新功能. Softkeys - 软键 State and Notification Broker - 状态提醒 Sound - 声音设置 Imaging - 图像操作 POOM - Pocket Outlook 对象模型 GPS – 全球定位系统 Messaging – 消息应用程序 ActiveSync – 同步控制 Picture Picker – 图像选择器

Download Presentation

Windows Mobile 原生代码开发的新功能

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Windows mobile l.jpg

Windows Mobile原生代码开发的新功能

高惠杰

合作伙伴技术支工程师

合作伙伴支持部

微软全球技术支持中心 大中华区


Slide3 l.jpg

我们将会讨论的新功能

  • Softkeys - 软键

  • State and Notification Broker - 状态提醒

  • Sound - 声音设置

  • Imaging - 图像操作

  • POOM - Pocket Outlook 对象模型

  • GPS –全球定位系统

  • Messaging –消息应用程序

  • ActiveSync –同步控制

  • Picture Picker –图像选择器

  • Contact Picker –联系人选择器

  • ExitWindowsEx –重新启动

  • QueryPolicy –安全策略查询

  • GetDeviceUniqueID –得到设备标识


Slide4 l.jpg

我们不会讨论的新功能

  • DirectDraw / Direct3D请参见《用 DirectX 开发 Windows Mobile 游戏》

  • Windows Media Player请参见《Windows CE 5.0 的多媒体技术》

  • SQL Server CE / SQL Server Mobile请参见《SQL CE 的演进 - SQL Server 2005 移动版》

  • 托管应用程序开发请参见《Windows Mobile 5.0 中新的托管代码API以及控件》

  • Visual Studio 2005, MFC, ATL…请参见《在VS .NET 2005 中移动智能设备开发 》


Pocket pc softkeys l.jpg

Pocket PC SoftKeys - 软键

  • SHCreateMenuBar


Command bars l.jpg

原有的 Command Bars

IDR_MYAPP_CMDBAR RCDATA

BEGIN

IDR_MAIN_MENU,

2,

I_IMAGENONE, IDM_DRAW, TBSTATE_ENABLED,

TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE, IDS_DRAW, 0, NOMENU,

I_IMAGENONE, 0, TBSTATE_ENABLED,

TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_MENU, 0, 0,

END


Command bars7 l.jpg

原有的 Command Bars

IDR_MYAPP_CMDBAR RCDATA

BEGIN

IDR_MAIN_MENU,

2,

I_IMAGENONE, IDM_DRAW, TBSTATE_ENABLED,

TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE, IDS_DRAW, 0, NOMENU,

I_IMAGENONE, 0, TBSTATE_ENABLED,

TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_MENU, 0, 0,

END

X


Softkeys l.jpg

Softkeys –软键

  • SHCMBF_HMENU

cbi.dwFlags = SHCMBF_HMENU;

cbi.nToolBarId = IDM_MYMENU;

SHCreateMenuBar(&cbi);


Visual studio l.jpg

Visual Studio


Visual studio10 l.jpg

Visual Studio

IDR_MYAPP_CMDBAR RCDATA

BEGIN

IDR_MAIN_MENU,

2,

I_IMAGENONE, IDM_DRAW, TBSTATE_ENABLED,

TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE, IDS_DRAW, 0, NOMENU,

I_IMAGENONE, 0, TBSTATE_ENABLED,

TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_MENU, 0, 0,

END


Slide11 l.jpg

SHEnableSoftkey(

HWND hwndMenuBar,

UINT uid, // command id or index

BOOL bByIndex,

BOOL bEnable);

启用/禁用软键

SDK中的例子: ShellApiDemo


Slide12 l.jpg

SoftKey 演示程序


State and notification broker l.jpg

State And Notification Broker - 状态提醒

  • 通过统一的方式来提供设备状态的提醒功能


Slide14 l.jpg

典型的提醒功能

  • 电话

    • 未接来点

    • 电话状态

    • 来电显示信息

  • 网络连接状况

    • WiFi, GPRS, 调制解调器,通过桌面电脑

  • 日程表

    • 当前的约会

    • 即将到来的约会


Slide15 l.jpg

典型的提醒功能

  • 通信提醒

    • 未阅读的E-mail、短消息数量

  • 其他提醒

    • 显示方向(横向、纵向)

    • 放入同步架中

  • 可以由ISV自定义扩展


Snapi h l.jpg

ActiveApplication

DisplayRotation

KeyboardPresent

CradlePresent

CameraPresent

MessagingSmsUnread

MessagingMmsUnread

MessagingVoiceMailTotalUnread

MessagingVoiceMail1Unread

MessagingVoiceMail2Unread

MessagingActiveSyncEmailUnread

MessagingTotalEmailUnread

MessagingOtherEmailUnread

MessagingLastEmailAccountName

MessagingSmsAccountName

MessagingMmsAccountName

MessagingActiveSyncAccountName

TasksActive

TasksHighPriority

TasksDueToday

TasksOverdue

CalendarNextAppointmentSubject

CalendarNextAppointmentLocation

CalendarNextAppointmentStart

CalendarNextAppointmentEnd

MediaPlayerAlbumArtist

MediaPlayerTrackBitrate

MediaPlayerTrackTitle

MediaPlayerAlbumTitle

MediaPlayerTrackArtist

MediaPlayerTrackNumber

MediaPlayerTrackGenre

MediaPlayerTrackTimeElapsed

PowerBatteryStrength

PowerBatteryState

PowerBatteryBackupStrength

PowerBatteryBackupState

Time

Date

PhoneSignalStrength

PhoneOperatorName

PhoneTalkingCallerName

PhoneActiveCallCount

PhoneProfileName

PhoneProfile

PhoneCellBroadcast

CalendarNextAppointmentHasConflict

OwnerName

OwnerPhoneNumber

OwnerEmail

OwnerNotes

ActiveSyncStatus

PhoneMissedCalls

HeadsetPresent

CarKitPresent

SpeakerPhoneActive

PhoneMultiLine

PhoneSimFull

PhoneNoSim

PhoneInvalidSim

PhoneBlockedSim

PhoneRadioOff

PhoneRadioPresent

PhoneRingerOff

PhoneLine1Selected

PhoneLine2Selected

PhoneRoaming

PhoneCallForwardingOnLine1

PhoneMissedCall

PhoneActiveDataCall

PhoneCallBarring

PhoneCallOnHold

PhoneConferenceCall

PhoneIncomingCall

PhoneCallCalling

PhoneGprsCoverage

PhoneNoService

PhoneSearchingForService

PhoneHomeService

Phone1xRttCoverage

PhoneCallTalking

PhoneCallForwardingOnLine2

CalendarNextAppointment

CalendarNextAppointmentBusyStatus

CalendarNextAppointmentCategories

CalendarAppointment

CalendarAppointmentSubject

CalendarAppointmentLocation

CalendarAppointmentStartTime

CalendarAppointmentEndTime

CalendarAppointmentHasConflict

CalendarAppointmentBusyStatus

CalendarAppointmentCategories

SnApi.h中的各种状态

CalendarHomeScreenAppointment

CalendarHomeScreenAppointmentSubject

CalendarHomeScreenAppointmentLocation

CalendarHomeScreenAppointmentStartTime

CalendarHomeScreenAppointmentEndTime

CalendarHomeScreenAppointmentHasConflict

CalendarHomeScreenAppointmentBusyStatus

CalendarHomeScreenAppointmentCategories

PhoneIncomingCallerName

PhoneLastIncomingCallerName

PhoneIncomingCallerNumber

PhoneLastIncomingCallerNumber

PhoneIncomingCallerContactPropertyName

PhoneLastIncomingCallerContactPropertyName

PhoneIncomingCallerContactPropertyID

PhoneLastIncomingCallerContactPropertyID

PhoneIncomingCallerContact

PhoneLastIncomingCallerContact

PhoneTalkingCallerNumber

PhoneTalkingCallerContactPropertyName

PhoneTalkingCallerContactPropertyID

PhoneTalkingCallerContact

ConnectionsCount

ConnectionsBluetoothCount

ConnectionsBluetoothDescriptions

ConnectionsCellularCount

ConnectionsCellularDescriptions

ConnectionsNetworkCount

ConnectionsNetworkDescriptions

ConnectionsNetworkAdapters

ConnectionsDesktopCount

ConnectionsDesktopDescriptions

ConnectionsProxyCount

ConnectionsProxyDescriptions

ConnectionsModemCount

ConnectionsModemDescriptions

ConnectionsUnknownCount

ConnectionsUnknownDescriptions

ConnectionsVpnCount

ConnectionsVpnDescriptions

CalendarEvent

CalendarEventSubject

CalendarEventLocation

CalendarEventStartTime

CalendarEventEndTime

CalendarEventHasConflict

CalendarEventBusyStatus

CalendarEventCategories


Broker l.jpg

如何与Broker进行交流

  • 注册表

    • 标准的Win32 注册表API

    • RegistryGetDWORD()

    • RegistrySetDWORD()

    • RegistrySetString()

    • RegistryGetString()

SDK中的例子: SyncManager


Transient notifications l.jpg

Transient Notifications瞬时提醒

  • 仅当应用程序运行时产生提醒

  • 提醒方式

    • Window Message –窗口消息

    • CE Message Queue – CE消息队列

    • Callback –函数回调


Transient notifications19 l.jpg

Transient Notifications瞬时提醒

#include <RegExt.h>

#include <SnApi.h>

// 设置提醒句柄

HREGNOTIFY hNotify = NULL;

RegistryNotifyWindow(

SN_PHONESIGNALSTRENGTH_ROOT,

SN_PHONESIGNALSTRENGTH_PATH,

SN_PHONESIGNALSTRENGTH_VALUE,

hWnd,

WM_MY_WINDOW_MESSAGE,

dwUserDefinedValue,

NULL,

&hNotify);


Conditional notifications l.jpg

Conditional Notifications条件提醒

  • DWORD 条件运算符

    • ==, !=, >, >=, <, <=

  • 字符串条件运算符

    • ==, !=, >, >=, <, <=, contains, starts with, ends with

  • 对于二进制数据不提供条件提醒


Signal 15 l.jpg

样例: Signal < 15%

// Set up the condition

NOTIFICATIONCONDITION condition;

condition.ctComparisonType = REG_CT_LESS;

condition.TargetValue.dw = 15;

condition.dwMask = 0xFFFFFFFF;

// Set up the notification

HREGNOTIFY hNotify = NULL;

RegistryNotifyWindow(SN_PHONESIGNALSTRENGTH_ROOT,

SN_PHONESIGNALSTRENGTH_PATH,

SN_PHONESIGNALSTRENGTH_VALUE,

hWnd,

WM_MY_WINDOW_MESSAGE,

dwUserDefinedValue,

&condition,

&hNotify);


Persistent notifications l.jpg

Persistent Notifications持久提醒

  • 如果应用程序尚未运行,会被Broker启动

  • 提醒方式

    • 命令行

    • 窗口消息

  • 重启后仍然有效


Persistent notifications23 l.jpg

Persistent Notifications持久提醒

NOTIFICATIONCONDITION condition;

condition.ctComparisonType = REG_CT_LESS;

condition.TargetValue.dw = 15;

condition.dwMask = 0xFFFFFFFF;

RegistryNotifyApp(

SN_PHONESIGNALSTRENGTH_ROOT,

SN_PHONESIGNALSTRENGTH_PATH,

SN_PHONESIGNALSTRENGTH_VALUE,

L“MyCompany.SignalStrengthLow”,

L“MyApp.exe”,

L“MyWindowClass”,

L“MyWindow”,

WM_MY_WINDOW_MESSAGE,

RNAF_NONAMEONCMDLINE,

&condition);


Sound settings l.jpg

Sound Settings - 声音设置

  • Soundfile.h

  • 管理用户的声音设置

    • 铃声设置

    • 全局声音设置


Sound settings25 l.jpg

Sound Settings - 声音设置

  • 铃声设置

SNDFILEINFO fi;

fi.szPathName = “MyRing.wav”;

fi.sstType = SND_SOUNDTYPE_FILE;

SndSetSound(SND_EVENT_RINGTONELINE1, &fi, TRUE);


Sound settings26 l.jpg

Sound Settings - 声音设置


Sound settings27 l.jpg

Sound Settings - 声音设置

  • 全局声音设置 (仅对Pocket PC)

SNDFILEINFO fi;

fi.sstType = SND_SOUNDTYPE_VIBRATE;

// 也可以是 SND_SOUNDTYPE_ON

// 或者是 SND_SOUNDTYPE_NONE

SndSetSound(SND_EVENT_ALL, &fi, TRUE);


Slide28 l.jpg

设置Pocket PC全局音量


Slide29 l.jpg

EDB –嵌入式数据库

EDB代替了CEDB

非常相似的API


Imaging l.jpg

Imaging –图像操作

  • IImagingFactory, IImage

  • png, bmp, gif, jpg, ico


Imaging31 l.jpg

Imaging –图像操作

if (S_OK == CoCreateInstance (CLSID_ImagingFactory,

NULL, CLSCTX_INPROC_SERVER,

IID_IImagingFactory,

(void **)&pImgFactory))

{

if (S_OK == pImgFactory->CreateImageFromFile(

L"flower.jpg",

&pImage)

{

pImage->Draw(hdc, &rc, NULL);

pImage->Release();

}

pImgFactory->Release();

}

SDK中的例子: Imaging


Slide32 l.jpg

图像操作


Poom pocket outlook l.jpg

POOMPocket Outlook对象模型

  • Custom Properties自定义属性

  • Bulk Properties 同时处理大量属性

  • Notifications

  • Category list


Slide34 l.jpg

POOM –自定义属性

static const WCHAR * rgszPropNames[] =

{

L"HealthInsuranceProvider",

L"BloodType",

L"BloodPressure",

L"Allergies"

};

CEPROPID rgPropIDs[4] = {0};

polApp->GetIDsFromNames (4,

rgszPropNames,

PIM_CREATE | CEVT_LPWSTR,

rgPropIDs);

SDK中的例子: MedicalHistory


Slide35 l.jpg

POOM –同时处理大量属性

CEPROPID rgPropIDs[4] ;

CEPROPVAL *pVals = NULL;

pItem->GetProps(

rgPropIDs,

CEDB_ALLOWREALLOC,

4,

&pVals,

&cbBuffer,

heap);

SDK中的例子: MedicalHistory


Slide36 l.jpg

POOM –状态提醒

如何注册

  • 如何注册

propval.propid = PIMPR_FOLDERNOTIFICATIONS;

propval.val.ulVal = PIMFOLDERNOTIFICATION_LOCAL |

PIMFOLDERNOTIFICATION_REMOTE;

pItemFolder->SetProps(0, 1, &propval);

SDK中的例子: CalendarView

SDK中的例子: CalendarView


Slide37 l.jpg

POOM –状态提醒

IPOutlookApp2 *polApp;

polApp->Logon((long)hWnd)

LRESULT CALLBACK WndProc(…) {

switch (msg) {

case PIM_ITEM_CREATED_LOCAL:

case PIM_ITEM_DELETED_LOCAL:

case PIM_ITEM_CHANGED_LOCAL:

case PIM_ITEM_CREATED_REMOTE:

case PIM_ITEM_DELETED_REMOTE:

case PIM_ITEM_CHANGED_REMOTE:

oid = wParam;

olFolder = lParam;


Slide38 l.jpg

联系人自定义属性


Slide39 l.jpg

GPS –全球定位系统

  • GpsApi.h

  • 核心函数调用:

    • GPSOpenDevice()

    • GPSCloseDevice()

    • GPSGetPosition()

    • GPSGetDeviceState()


Slide40 l.jpg

GPS –全球定位系统

#include <GpsApi.h>

HANDLE h;

GPS_POSITION pos;

h = GPSOpenDevice (heventNewPos,

heventDeviceStateChange,

NULL, 0);

GPSGetPosition(h, &pos, 60000, 0);

// 得到 pos.dblLongitude, pos.dblLatitude


Messaging application l.jpg

Messaging Application消息应用程序

  • 控制用户界面

    • MailComposeMessage

    • MailDisplayMessage

    • MailSwitchToFolder

    • MailSwitchToAccount

    • MailSyncMessages

  • CeMapi.h


Activesync l.jpg

ActiveSync - 同步控制

  • ActiveSyncStart()

  • ActiveSyncStop()

  • State and Notification Broker: HKLM\System\State\ActiveSyncSynchronizing

    • None = 0

    • Synchronizing = 1

    • Error = 2

SDK中的例子: SyncManager


Picture picker l.jpg

Picture Picker –图像选择器

同时也支持视频


Picture picker44 l.jpg

Picture Picker –图像选择器

OPENFILENAMEEX ofnex = {0};

ofnex.lStructSize = sizeof(ofnex);

ofnex.ExFlags = OFN_EXFLAG_THUMBNAILVIEW;

ofnex.lpstrFile = new TCHAR [MAX_PATH];

ofnex.nMaxFile = MAX_PATH;

GetOpenFileNameEx(&ofnex);

SDK中的例子: AddContactPicture


Picture picker45 l.jpg

Picture Picker –图像选择器


Slide46 l.jpg

通过摄像头拍摄


Slide47 l.jpg

通过摄像头拍摄

typedef struct {

DWORD cbSize;

HWND hwndOwner;

TCHAR szFile[MAX_PATH];

LPCTSTR pszInitialDir;

LPCTSTR pszDefaultFileName;

LPCTSTR pszTitle;

CAMERACAPTURE_STILLQUALITY StillQuality;

CAMERACAPTURE_VIDEOTYPES VideoTypes;

DWORD nResolutionWidth;

DWORD nResolutionHeight;

DWORD nVideoTimeLimit;

CAMERACAPTURE_MODE Mode;

} SHCAMERACAPTURE;

HRESULT SHCameraCapture (PSHCAMERACAPTURE *pshcc);

SDK Sample: CECamera


Contact picker l.jpg

Contact Picker –联系人选择器


Contact picker49 l.jpg

Contact Picker –联系人选择器

IPOutlookApp2 pApp;

IItem *pItem;

CHOOSECONTACT cc = {0};

cc.cbSize = sizeof (cc);

cc.dwFlags = CCF_CHOOSECONTACTONLY;

cc.hwndOwner = NULL;

ChooseContact (&cc);

pApp->GetItemFromOidEx(cc.oidContactID,

0, &pItem);

SDK中的例子: AddContactPicture


Contact picker50 l.jpg

Contact Picker –联系人选择器

  • 选取联系人

  • 选取特定属性的联系人

  • 通过属性筛选


Slide51 l.jpg

联系人图片


Exitwindowsex l.jpg

ExitWindowsEx –重新启动

  • 可以在非信任的环境中调用

  • PocketPC

    • 重新启动

  • Smartphone

    • 重新启动, 关闭


Querypolicy l.jpg

QueryPolicy安全策略查询

  • QueryPolicy(DWORD dwPolicyId, PDWORD pdwPolicyValue);

  • 可以在非信任的环境中调用

QueryPolicy(SECPOLICY_UNSIGNEDAPPS,

&dwPolicyValue);

if (dwPolicyValue == FALSE)

{ …

}


Getdeviceuniqueid l.jpg

GetDeviceUniqueID得到设备标识

  • 可以在非信任的环境中调用

  • 对于每个应用程序都会产生不同的ID

HRESULT GetDeviceUniqueID(

LPBYTE pbApplicationData,

DWORD cbApplicationData,

DWORD dwDeviceIDVersion,

LPBYTE pbDeviceIDOutput,

DWORD *pcbDeviceIDOutput);

SDK中的例子: GetDeviceID


Slide55 l.jpg

工具及资源

Build

Develop

Websites

msdn.microsoft.com/embedded

msdn.microsoft.com/mobility

Newsgroups

microsoft.public.pocketpc.developer smartphone.developer dotnet.framework.compactframework

microsoft.public.windowsxp.embedded

windowsce.platbuilder

windowsce.embedded.vc

Blogs

blogs.msdn.com/mikehall

blogs.msdn.com/windowsmobilevsdteamnetcfteam

Tools

Windows Mobile 5.0 Eval Kit

Windows CE 5.0 Eval KitWindows XP Embedded Eval Kit


  • Login