1 / 27

WCL322: The Windows API Code Pack – Add Windows 7 Features to Your Application

WCL322: The Windows API Code Pack – Add Windows 7 Features to Your Application. Kate Gregory Gregory Consulting www.gregcons.com/kateblog, @gregcons . It’s Simple, Really. If you have a Windows application, it should be a Windows 7 application. Agenda. What is different about Windows 7?

parker
Download Presentation

WCL322: The Windows API Code Pack – Add Windows 7 Features to Your Application

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. WCL322: The Windows API Code Pack – Add Windows 7 Features to Your Application Kate Gregory Gregory Consulting www.gregcons.com/kateblog, @gregcons

  2. It’s Simple, Really If you have a Windows application, it should be a Windows 7 application.

  3. Agenda • What is different about Windows 7? • Visuals • Taskbar jumplists • Taskbar overlays – icons and progress bars • Thumbnail buttons and custom thumbnails • Fundamentals • Power awareness • Network awareness • Libraries • Restart and recovery

  4. Accessibility from managed code Easy • Directly-callable using. NET interop mechanisms • Eg RSS, Office • C++/CLI or PInvoke signatures • EgApplication Recovery and Restart • Raw Win32 • EgPower Management, Windows Vista Wizards • COM • EgSearch and Organize APIs • Extra difficult to call from managed code • EgCommon File Dialogs, Network Awareness Hard

  5. What is the Windows API Code Pack? • Managed class library to access to Windows 7 features • Windows Shell namespace • Windows Vista and Windows 7 Task Dialogs • Support for Shell property system • Taskbar Jump Lists, Icon Overlay and Progress bar • Common file dialogs • Direct3D 11.0 and DXGI 1.0/1.1 APIs • Sensor Platform APIs • Extended Linguistic Services APIs • http://code.msdn.microsoft.com/windowsapicodepack

  6. Highlights from Windows API Code Pack • All demos are from the samples that ship with it • All demos are provided in both VB and C# • Samples are designed as a source of code for you • But you would hardcode so much more • Run the apps to experiment and see what you like

  7. What You Will See • Taskbar Jumplists • Taskbar Overlays • Taskbar Thumbnail Buttons • Restart and Recovery • Power Management

  8. Taskbar - Jumplists demo

  9. Taskbar Jumplists - destinations • Private jumpList As JumpList • jumpList.AddToRecent(fileName) • jumpList.KnownCategoryToDisplay = • JumpListKnownCategoryType.Recent • category1 = new JumpListCustomCategory(“My Category 1") • jumpList.AddCustomCategories(category1) • category1.AddJumpListItems(New JumpListItem(path)) • jumpList.AddUserTasks(jll)

  10. Taskbar Jumplists - tasks • Dim p As String = Path.Combine(systemFolder, "notepad.exe") • Dim ir As IconReference = New IconReference(p, 0) • Dim jll As JumpListLink = New JumpListLink(p, • "Open Notepad") • jll.IconReference = ir • jumpList.AddUserTasks(jll)

  11. Taskbar - Overlays demo

  12. Taskbar Overlays • TaskbarManagerwindowsTaskbar = TaskbarManager.Instance • windowsTaskbar.SetOverlayIcon(Me.Handle,My.Resources.Green, "Green") • windowsTaskbar.SetProgressState( • TaskbarProgressBarState.Error) • windowsTaskbar.SetProgressValue( • currentValue, maxValue)

  13. Taskbar – Thumbnail Buttons and Clipping demo

  14. Taskbar Thumbnails • buttonFirst = • New ThumbnailToolbarButton( • My.Resources.first, "First Image") • AddHandlerbuttonFirst.Click, AddressOfbuttonFirst_Click • TaskbarManager.Instance.TabbedThumbnail. • SetThumbnailClip(Me.Handle, • New Rectangle(pictureBox1.Location, pictureBox1.Size))

  15. Restart and Recovery • Register for Recovery • Chance to save your information on another thread • OS calls your code for you • Register for Restart • OS will run your app again (with a hint) after it dies

  16. Restart and Recovery demo

  17. Restart and Recovery • ApplicationRestartRecoveryManager. • RegisterForApplicationRestart(new RestartSettings("/restart", • RestartRestrictions.None)); • RecoveryData data = new RecoveryData( • new RecoveryCallback(RecoveryProcedure), null); • RecoverySettings settings = new RecoverySettings(data, 0); • ApplicationRestartRecoveryManager. • RegisterForApplicationRecovery(settings);

  18. Power Management • Is the machine running on battery? • What can your application do to extend battery life? • Autosaveless frequently • Autosave before critical battery reached • Scale back the user experience • Graphics richness • Reduce the frequency of data updates • Stop spinning the CD for sound effects access • Reduce CPU work loads • Number of threads, thread priorities • Use hardware (not software) rendering for graphics • Turn off or constrain background processing • Defer unnecessary tasks

  19. Power Management demo

  20. Power Management • PowerManager.PowerSourceChanged += • new EventHandler(PowerSourceChanged); • PowerManager.PowerPersonality • PowerManager.PowerSource • PowerManager.GetCurrentBatteryState().EstimatedTimeRemaining

  21. Code Pack • Gets managed developers working on Windows 7 now • WPF or Windows Forms • C# or VB • Not the only way to get there • Some of this is in WPF (.NET 4) • You could do your own interop, but why? • Others have written other wrappers • Documentation and samples • Discussions on Code Gallery • If you need to change or redistribute, you can

  22. What you’ve seen • Taskbar • Jumplists – nouns and verbs • Icon overlays • Progress bar overlays • Thumbnail buttons • Thumbnail clipping • Restart and Recovery • Power Awareness

  23. Call to Action • Download Code Pack • http://code.msdn.microsoft.com/windowsapicodepack • Add functionality to your application so it lights up on Win 7 • Feels like a Windows 7 app (taskbar etc.) • Never lose unsaved data to a crash again • Power efficiency and thoughtfulness

  24. Resources • http://code.msdn.microsoft.com/WindowsAPICodePack • http://windowsteamblog.com/windows/b/developers • http://www.developforwindows.com/

  25. Session Evaluations Tell us what you think, and you could win! All evaluations submitted are automatically entered into a daily prize draw*  Sign-in to the Schedule Builder at http://europe.msteched.com/topic/list/ * Details of prize draw rules can be obtained from the Information Desk.

  26. © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

More Related