Are you curious about the newer developer tools available in Windows 7. In this excerpt from Kiriaty, Moroney, Goldshtein, and Fliess' Introducing Windows® 7 for Developers you'll learn about seven ways to shine while developing Windows 7 software.
Windows 7 offers numerous technologies and features to light up your application and make it shine. In this book, we chose to focus on the features we think bring the most added value to the end user experience and that require relatively little development effort. Think of these features as giving you the best overall user experience value for your time, effort, and money.
There is no single, silver bullet Windows 7 feature that transforms your application into the best Windows application. The built-in Windows features help you create amazing applications, but it's up to you to make the right decision about which features best fit your application scenarios. You can pick and choose any combination of Windows 7 features that will all play together, and thus create a solid application that uses the right features at the right time. From nonfunctional features such as Restart and Recovery or Kernel Transaction Manager, to more user-based features such as the new taskbar, Windows 7 Libraries, or multitouch. In this book, we'll focus on a few of the most important features and the ones that you are most likely to want to use while lighting up your application with Windows 7, such as the following:
Taskbar
Libraries
Multitouch
Sensor and location
Ribbon
Improved fundamentals
Enhanced graphics platform
You can mix and match any of these seven features or any other Windows 7 features. All the features in the preceding list are independent of each other. There is no one single feature that you need to implement, but it make sense to make your application feel like a Windows 7 application by optimizing its taskbar behavior and making it properly work with Windows 7 Libraries. Next, you can start differentiating your application from others by creating next-generation user experiences that involve multitouch, sensors, location, the new ribbon, and the new graphics stack.
The rest of this chapter provides a short overview of the various technologies this book focuses on.
So you've got Windows 7 installed and you log on for the first time, eagerly waiting for the "Preparing your desktop…" prompt to go away. The first user-interface change you'll notice with Windows 7 is the new, reworked Windows taskbar.
Over the years, the Windows taskbar evolved into the somewhat cluttered form that you might be familiar with from Windows Vista. The abundance of launch surfaces made it more difficult for users to navigate to their favorite programs, switch between applications, and access frequent destinations. The new taskbar reflects many years of user-interface design and usability testing, and it represents a revolution in the design of launch surfaces. It has never been so easy to navigate Windows and windows—the new user interface is simple, intuitive, fresh, and clean. Users will find it easier to launch their favorite applications, to switch between windows, to control applications that do not currently have focus, and to reach their recent documents—all of which are just a mouse click away. The following illustration shows the sleek, clean look of the Windows 7 taskbar and Start menu:
This book will show you the new features of the Windows 7 taskbar, as well as explain how to ensure your application takes advantage of every relevant piece of functionality. In Chapter 2, Integrate with the Windows 7 Taskbar: Basic Features, we show you how to use the new taskbar features that require relatively little effort on your part—providing a progress indicator through a taskbar button, showing an overlay icon that gives additional status information, and distinguishing windows and applications by assigning them separate taskbar buttons. In Chapter 3, Integrate with the Windows 7 Taskbar: Advanced Features, we discuss the more sophisticated features that users will come to expect from your application—thumbnail toolbars for remotely controlling a window from its taskbar thumbnail, jump lists for quickly accessing recent documents and frequent tasks, tools for completely customizing taskbar thumbnails, and tools for creating live window previews. All of these features combine to deliver a compelling experience to users of your applications.
In these two chapters, you'll learn how Internet Explorer presents live previews of its internal Web page tabs, how Windows Media Player enables you to play music from its application thumbnail, how Windows Live Messenger allows you to change your online availability and navigate to your e-mail inbox from its jump list, and how Sticky Notes shows you a thumbnail of a stack of notes and allows you to create another note with a single click of the mouse. The following screen shot shows Internet Explorer 8 tabs as taskbar button thumbnails:
Throughout these chapters, we'll look at the native Windows APIs that make this magic possible, including the underlying COM interfaces, window messages, and Win32 functions. We'll also use the Windows API Code Pack for Microsoft .NET Framework to interact with Windows 7 from managed code. We'll do this by using a well-designed layer of abstraction for organizing taskbar features that will be immediately familiar to you if you're writing code with the .NET Framework.
Almost every application needs the new taskbar to truly shine on Windows 7. If you're writing a document-oriented application, you can give your users immediate access to their recent and frequent documents. If you're developing an application rich with media, you can give your users a thumbnail toolbar for quick access to media-oriented operations and live, vivid previews of your application from the taskbar button. If you're programming a utility that lurks in the background and pops up only once in a while, you might find that the best place for your application is on the Windows taskbar, where it can give users a live progress indicator and a status icon. Even if you're programming for the browser, one day you'll find that your users are eager to have your application out of the browser because they're enjoying the rich world of the Windows 7 taskbar.
Since Windows XP, you've had the option to store your content (documents, videos, pictures, or any other files) in a set of special dedicated folders such as My Documents and My Pictures. These folders are unique for each user, and in Windows Vista they were automatically indexed to provide a superior search experience. But didn't you wish you were able to extend these special folders and include additional folders on your local hard drive or on remote shares? Libraries in Windows 7 allow you to do just that!
With Windows 7 Libraries, you are in control of your data. Using Windows 7 Libraries enables you to manage your own set of folders for various purposes, or add more folders to the My Images library. Libraries are user-defined collections of folders aggregated into a single unified view. By including folders in Libraries, the user is telling Windows (and you the developer) where his important data is located.
Windows 7 Libraries are the users' new entry point for accessing their data. Users will go to Libraries to manage their documents, music, pictures, and other files. And users will expect your application to work with Libraries because they are an integral part of the Windows Shell and play a dominant role within Windows Explorer and other parts of the operating system, such as the Common File dialog.
In some ways, a library is similar to a folder. From a user's point of view, a library looks and behaves just like a regular folder. However, unlike a folder, a library gathers files that are stored in several locations into a unified view. This is a subtle but important difference between a library and a folder. Libraries don't actually store users' items, they only monitor folders that contain items and let users access and arrange these items in different ways. Nonetheless, let's perform a little experiment. Go ahead and launch Notepad and try to save the file to the Documents library. The save operation will complete successfully. However, we just said that libraries are not regular folders that contain files, so what's going on here?
In Chapter 4, Organize My Data: Libraries in Windows 7, you will read all about Windows 7 Libraries. By reading this chapter, you'll gain an understanding of the underlying architecture of the Libraries feature and see why saving files to the Documents (or any other) library works in Windows 7. The chapter also explains in detail the API needed to work and manage Windows 7 Libraries. You might find that your application already supports Libraries, but even if your application does not, you'll see that it doesn't take a lot of effort to turn your application into a library-aware application that can work and consume Windows 7 Libraries content. As we do in most chapters of this book, we address both the native C++ (mostly COM) APIs and, where possible, the managed code APIs. We explain the architecture and concepts using the native API and dive into specific examples of how to use the new Libraries API using the managed code API.
Almost any Windows application that enables user to load and save files from the local hard drive will want to seamlessly integrate with Windows 7 Libraries to enable users to enjoy the rich search and visual experience offered by Windows Explorer and to have a friction-free experience while running on Windows 7.
Whenever you see a demonstration of Windows 7, touch, multitouch, and gestures are likely the most prominent features in the demonstration. Since Microsoft first demonstrated the Surface platform, interest in applications and scenarios that allow the user to touch the screen in multiple places to interact with user interfaces has reached an all-time high! Windows 7 fully supports touch interfaces, and it's flexible enough to handle many different touch types. You might be familiar with building applications for touch with Tablet PCs using the inking subsystem, but that's just the beginning.
Because of the importance and popularity of these features, we spend a lot of time in this book talking about the new multitouch APIs. We first go into detail about how the underlying system works and how the operating system manages the vastly diverse touch hardware. In the past, the only touch hardware was either a Tablet PC containing a single input via a pen or specialized hardware having specialized drivers that a developer would have to learn. With Windows 7, hardware vendors can now build screens or external devices and hook them up to the new touch driver system, and you as a developer can take advantage of this.
In Chapter 5, Touch Me Now: An Introduction to Multitouch Programming, we cover the basic concepts of Windows multitouch programming and provide a detailed architecture review as well as a thorough review of the native C++ (COM) APIs. This chapter mainly focuses on the Windows 7 built-in gesture engine, which enables developers to enhance their application with multitouch support with very little effort.
In Chapter 6, Touch Me Now: Advanced Multitouch Programming we'll move up the stack a little bit and look at the .NET Framework and in particular the Windows Presentation Foundation. If you're not familiar with these, the .NET Framework is a set of classes built for you by Microsoft that provide a friendlier programming interface that can be used with languages such as Microsoft Visual Basic or C#. One part of the .NET Framework is the Windows Presentation Foundation, which is designed to provide access to everything you need to build the visual layer of a rich UI application. Of course, the touch system falls under this domain, and version 4.0 of WPF provides not just access to the touch system but also to a group of APIs that tell you about user gestures.
A gesture is a fixed action that can happen in a multitouch environment. To understand this, think about how you would interact with a photograph in a multitouch environment. Typically, a photograph is rendered as a rectangle oriented vertically. You can zoom in and out usually with a mouse wheel or a slider. But what about when you can touch the screen? Wouldn't it be nice if you could put your thumb on one corner and your index finger on the opposite corner and then bring your fingers together to make the picture get smaller as the corners follow your fingers? In a similar vein, you can make the picture bigger by moving your fingers apart, rotate it by twisting your wrist, or move it to another part of the screen by moving your hand and having the picture follow it. These are the concepts in Windows 7 that are called gestures. In Chapter 6, Touch Me Now: Advanced Multitouch Programming, you'll see how you can easily add gesture support to your application.
In Chapter 7, Building Multitouch Applications in Managed Code we deepen our discussion and dive into more powerful and more complex multitouch APIs. This chapter covers Windows 7 raw-touch support and the native manipulation and inertia engines.
In these two chapters, you'll get a full tour of the multitouch features, and after finishing them you'll have a good understanding of how the touch system works in Windows 7. These two chapters are not required for the two chapters that follow them, which deal with Windows Presentation Foundation (WPF) and Silverlight multitouch. However, they'll provide you with a solid understanding of the relevant parts of the architecture, making it easier for you to understand the .NET multitouch abstraction layers.
Microsoft released a technology called Silverlight in 2007. Silverlight is a browser plug-in that provides a rich programming interface and a miniature version of the .NET Framework that allows you to build and easily deploy applications that can take advantage of features of the operating system. A feature of Silverlight that makes it compelling is the ability for it to be run out-of-browser, whereby a user can choose to remove the dependency of the application on the browser and install it to her desktop. In Chapter 8, Using Windows 7 Touch with Silverlight, we'll look at Silverlight—what it is and what it does. You'll see how easy it is to build an application in .NET that is delivered across the Internet using Silverlight. You'll then see how to add touch to your Silverlight application in Windows 7 by using the inking capabilities for Tablet PCs as well as the raw touch objects that allow you to process multitouch messages.
By the end of Chapter 8, Using Windows 7 Touch with Silverlight, you'll know all you need to know about touch and a whole lot more—from the underlying touch system to the .NET APIs for gesturing provided by WPF, all the way up to adding touch functionality to rich Web applications.
The Sensor and Location Platform is among the coolest and most useful new technologies offered in Windows 7, for both users and developers. The Windows 7 Sensor and Location Platform enables developers to create adaptive applications that can change the way the application looks and behaves according to different environmental conditions. You might wonder why even bother with this type of functionality, but take a quick look around you. You see mobile devices that change their display orientation based on the relative position of the device. More and more computers include an ambient light sensor that allows your computer to automatically adjust your screen's brightness based on the current lighting conditions, so when you use your computer in a dark environment, you don't have to strain your eyes.
Ambient light sensors also enable applications to optimize their content for readability, making your computer more useful and user friendly in a wider range of operating environments than ever before.
The Sensor and Location Platform provides a standard way to integrate sensor and location devices into Windows, as well as a standard programming interface for applications to take advantage of these devices. Lack of such functionality has been a long-standing problem, because previously Windows developers had to choose specific sensor hardware and sets of APIs to work with in their applications. Switching between different vendors was extremely expensive because of the lack of standardization. And with Windows 7, applications have a uniform, standard interface to use the sensors on data, and the user has control over how data from these sensors is exposed to applications.
In this book, we dedicated two chapters to the Windows 7 Sensor and Location Platform. Chapter 9, Introduction to the Sensor and Location Platform, provides an introduction to the Sensor and Location Platform. The chapter focuses on the core architecture of the platform and explains the role of the different components. Next, the chapter describes the way developers can integrate sensory inputs into their applications by discovering sensors and programmatically accessing data that the sensors provide. By the end of Chapter 9, Introduction to the Sensor and Location Platform, you'll know how to program both the native C++ (COM) APIs as well as the .NET-managed APIs.
Chapter 10, Tell Me Where I Am: Location-Aware Applications, explains in detail the location part of the platform. The Windows Location APIs, which are a dedicated set of higher-level abstraction APIs, are built on top of the Windows 7 Sensor platform. The Location APIs exist to answer one simple question: "Where am I, or what is my current location?" The answer is simple because it is stated as a set of values representing longitude, latitude, and an error radius. There is so much you can do with accurate real-time location information—you can have location-based services that can optimize a search for your current location or a mapping application that focuses on your current position and keeps track of it as you travel and change your location. After reading Chapter 10, Tell Me Where I Am: Location-Aware Applications, you'll know everything that you need to know for integrating location into your application and see how easy it is to integrate the location APIs with your application.
When you start the Microsoft Paint program in Windows 7, what is the first thing you notice? What has changed since Windows Vista (or should we say, "Since Windows XP")? Now start WordPad. What do you see? In Windows 7, there are new versions of the popular Paint and WordPad applications (See Figure 1.1).
Both applications include new features such as the ability to paint with all your fingers (on a multitouch machine) or open a Word 2007 .docx document without having Microsoft Office Word 2007 installed on your computer. But the most noticeable change is the new Ribbon user interface.
We are living in an era in which software is everywhere and used by everyone. Alon's 3-year-old son watches TV using Windows Media Center. His mother sends e-mail to her friends, and his home automation system is programmed to control the TV and to send timed e-mail messages—and it also wakes him up every morning by raising the shutters on his bedroom windows. Nowadays software is much more complicated than it used to be. There are many more features, we can do much more with it, and we can use it to help realize our potential. However, the user interface and, more importantly, the user experience provided by most Windows applications has not changed much to support all these new features and uses of software. It's a bit like using a car's steering wheel and pedals to fly an airplane!
The first group within Microsoft to understand that the traditional user interface based on menus and toolbars was failing the user was the Office development team. With each new release of Office, new features were added, but no one found or used them. The product became more and more complicated. The user interface became bloated. People felt that they could do more, but they didn't know how.
In Office 2007, the Office team took another, refreshing, user interface (UI) design approach—instead of thinking about commands, they thought about features. They call it result-oriented design. The Ribbon was born and, with it, a new user experience. Using the power of the modern CPUs combined with visual galleries, the Ribbon can show the outcome of an action whenever the mouse cursor is hovering over the command icons. If you want to set a style, just hover the cursor over each of the style icons in the style gallery. Any style that gets the focus shows you a preview of how the document would change to reflect it. The user just needs to pick the style that makes the document look best. The feature-based design makes Office 2007 much more productive than any older version of Office.
As always, the Office team is the user-interface pioneer. We can find many followers of their fine example by looking at the UI elements in other Microsoft products, such as the new Ribbon support in Visual Studio 2008 SP1 Microsoft Foundation Classes (MFC) or the Ribbon toolkit for WPF and Windows 7 introduces the Windows Ribbon Framework. It has never been so easy to have a rich user interface and provide a positive user experience in Win32-based applications.
In many modern user-interface frameworks, the UI part is separated from the code that handles UI events and controls the business logic. In the case of the Windows Ribbon Framework, the UI is written using XML-based markup language that is similar to the WPF XAML in many ways, whereas the code-behind compilation unit uses COM as its interfacing technology.
Chapter 11, Develop with the Windows Ribbon, Part 1, lays the foundation for understanding and using the Windows Ribbon Framework. This chapter deals with the Ribbon building blocks. You'll see how to create the Ribbon using its markup language and how to set its sizing behavior; you'll become familiar with the various Ribbon controls. As a side benefit, you'll even become a better user of the Ribbon!
In Chapter 12, Develop with the Windows Ribbon, Part 2, you'll see how to program with the Windows Ribbon Framework, how to initialize and load the Ribbon, how to interact with it, how to reflect the application state in the UI, and how to support the Office Fluent UI approach.
Even if you are a .NET developer who will not use the Windows Ribbon Framework, we encourage you to read the chapters related to it to get a better understanding of this new user-interface concept. Then, based on the technology you are using (Web, WPF, or Windows Forms), pick the most suitable Ribbon control suite. Native developers can take their old applications and make them shine on Windows 7!
This book doesn't include any chapters on the new graphics stack available in Windows 7. It looked like there was going to be too much information to fit into one, two, or even three chapters, and we didn't want to turn a substantial part of this book into a "Developing Windows 7 Graphics" course. With that said, the new DirectX graphics stack in Windows 7 offers innovations and great tools for developers to easily create hardware-accelerated 2D and text applications, on top of the DirectX APIs. So we decided to write a little bit about the enhancements to the graphics platform in Windows 7 to at least provide a high-level overview.
The Microsoft Windows graphics device interface (GDI) enables applications to use graphics and formatted text on both the video display and the printer. Windows-based applications do not access the graphics hardware directly. Instead, GDI interacts with device drivers on behalf of applications. Since Windows 3.0, developers have been using GDI, and since the release of Windows XP a lot of applications have been exploiting GDI+, which is a completely new set of APIs. Even higher abstraction layers, such as the .NET WinForms rendering, are based on GDI+. With that said, Windows application developers have long used DirectX to provide high-quality, hardware-accelerated, 3D graphics. When the technology debuted in 1995, developers could provide high-quality 3D graphics for games and engineering applications for gamers and professionals willing to pay extra for a 3D-graphics board. Now, even the most inexpensive PCs include capable 3D-graphics hardware. The WPF rendering engine uses DirectX and allows managed code developers to write cutting-edge graphical applications that are hardware accelerated.
In Windows Vista, the Windows Display Driver Model (WDDM) was introduced. The WDDM infrastructure for DirectX enabled multiple applications and services to share the resources of the Graphical Processing Unit (GPU). The Desktop Window Manager (DWM) uses this technology to animate task switching in 3D, to provide dynamic thumbnail images of application windows, and to provide Windows Aero glass effects for desktop applications.
In Windows 7, Microsoft introduced a more modern set of APIs, which we hope will eventually help replace GDI+. Windows 7 places more graphics capabilities into the hands of application developers. Through a new set of DirectX APIs, Win32, and managed code, developers can take advantage of the latest innovations in GPUs to add to their applications fast, scalable, high-quality, 2D and 3D graphics; text; and images. All these new technologies were designed to interoperate with GDI and GDI+, ensuring that developers can easily preserve their existing investment and providing a clear migration path.
These enhanced graphics capabilities are provided by the following COM-based APIs (and some are also available in managed code through the Windows API Code Pack):
Windows Imaging Component (WIC) for processing and displaying images
Direct3D 10 for drawing 3D graphics
Direct3D 11 for drawing 3D graphics and providing access to next-generation GPU technologies, such as tessellation, limited support for texture streaming, and general-purpose computing
DirectX Graphics Infrastructure (DXGI) for managing devices and GPU resources and providing interoperability between DirectX and GDI
Direct2D Built on Direct3D, Direct2D offers Win32 developers immediate-mode, resolution-independent, 2D APIs that use the power of the graphics hardware. Direct2D provides high-quality 2D rendering with performance superior to GDI and GDI+ even when using full-software rendering without hardware acceleration. It provides Win32 and managed-code developers finer control over resources and their management and a higher abstraction of the complex DirectX APIs.
DirectWrite A great deal of Windows applications target worldwide users, which often means using multiple languages. This calls for a technology that supports high-quality text rendering, resolution independence, and Unicode text and layout. GDI and GDI+ do not provide these features, but DirectWrite, a new DirectX component, provides these features and more. DirectWrite provides the following capabilities:
High-quality, sub-pixel, ClearType text rendering that can use GDI, Direct2D, or application-specific rendering technologies
Hardware-accelerated text, when used with Direct2D
A device-independent text layout system that improves text readability in documents and in the UI
Support for multiformat text
GDI-compatible layout and rendering
Support for advanced typography features
The DirectWrite font system enables "any font, anywhere" font usage, where users don't have to perform a separate installation step just to use a font. It also has an improved structural hierarchy for font groupings to help with manual or programmatic font discovery. The APIs support measuring, drawing, and hit-testing of multiformat text, as shown in Figure 1.2.
The new graphics API in Windows 7 offer many existing GDI+-based applications clear and developer-friendly integration path to the newer APIs.
The features described in the previous sections might tempt you to doubt the performance of Windows 7. After all, how is it possible to integrate so much additional functionality into the operating system without hurting performance even a little bit? Surely, every additional feature requires another upgrade of your computer's RAM, a faster CPU, and a larger hard drive.
In fact, Windows 7 has the same hardware requirements as Windows Vista, and it runs faster on any hardware. As I write this, I'm running the RTM build of Windows 7 on my 9-inch netbook, which "features" a single, low-end 900-MHz CPU and 1 GB of physical memory. It's equipped with an extremely slow 16-GB, solid-state hard drive, which made even Internet browsing nearly impossible when I had Windows XP installed. This particular netbook has been running Windows 7 since the Release Candidate, and I've never been happier about its performance.
This represents a great effort by the Windows developers to improve the system's performance and reliability with regard to nearly every feature of the operating system. Windows 7 boots faster, enters standby mode faster, hibernates faster, and shuts down faster than ever before. Windows 7 runs for hours with 0% CPU utilization and barely noticeable memory usage, it consumes less power, and it conserves more system resources than its predecessors.
But wait, there's more! Windows 7 supports 256 cores, which gives you quite some time before you need to start worrying about seeing hardware that can't be used to its full capacity by the operating system. Windows 7 takes advantage of the latest advances in CPU and memory architecture—the Non-Uniform Memory Access (NUMA) paradigm—and it features scalability improvements across the board. Windows 7 also has additional improvements to power management and energy consumption so that your mobile PC lasts an entire day in the field. You'll also find fewer background services running at any given time, and you'll see that some tasks will trigger-start only when you really need them—for example, when connecting to a network or when adding an external digitizer device, a Bluetooth component, or a USB dongle to your system.
Indeed, two of the major requirements of Windows users for the past few years have been for the system to run faster and consume fewer resources. This is impossible to achieve from the operating system end alone—it requires cooperation and hard work from you, developers writing software for Windows 7. Other than the amazing effort put into the Windows kernel to improve performance, there are some things you need to know about to make sure your users enjoy the same experience with your applications as they do with an out-of-the-box installation of Windows 7.
Windows 7 does not leave you alone with this daunting task. There are great tools, which we'll explore in the closing chapter of this book, that will assist you in profiling, troubleshooting, and monitoring the performance of your applications. Windows 7 works great with the Windows Performance Toolkit, which serves as a profiler and performance analyzer. Windows 7 builds on the foundation laid by Windows Vista with improvements to the Performance Monitor and the Reliability Monitor. Windows 7 supports production debugging techniques that will make it easier to troubleshoot your applications in the field. Windows 7 even features a Troubleshooting Platform to ensure that your users will be able to solve problems on their own—and if they don't, the Problem Steps Recorder will always be there to assist them with reproducing the problem and sending it to you to analyze. Some of these Windows 7 tools are depicted in the following screen shots:
And finally, if you stumble across a legacy application that doesn't work quite right on Windows 7, you can always use the built-in Windows XP virtual machine that is integrated into the operating system. You can have a Windows XP application running on your Windows 7 desktop, with the familiar, working Windows XP look and feel.
Get your first look at Windows 7 and see how much more productive and efficient the development life cycle can be. Guided by three Windows programming experts, you'll examine new Windows 7 capabilities and get a head start exploiting them to build better user experiences and applications. Topics include multi-touch gesture support, graphics and video enhancements, the Ribbon user interface (including the difference between Windows 7 Ribbon and Windows Presentation Foundation (WPF) Ribbon), federated search, the Libraries feature, Taskbar functionality, the new Windows Sensor and Location platform, and more.




Help









