Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to managed code development for Windows Mobile Paul Foster

Similar presentations


Presentation on theme: "Introduction to managed code development for Windows Mobile Paul Foster"— Presentation transcript:

1 Introduction to managed code development for Windows Mobile Paul Foster paulfo@microsoft.com

2 Event agenda 18.00 Registration 18:30 Introduction to managed code application development for Windows Mobile 19:30 Break / Refreshments 20:00 Session continued 20:50 Q&A 21:00 Close

3 Agenda Smart Client design Smart Client design Introduction to managed code Introduction to managed code .Net Compact Framework – overview  Design and performance tips  Deployment Windows Mobile 2003 2 nd Edition Windows Mobile 2003 2 nd Edition  Orientation support  DPI support

4 Momentum Continues To Build… 600500400300200100 Source: Gartner Dataquest (Dec. 2003) PC Shipments Unit Shipments (M) 2001 2002 2003 2004 2005 2006 2007 Mobile Device Shipments For Mobile Devices: Mobile device adoption continues to grow Mobile device adoption continues to grow Growing Pocket PC market share Growing Pocket PC market share Smartphones launching, 37+ leading OEMs and 50+ Mobile Operators partners Smartphones launching, 37+ leading OEMs and 50+ Mobile Operators partners New form factors for landscape, high DPI New form factors for landscape, high DPI For Mobile Applications: $5.8 billion market for ISVs by 2006 $5.8 billion market for ISVs by 2006 (source: Forrester, 2002) Customers demand more mobile applications Customers demand more mobile applications (source: Handango, 2003) Mobile Operators report monthly ARPU increases of 25% on Windows Mobile-based devices Mobile Operators report monthly ARPU increases of 25% on Windows Mobile-based devices 700 applications added to Mobile Application Catalog since launch of Mobile2Market program last year 700 applications added to Mobile Application Catalog since launch of Mobile2Market program last year 58% want more Personal productivity apps 58% want more Business and professional apps 54% want more Games 44% want more Utilities

5 Windows Mobile Roadmap Richer Platform Capabilities.NET CF “Whidbey” MFC 8.0, ATL 8.0 Broad managed code support Notification broker, Location, Camera, Watson, D3DM,.NET CF SP2 VGA (PPC) QVGA (SP) Square Landscape ATL 4.2,.NET CF Enhanced Emulator Configuration Mgr, Bluetooth, SMS MFC, ATL Active Sync Connection Mgr MAPI OBEX Telephony MFC Win32, POOM MFC Win32, POOM Better Development VS “Whidbey” (C#, VB.NET, C++) eVC 3 (C++) eVC 4 (C++) VS.NET 2003 (C#, VB.NET) eVC 3 (C++) eVC 4 (C++) VS.NET 2003 (C#, VB.NET) eVC 3 (C++) eVB 3 (VB) Core OS WinCE “Macallan” WinCE 4.2 WinCE 3.0 WinCE 3.0 WinCE 3.0 More Device Choices Future Windows Mobile 2003 Second Edition 200320022000

6 Smart Client design For.Net Compact Framework

7 The Mobile Device Universe Infrastructure Servers, e.g. Network Operators Tools Web services Clients User Experiences & Solutions AuthenticationSMSVoice Calls Subscriber DBMMSData Calls PersonalizationBillingetc…

8 Police Force case study Business driver Business driver  Need to improve officer productivity Goal Goal  Improve productivity to eqv. 100 additional officers Very public project Very public project  Council tax contribution to fund project Results Results  PNC search results ~4 seconds back on device

9 The need for a Smart Client Application supports key business activities Application supports key business activities User needs to ‘fire and forget’ tasks User needs to ‘fire and forget’ tasks Device security requires code on the client Device security requires code on the client

10 What is a Smart Client design? Client installed app using local CPU Client installed app using local CPU Works in both connect and disconnected network states Works in both connect and disconnected network states In-built application change management In-built application change management

11 Smart Client architecture Why consciously factor code? Why consciously factor code?  Increased abstraction  Decreased complexity  Increase reusability How to factor code? How to factor code?  Move code (functions, classes, assemblies)  Change code visibility  Share or Split implementations

12 Specific Factoring Opportunities The.NET Compact Framework has additional opportunities to gain value by factoring The.NET Compact Framework has additional opportunities to gain value by factoring Divide them into two key sub-groups: Divide them into two key sub-groups:  Cross-tier factoring  Intra-tier (on-device) factoring

13 Multi-tier Factoring How much can you put on a server? How much can you put on a server? How will you handle being unable to reach the server? How will you handle being unable to reach the server? Duplication of sending (idempotence) Duplication of sending (idempotence) Mobile apps must be able to continue running while mobile Mobile apps must be able to continue running while mobile Client data stores: XML, SQLCE, flat files… Client data stores: XML, SQLCE, flat files…

14 Cross-tier factoring Device application functionality Server application functionality Unreliable wireless connectivity

15 Intra-tier Factoring Strict separation of UI and client-side logic (UI Processing code) Strict separation of UI and client-side logic (UI Processing code)  User interface code handles the specifics of the screen drawing  All logic associated with client validation, logic, rules, etc., should be considered UI Processing Allows reuse of the maximum possible subset of code Allows reuse of the maximum possible subset of code

16 Device Variety.NET Compact Framework allows for unified API for many devices.NET Compact Framework allows for unified API for many devices The underlying form factors can be quite diverse, though. The underlying form factors can be quite diverse, though. This means input methods may be different This means input methods may be different Consider factoring to allow for additional devices to be supported later. Consider factoring to allow for additional devices to be supported later.

17 N-tier application architecture Operational ManagementSecurityCommunication UI Components UI Process Components Business Workflows Service Interfaces Business ComponentsBusiness Entities Users Data SourcesServices Data Access Logic ComponentsService Agents

18 Introduction to the.Net Compact Framework

19 Display USB or Serial Processor Memory GSM/GPRS CDMA/1xRTT Device Hardware WiFi Bluetooth Radio Drivers Windows Mobile CE DB ActiveSync Pocket Outlook Pocket Internet Explorer Windows Media Player Windows CE Software Platform (APIs) Home Screen User Interface/Shell HTML Control GAPI Remote API Configuration Bluetooth Security Connection Manager TAPI SMS MAPI POOM ActiveSync Multimedia Communication Device Management Presentation ADO CE XML CE DB OLE DB Data Access Native Win32 MFCATL Managed.NET Compact Framework Server side ASP.NET Mobile Controls Native Win32 MFCATL Managed.NET Compact Framework Server side ASP.NET Mobile Controls Windows Mobile Development Platform : Today Embedded VC++ Visual Studio.NET

20 Display USB or Serial Processor Memory GSM/GPRS CDMA/1xRTT Device Hardware WiFi Bluetooth Radio Drivers Windows Mobile CE DB ActiveSync SQL CE Pocket Outlook Pocket Internet Explorer Windows Media Player Windows CE Software Platform (APIs) Home Screen User Interface/Shell HTML Control DOM GAPI Camera D3DM Location* Remote API Configuration* Bluetooth Statsor* Pocket Watson Connection Manager TAPI* SMS* MAPI* POOM* Multimedia Communication Device Management Presentation SQL CE ADO CE XML CE DB OLE DB Data Access Native Win32 MFCATL Managed.NET Compact Framework Server side ASP.NET Mobile Controls Orange = Added/Enhanced in Future Windows Mobile Platform * = Managed wrappers This Session Will Focus On … Visual Studio “Whidbey”

21 .NET Compact Framework Today… Service Pack 2 Improvements Service Pack 2 Improvements  Download it today from MSDN Download it today from MSDN Download it today from MSDN  Performance Gains over RTM  ~ 40% faster XML  ~ 20% faster ADO.NET  ForeColor and BackColor!!!  Keyboard Events  Support for Future Devices Developer Adoption Developer Adoption  Fourth most active.NET newsgroup  Developer Focused Web sites like  http://www.OpenNetCF.org http://www.OpenNetCF.org  http://www.dotnetdn.com/ http://www.dotnetdn.com/  http://www.pocketPCDN.com http://www.pocketPCDN.com  http://msdn.microsoft.com/ mobility / http://msdn.microsoft.com/ mobility / http://msdn.microsoft.com/ mobility /  Information direct from product team members

22 .NET Compact Framework Today… Third Party Controls and Libraries ComponentOne Studio for Mobile Devices ComponentOne Studio for Mobile Devices /n Software’s IP*Works for.NET Compact Framework /n Software’s IP*Works for.NET Compact Framework InstallShield Developer Mobile Edition InstallShield Developer Mobile Edition Odyssey CFCom Odyssey CFCom Preemptive Dotfuscator Preemptive Dotfuscator And More! And More!

23 Framework Size Framework size (RAM or ROM) Framework size (RAM or ROM)  ~1.5 MB Running RAM needs Running RAM needs  1 MB+ (depends on app) Typical application sizes Typical application sizes  5 - 100 KB  Apps often smaller due to use of platform features in the framework

24 The.NET Compact Framework System System.DataSystem.Xml System.Web Globalization Text Security Collections Resources Reflection Net IO Threading Diagnostics ADO.NET SqlServerCe SqlClientXmlDocument common language runtime InteropServices Security Services Description Discovery Protocols System.Drawing Drawing2D Text System.Windows.Forms DesignComponentModel Reader/Writers

25 The.NET Common Language Runtime Core functionality for execution Core functionality for execution No worries about initialized pointers! No worries about initialized pointers! Provides garbage collection services Provides garbage collection services Good performance through JIT compilation Good performance through JIT compilation Straightforward error handling with exceptions Straightforward error handling with exceptions Support for Win32 APIs through platform invocation Support for Win32 APIs through platform invocation All these benefits, and you can pick your development favourite language too! All these benefits, and you can pick your development favourite language too! System System.DataSystem.Xml System.Web Globalization Text Security Collections Resources Reflection Net IO Threading Diagnostics ADO.NET SqlServerCe SqlClient XmlDocument common language runtime InteropServices Remoting Serialization Security Services Description Discovery Protocols System.Drawing Drawing2D Text System.Windows.Forms DesignComponentModel Reader/Writers

26 Compiler Assembly Common Language Runtime DEVELOPMENT C#J#VBCobol… MSILMetadataResources public static void Main(String[] args ) { String usr; FileStream f; StreamWriter w; try { usr=Environment.GetEnvironmentVariable("USERNAME"); f=new FileStream(“C:\\test.txt",FileMode.Create); w=new StreamWriter(f); w.WriteLine(usr); w.Close(); } catch (Exception e){ Console.WriteLine("Exception:"+e.ToString()); } public static void Main(String[] args ) { String usr; FileStream f; StreamWriter w; try { usr=Environment.GetEnvironmentVariable("USERNAME"); f=new FileStream(“C:\\test.txt",FileMode.Create); w=new StreamWriter(f); w.WriteLine(usr); w.Close(); } catch (Exception e){ Console.WriteLine("Exception:"+e.ToString()); } Source code

27 Compiler AssemblyDEVELOPMENTC#J#VBCobol… MSILMetadataResources public static void Main(String[] args ) { String usr; FileStream f; StreamWriter w; try { usr=Environment.GetEnvironmentVariable("USERNAME"); f=new FileStream(“C:\\test.txt",FileMode.Create); w=new StreamWriter(f); w.WriteLine(usr); w.Close(); } catch (Exception e){ Console.WriteLine("Exception:"+e.ToString()); } public static void Main(String[] args ) { String usr; FileStream f; StreamWriter w; try { usr=Environment.GetEnvironmentVariable("USERNAME"); f=new FileStream(“C:\\test.txt",FileMode.Create); w=new StreamWriter(f); w.WriteLine(usr); w.Close(); } catch (Exception e){ Console.WriteLine("Exception:"+e.ToString()); } Source code Application Directory Global Assembly Cache (GAC) Common Language Runtime AssemblyDEVELOPMENTDEPLOYMENT SetupCopyBrowser Download Cache Install

28 Debug Engine IL to Native Compiler Application Directory SetupCopyBrowser Download Cache Global Assembly Cache (GAC) Assembly on Target Machine Common Language Runtime AssemblyDEVELOPMENTDEPLOYMENT Install EXECUTION AssemblyLoader Security Class Loader Native.exe + GC table Code Manager Garbage Collection Exception Manager Thread Support COM Interop Policy <CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="Nothing" Name="All_Code" Description="Code group grants no permissio ns and forms the root of the code group tree."> <IMembershipCondition clas s="AllMembershipCondition" version="1"/> <CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="FullTrust"

29 Networking Support System.Net Sockets Sockets  Provides synchronous and asynchronous  Multiple protocols Streams Streams  Built on top of sockets  Synchronous and asynchronous HTTP request and response HTTP request and response  Use stream model  Requires no user knowledge of HTTP System System.DataSystem.Xml System.Web Globalization Text Security Collections Resources Reflection Net IO Threading Diagnostics ADO.NET SqlServerCe SqlClient XmlDocument common language runtime InteropServices Remoting Serialization Security Services Description Discovery Protocols System.Drawing Drawing2D Text System.Windows.Forms DesignComponentModel Reader/Writers

30 Web Service Support System.Web Calling Web services Calling Web services All encoding types All encoding types Synchronous and asynchronous invocation Synchronous and asynchronous invocation Basic and Digest authentication Basic and Digest authentication Secure Sockets Layer support for encryption (SSL) Secure Sockets Layer support for encryption (SSL) Custom SOAP headers Custom SOAP headers Read more about it! Read more about it!  Consuming XML Web Services with the Microsoft.NET Compact Framework http://msdn.microsoft.com/mobility/understanding/articles/default.aspx? pull=/library/en-us/dnnetcomp/html/netcfwebservices.asp System System.DataSystem.Xml System.Web Globalization Text Security Collections Resources Reflection Net IO Threading Diagnostics ADO.NET SqlServerCe SqlClient XmlDocument common language runtime InteropServices Remoting Serialization Security Services Description Discovery Protocols System.Drawing Drawing2D Text System.Windows.Forms DesignComponentModel Reader/Writers

31 Data Support System.Data Handling data offline with DataSet Handling data offline with DataSet Common data model from server to PC to device Common data model from server to PC to device Extensible ADO.NET provider model Extensible ADO.NET provider model SQL Server (System.Data.SqlClient) SQL Server (System.Data.SqlClient) SQL Server CE (System.Data.SqlServerCe) SQL Server CE (System.Data.SqlServerCe)  Managed access to rich, robust device database  Efficient, complex querying  Enables online/offline applications  Data synchronization to SQL Server with server and client tracking System System.DataSystem.Xml System.Web Globalization Text Security Collections Resources Reflection Net IO Threading Diagnostics ADO.NET SqlServerCe SqlClientXmlDocument common language runtime InteropServices Remoting Serialization Security Services Description Discovery Protocols System.Drawing Drawing2D Text System.Windows.Forms DesignComponentModel Reader/Writers

32 Data Best Practices If data is local…instead of DataSet… If data is local…instead of DataSet…  Leverage SQL Server CE native in-proc database  Query data using DataReader  Use TableDirect command type for fast index searches  Equivalent to “SELECT * FROM foo WHERE bar > 3”  Limit open SqlCeCommand/DataReaders  Dispose when complete If data is remote… If data is remote…  Use SQL Server CE replication  When using Web Services  Use DiffGrams to read and write DataSets to limit data transfer  Save data locally in SQL Server CE for faster access and storage  Don’t save remote DataSets as XML to device  If you do, save Schema as well

33 XML Best Practices for Managing Large XML Data Files Use XmlTextReader and XmlTextWriter Use XmlTextReader and XmlTextWriter  Smaller memory footprint than using XmlDocument  XmlTextReader is a pull model parser which only reads a “window” of the data Design XML schema first, then code Design XML schema first, then code  Understand the structure of your XML document  Use elements to group  Allows use of Skip() in XmlTextReader  Use attributes to reduce size

34 XML Best Practices for Serialization Use XmlTextReader and XmlTextWriter Use XmlTextReader and XmlTextWriter  XmlDocument builds a generic, untyped object model using a tree  Type stored as string  Use XmlConvert to convert each element to appropriate managed type for efficiency  e.g. Int32 Design XML schema first, then code Design XML schema first, then code  Use elements for objects and arrays  Use attributes for simple properties and fields

35 XML And Data.NET Compact Framework 2.0 Performance Vastly improved XmlTextReader (SP2) and XmlTextWriter Vastly improved XmlTextReader (SP2) and XmlTextWriter XmlSerializer XmlSerializer Improved ADO.NET performance with SQL Server CE 3.0 Improved ADO.NET performance with SQL Server CE 3.0  SqlCeResultSet  Direct access to scrollable, updatable cursor

36 User Interface Design Wide range of controls Wide range of controls Supported controls are tailored to each device Supported controls are tailored to each device Rich designer support in Visual Studio.NET Rich designer support in Visual Studio.NET Some desktop functionality isn’t supported Some desktop functionality isn’t supported  ActiveX Controls  Printing  Drag and Drop  GDI+ (transparency) System System.DataSystem.XmlSystem.WebGlobalization Text Security Collections Resources Reflection Net IO Threading Diagnostics ADO.NET SqlServerCe SqlClient XmlDocument common language runtime InteropServices Remoting Serialization Security Services Description Discovery Protocols System.Drawing Drawing2D TextSystem.Windows.FormsDesignComponentModel Reader/Writers

37 Supported Controls System.Windows.Forms ButtonCheckBoxComboBoxContextMenuDataGridDomainUpDownFileOpenDialog Supported controls Supported controls FileSaveDialogHScrollBarImageList Input Panel LabelListBoxListViewMainMenuNumericUpDownPanelPictureBoxProgressBarRadioButtonStatusBarTabControlTextBoxTimerToolBar Track Bar TreeViewVScrollBar Unavailable controls Unavailable controls CheckedListBoxColorDialogErrorProvider HelpProviderLinkLabelNotifyIcon ToolTipSplitterFontDialog

38 Control Extensibility System.Windows.Forms Add functionality to existing controls Add functionality to existing controls  Create a text box that only supports numeric text entry  Add additional properties specific to your application Create your own new controls Create your own new controls  Many 3 rd party examples, such as a signature capture control Article with source code: Article with source code:  Microsoft®.NET Compact Framework-based DateTimePicker Control http://msdn.microsoft.com/mobility/understanding/articles/default.aspx?p ull=/library/en-us/dnnetcomp/html/netcfdatetimepicker.asp

39 Windows Forms Best Practices Load and cache Forms in the background Load and cache Forms in the background  Populate data separate from Form.Show()  Pre-populate data, or  Load data async to Form.Show() Parent controls top-down Parent controls top-down  e.g. Form  panels  controls Use BeginUpdate/EndUpdate when it is available Use BeginUpdate/EndUpdate when it is available  e.g. ListView, TreeView Use SuspendLayout/ResumeLayout when repositioning controls Use SuspendLayout/ResumeLayout when repositioning controls Keep event handling code tight Keep event handling code tight  Process bigger operations asynchronously  Blocking in event handlers will affect UI responsiveness

40 Form Management The Form Flow Challenge The Form Flow Challenge  No Multiple Document Interface  Multi form input more common  Which form to display next?  Hide or destroy current form? Solutions Solutions  Dynamic form construction  Forms manager  Wizard based input (e.g. tight scripting of forms)

41 Form Management Application Kernel Web Service Interface Local Store (SQL CE ) Main FormCollect Form Inspect Form Truck Form Form Manager Main

42 Identifying The Top Pitfalls The most common problems Putting synchronous code in Form_Load Putting synchronous code in Form_Load Putting too much code in Form_Load Putting too much code in Form_Load Assuming connectivity (implicitly) Assuming connectivity (implicitly) Mixing user interface code and processing Mixing user interface code and processing Architecting based on incomplete or non- representative tests Architecting based on incomplete or non- representative tests Accepting default timeouts Accepting default timeouts Misapplying UI metaphors (desktop to mobile) Misapplying UI metaphors (desktop to mobile)

43 CRM Mobile Architecture Dynamic Offline Store SQL CE Store Metadata driven Data Access Datasets and Data Readers Wrapped with our Metadata APIs Metadata Driven Biz Logic C# Code for Offline Business Logic Metadata Driven UI Dynamic WinForms Metadata and Data Sync Metadata changes are downloaded on the fly SQL CE schemas are altered on the fly Data is downloaded without replication using Standard XML messages Metadata Driven Wire Formats Dataset to message transforms are metadata driven Web Services for Connected Scenarios SQL CE RDA for async reliable messaging

44 Interoperability Platform Invocation (P/Invoke) Platform Invocation (P/Invoke)  Allows users to call custom native code and Windows APIs  Declare statement in Visual Basic  DLLImport Attribute in C# Callbacks Callbacks  No support for direct native to managed function calls  Use MessageWindow  Part of Microsoft.WindowsCE.Forms COM Interoperability COM Interoperability  Not directly supported in this version  Need to create native wrapper  Partner solutions available (Odyssey Software)

45 Interoperability Get More Information! Articles Articles  An Introduction to P/Invoke and Marshaling on the Microsoft.NET Compact Framework http://msdn.microsoft.com/mobility/understanding/articles/default.aspx? pull=/library/en-us/dnnetcomp/html/netcfintrointerp.asp  Advanced P/Invoke on the Microsoft.NET Compact Framework http://msdn.microsoft.com/mobility/understanding/articles/default.aspx? pull=/library/en-us/dnnetcomp/html/netcfadvinterop.asp

46 Performance Principles In general… Less code is faster code Less code is faster code Fewer objects are better for performance Fewer objects are better for performance Recycle and re-use expensive resources Recycle and re-use expensive resources Batch work where possible Batch work where possible Initialize lazily Initialize lazily Do work in the background to affect “perceived” performance Do work in the background to affect “perceived” performance  Use threads and async calls Understand what the APIs are doing Understand what the APIs are doing

47 Application deployment A mobile Smart Client example

48 Application Deployment Visual Studio.NET provides auto-generation of simple CAB files for ActiveSync Visual Studio.NET provides auto-generation of simple CAB files for ActiveSync  Include application and dependant references  Does not include the runtime  Does not include other products that the app requires (e.g. SQL Server CE) Temporary files are kept if user wants to customize the cab file contents Temporary files are kept if user wants to customize the cab file contents

49 Self-updating applications Application event triggers update enquiry Application event triggers update enquiry Updater applet calls web service with version and platform data Updater applet calls web service with version and platform data Web service indicates new version and location Web service indicates new version and location Updater asynchronously acquires cab Updater asynchronously acquires cab Updater executes cab causing install Updater executes cab causing install New application version installed New application version installed

50 Self-updating architecture Application V1.0 Updater Web Service XML Spec CAB \downloads CAB Application V1.1 Async download CAB executed New version http://msdn.microsoft.com/library/default.asp Creating Self-Updating Applications With the.NET Compact Framework By Alex Feinman OpenNETCF.org

51 Windows Mobile 2003 2 nd Edition

52 Windows Mobile 2003 2 nd edition Screen orientation Screen orientation High DPI support High DPI support ActiveSync programming model ActiveSync programming model Today screen selection API Today screen selection API.Net Compact Framework SP2 in ROM.Net Compact Framework SP2 in ROM

53 Developer resources Windows Mobile developer downloads Windows Mobile developer downloads http://www.microsoft.com/windowsmobile/resources /downloads/developer/default.mspx http://www.microsoft.com/windowsmobile/resources /downloads/developer/default.mspx http://www.microsoft.com/windowsmobile/resources /downloads/developer/default.mspx http://www.microsoft.com/windowsmobile/resources /downloads/developer/default.mspx Developer Resource kit Developer Resource kit  White papers  Samples Windows Mobile 2003 2 nd Edition emulators for PPC and Smartphone Windows Mobile 2003 2 nd Edition emulators for PPC and Smartphone eVC V4 SP3 eVC V4 SP3

54 Types Of Orientations & Screens Portrait240x320Landscape320x240 Square 240x240

55 Application Impact Fit content to the window Fit content to the window Change the content Change the content Change layout Change layout Design for square Design for square

56 Fit Content To Window Portrait Landscape

57 Change The Content Content may need to change when orientation changes Content may need to change when orientation changes Portrait Landscape

58 Change The Layout Portrait Landscape

59 Design For Square Portrait Landscape Square

60 What Happens? Pocket PC OS actions: Pocket PC OS actions:  Call to ChangeDisplaySettingsEx() occurs  The display driver and touch screen driver are notified of the orientation change  The shell is notified of the orientation change

61 Supporting Orientation Change Full Screen application Full Screen application  Resize done by the shell  Respond to Resize event (WM_SIZE) and resize child windows Dialogs Dialogs  Design new dialogs for square screen  Consider using property pages  Re-layout content  Use Replacement controls Menus Menus  Design for square screen  Fit without scrolling in all orientations

62 Future Device Orientations Orientations Resolutions Resolutions Displays And Layout.NET Compact Framework 1.0 Service Pack 2 (today).NET Compact Framework 1.0 Service Pack 2 (today)  Automatically provides scrolling Form contents for non-portrait displays  Form.Resize event  Automatically provides pixel doubling for high resolution  White paper on MSDN: Developing Screen Orientation-Aware Applications Developing Screen Orientation-Aware Applications Developing Screen Orientation-Aware Applications

63 Re-layout content Create layout Classes from Designer Create layout Classes from Designer  Design Portrait -> capture InitializeComponent  Design Landscape - > capture InitializeComponent Handle orientation in methods Handle orientation in methods Keep designer forms for future modification Keep designer forms for future modification Full designer support in VS 2005 Full designer support in VS 2005

64 Auto Scrollbars In Dialogs Existing apps (version <=4.20) Existing apps (version <=4.20)  automatic vertical scroll bar for Landscape and Square New apps (version >=4.21) New apps (version >=4.21)  Call SHInitDialog() with SHIDIF_WANTSCROLLBAR 80 pixels

65 Layout Tips Re-layout is expensive Re-layout is expensive  relayout only when the width changes (not all WM_SIZE)  Use DeferWindowPos for child windows Off-screen controls Off-screen controls  To the left or above the window  Hide them! Ensure select item is visible Ensure select item is visible  Scroll into view if necessary Hardware buttons move! Hardware buttons move!  May not lie where you expect

66 Update Your Install Script Subsystem.EXE version <=4.20 Subsystem.EXE version <=4.20 Update.INF file: Update.INF file:[CEDevice] BuildMax=0xE0000000 ; support for square screens and screen rotation

67 Resolution aware apps What’s new? What’s new? ExistingNew Pocket PC 240 x 320 96 dots per inch 480 x 640 192 DPI Smartphone 172 x 240 96 DPI 240 x 320 131 DPI NOTE: this is a DPI change, NOT a screen size change! NOTE: this is a DPI change, NOT a screen size change!  Same physical size  Designed to enable high quality screens

68 Goals Keep one app for both DPI settings Keep one app for both DPI settings Support existing applications Support existing applications  Provide DPI “emulation” for existing apps  Best effort experience  Pocket PC only Allow new applications to be DPI aware Allow new applications to be DPI aware  Use hires graphics  Better customer experience

69 What Is DPI Awareness? More detail per element More detail per element NOT tiny text NOT tiny text

70 Migrating to HiDPI Run your app on 96DPI Run your app on 96DPI  Take a screen snapshot Run your app on 192DPI Run your app on 192DPI  Take a screen snapshot Compare the output: Compare the output: pWord, 96 DPI pWord, 192 DPI

71 Migrating to HiDPI Why so similar? Why so similar?  Legacy emulation layer  App believes it is running on 96 DPI  Layer stretches app to screen pixels Main Difference: Main Difference:  Text looks sharper/better 96 DPI 192 DPI

72 So, Are We Done? No – true Hi-DPI support means: No – true Hi-DPI support means:  Better images  Better performance 96 DPI 192 DPI

73 Disabling Emulation Layer Creating “manifest” resource: Creating “manifest” resource:  Resource type: CEUX (custom data)  Resource Name: “HI_RES_AWARE” Quotes important (or will be defined as numeric)  Value: 01 00  In.rc file: HI_RES_AWARE CEUX BEGIN 0x0001 END Now app will see the real DPI Now app will see the real DPI

74 Looking For Problems Compare screenshots Compare screenshots Obvious bugs Subtle bugs LoDPI HiDPI

75 .NET Compact Framework Emulation layer works Emulation layer works No designer support No designer support Manifest resource Manifest resource  Res2exe –c –r hidpi.res MyApp.exe

76 Summary Visual Studio.NET 2003 is the development environment Visual Studio.NET 2003 is the development environment Add on a Pocket PC or Smartphone SDK Add on a Pocket PC or Smartphone SDK.NET Compact Framework is in ROM!.NET Compact Framework is in ROM!

77 Get Tools & Resources: Windows Mobile Developer Portal More Support: Windows Mobile Solution Partner Program Go To Market: Mobile2Market and Certification Technical Support:  Tools and SDKs with emulators  Technical articles and whitepapers Marketing Support:  Monthly newsletters  Case studies Technical Support:  Exclusive expert columns  Early access to SDKs  Access to beta programs Marketing Support:  PR support  Ongoing promotions for devices Technical Support:  “Designed for Windows Mobile” certification testing  Free technical support incident Marketing Support:  “Designed for Windows Mobile” logo on packaging & promotions  Increased promotion to retailers and distribution partners Go to: http://www.microsoft.com/windowsmobile/developer http://www.microsoft.com/windowsmobile/developer http://www.microsoft.com/windowsmobile/developer Windows Mobile Developer Resources

78 Questions?

79 © 2004 Microsoft Corporation. All rights reserved.


Download ppt "Introduction to managed code development for Windows Mobile Paul Foster"

Similar presentations


Ads by Google