Summer is just around the corner and we’ve worked with our partners to bring you some great deals on Windows 7 PCs just in time for graduation. Today brings three more, which makes four ways you can currently save some money (the Windows Anytime Upgrade offer from April is still going strong – see below). So keep reading for details on the machines that will amp up all those summer road trips, beach-side days and long nights on European trains you’ve got planned.
Behind door #1 we have a Sony VAIO E series laptop loaded with Windows 7 Professional and a free Blu-ray disc drive upgrade starting at $799.99. Plus, Sony will also give you a $90 credit towards the purchase of movies. The VAIO E series has a 15.5” screen that makes it easy to watch TV and movies, it weighs less than 6 pounds and you can get it in an array of colors so you stand out from the crowd. Ben will have a full PC review of the VAIO E series up shortly.
With Windows 7 Professional you get all the media features in Windows 7 Home Premium plus Windows XP Mode so you can still run any programs that are only compatible with Windows XP. Windows 7 Professional also comes with automatic backups to your home network so your movies will always be there – even if you leave your new VAIO on a train in Vienna. This deal is only available to U.S. residents through May 29, 2010, so if you’re sold go to Sony Style to see the fine print and buy one.
Also available: get $50 off when you purchase a Windows 7 notebook and a Windows 7 netbook from Amazon.com. If you want to power through your homework with your PC and stay connected all day then a Notebook with Windows 7 Home Premium + a Windows 7 netbook is a great choice. This deal is only available to U.S. residents through May 29, 2010 and there’s an array of PCs to choose from – including Dell, HP, Gateway and ASUS– so go to Amazon and see which set-up is right for you.
Last but not least, we have a limited-time offer only available through the Microsoft Store. You can grab a Dell Studio XPS 13 with Windows 7 Home Premium, Microsoft Office 2007 Home & Student (with a free upgrade to Office 2010 Home & Student once it’s available) and free shipping for a special price of $989. This is a great deal, so don’t wait too long. I use an older (~2.5 years) XPS for my home machine and I love it (FYI, I upgraded last year to Windows 7 from Windows Vista with no issues). This offer is available to US residents until June 25th or while supplies last— head over to the Microsoft Store to check out the specifics and buy.
If none of these work for you don’t forget that some of our retail partners are still offering a Windows Anytime Upgrade with the purchase of a new PC at a special low price. Brandon did a great post with all the specifics back in April, but in short get:
· Windows 7 Starter to Windows 7 Home Premium ERP $49.99 (normally $79.99); or
· Windows 7 Home Premium to Windows 7 Professional ERP $79.99 (normally $89.99).
The Windows Anytime Upgrade offer ends (in the U.S.) on July 3, 2010 and details vary by retailer and region, so check with them to see which PCs they are offering as part of the deal.
Keep checking this blog and www.windows.com for updates on future deals—summer is just getting started.
This is not the first time I’ve written about the Windows API Code Pack, and probably will not be the last time. However, this time I am reaching out to all Windows Developers who create Windows applications using the .NET framework–this blog post is for you. We want your feedback about the Windows API Code Pack in preparation for a future release. And to all those who wonder whether the API Code Pack is still alive, fear not–it is alive and kicking!
Some Background
You may think of the Windows API Code Pack as the closest thing to an “official” managed API for Windows on top of the .NET Framework. The Windows API Code Pack is a free, managed source code library provided by Microsoft as-is. You should consider this library as if you wrote that code. It is a great starting point and provides a really solid solution for managed code developers who create Windows application and looking to light up their applications. It covers a lot of the new Windows 7 features as well as some more fundamental core features from the Windows Vista timeframe.
The Windows API Code Pack’s former name was Windows Vista Bridge, or simply “The Bridge”. We began developing the Windows Vista Bridge after Windows Vista and the .NET Framework 3.0 were released. Realizing that .NET Framework 3.0 was missing some Windows Shell and other Win32 APIs, which made it harder for managed code developers to use the full power of Windows. The team set out to create a “bridge” that would help developers to cross this gap and allow managed code developers to access some of the more useful features of Windows, such as Search, Restart and Recovery, Glass, and Power Management. The outcome of this process was the Windows Vista Bridge Sample Library.
In the process of updating Windows Vista Bridge, we realized that the old name doesn’t fit the new Library. Because this library is no longer tied to a specific Windows release, we decided to change the name to the rather unwieldy but descriptive Windows API Code Pack for Microsoft .NET Framework. Unlike Vista Bridge that shipped after Vista was released, the Alpha version (version 0.8) of the Windows API Code Pack was released on April 20, 2009, six months before Windows 7 shipped. Releasing an early version allowed us to solicit developers’ feedback, update our feature list, and discover more bugs. It also allowed us to actually tell a managed code stories for Windows 7, since back then the .NET Framework (3.5) didn’t support any Windows 7 features.
Windows API Code Pack Version 1.0.1
A year has passed since the initial 0.8 Alpha release. Since then, we have had 3 more releases. The current version, 1.0.1, released November 18, 2009, includes a great deal of useful features that any managed code developer who is targeting Windows can use, including complete taskbar integration, extensive improvements to Windows Shell and libraries, DirectX 11, Sensor, and many more features.
There have been more than 67,000 direct downloads of the Windows API Code Pack since its release, and about the same number of downloads for other projects, such as the Windows 7 Training Kit for Developers, Flashcards.Show, Images.Show. These projects either use the Windows API Code Pack DLLs or include the Windows API Code Pack code. I guess this is where I need to acknowledge all of those who downloaded the Windows API Code Pack – thank you!
Windows API Code Pack Version 1.X
We didn’t stop working on the Windows API Code Pack! In the next few weeks/months we’ll release another version that will include bug fixing, major code cleanup and standardization, and few new features.
The team working on the Code Pack gave the existing code base a major facelift. Following the Microsoft development process, the original code was reviewed against a number of criteria, including Visual Studio FxCop analysis, updated naming conventions, improved performance, and upgrades, resulting in a much cleaner and more cohesive baseline. This baseline code will serve us internally for future releases, and I know developers will appreciate it as well.
We also added automatic testing for all the major projects (DLLs). Adding automatic testing to the Windows API Code Pack streamlines our internal development process and alerts you if any of your Code Pack customizations breaks anything along the way. The testing framework we use for the Windows API Code Pack is called xUnit. We chose xUnit over Visual Studio (VS) unit testing because unit testing is not part of the free express version of VS, and we didn’t want to limit our target audience.
While these code changes do not result in many new features, they do result in a much more robust and easy to maintain and debug code base upon which we can build going forward. We are working on a small set of new features for our next release, which will ship in few weeks.
But fear not, this is where you come into the picture. If you ever wanted to add a feature to the Code Pack, were looking for some specific Win32 API to be wrapped, or just wanted to pass us some feedback, this is your opportunity. Please send us your feedback or file a bug using the Discussions or Issue Tracker for the Windows API Code Pack.
We are especially interested in improving support for the Windows Shell, specifically in the areas of Shell integration, support for file handlers and properties, libraries, and search and indexing. We are also looking into adding social and web APIs related to Windows, as well as some fundamentals around Windows Services and Task Scheduling and Power Management. Again, if you have any additional ideas or feedback, we are listening.
The Windows API Code Pack Team
Federated search enables users to search remote data sources from within Windows Explorer. This means that from within Windows Explorer, you can search those Web sites, feeds, and other structured remote data sources that make themselves searchable with a simple Web front end that exposes their search capabilities. You can use the search box in Windows Explorer just as you do when searching your own content. Search results are displayed in the same way, including coloring and even file preview. The results behave just as you would expect from items listed in Windows Explorer, as shown in the following image:
The benefit of integrating your data source with Windows Explorer is that users can get at all of their information by using the already familiar Windows Explorer user interface. Your users will be able to see files from your remote data source just as they would local files, including the right application icons and context menus. They can preview documents or Web pages, see thumbnails of images, and drag and drop a file directly to the desktop or into an e-mail. Please note in the above picture that the files are from flickr.com and I am still getting the size, name, tags, date modified, and so on.
In this post, based on the Windows 7 Federated Search Provider Implementer’s Guide, you learn what federated search is and how it works. If you are interested in using federated search or in creating your own search provider, please read this guide.
How does it work?
Windows 7 supports hooking up external sources to the Windows Client via the OpenSearch protocol. The OpenSearch v1.1 standard defines simple file formats that can be used to describe how a client should query the Web service for the data store and how the service should return results to be rendered by the client. Basically, this means that you can point Windows Explorer to an external data source. Using the standard OpenSearch protocol, Windows Explorer submits the search query and the remote data source returns a well-formatted data structure that can then be parsed and presented to the user.
To add a new OpenSearch provider, you need to “install” a Search Connector Description file (a .osdx file). The internal file format for a .osdx file is an OpenSearch Description XML document. Here is the content of a Flickr search osdx file:
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
xmlns:ms-ose="http://schemas.microsoft.com/opensearchext/2009/">
<ShortName>Flickr Search</ShortName>
<Description>OpenSearch for Flickr via Windows 7 Search Federation.</Description>
<Url type="text/html"
template="http://www.flickr.com/search/?w=all&q={searchTerms}&m=text"/>
</OpenSearchDescription>
Note how simple the file is. It basically includes a URL to Flickr search that specifies the searchTerms, which is the search query. For more information please go to OpenSearch v1.1 standard. Those of you who have a good eye and a good memory might think that the above XML looks a lot like an Internet Explorer 8 (IE8) Search Provider Extension – you know, the little search box on the top right of IE8 that lets you choose the context in which you execute a search. This is interesting enough so that you can expect a future post on how to convert an IE8 Search Provider to a Windows 7 Federated Search.
End users have several options for installing a new remote data source with Windows federated search: they can open a .osdx file by clicking on a link to one on a Web site or by opening one provided by someone else on a share or via an email attachment. This creates a .searchconnector-ms file in the Windows “Searches” folder (%userprofile%/Searches) and places a shortcut into the “Links” folder (%userprofile%/Links). This shortcut shows up in the Windows Explorer navigation pane Favorites section.
The communication between Windows Explorer and your OpenSearch Web service is done through the Windows Data Layer, which can communicate with various data source types via what are called Windows Store Providers. Each provider specializes in communicating with data stores that support a particular protocol and have specific capabilities. The OpenSearch provider communicates with data stores that have a Web service that supports the OpenSearch standard.
Let’s give it a try. Please click here to download (install) a Flickr search connector. You will be prompted to either save or open the file. Choose Open to actually register the search provider on your computer. Then, you will be prompted to Add a Search Connector. Accept by pressing the Add button as shown in the following image:
Note that a new shortcut named Flickr Search is added to your Favorite’s navigation pane. Click that shortcut, and then type Seattle in the Windows Explorer search box. Wait few seconds as the results are being streamed from the Flickr Web site.
Behind the scenes, when the user types a term into the search box in the upper right hand of Windows Explorer, the query is sent to the OpenSearch provider (described in the .searchconnector-ms file), which then sends the query to the remote data store (the URL that contains the “searchTerms” in the osdx file). The remote Web service responds to the query with results in an XML document in either the RSS or Atom format. The OpenSearch provider parses the XML elements of the results into items which eventually make it back to Windows Explorer where they are displayed to the user. The following picture illustrates the flow of data:
There are three steps to getting your data store’s Web service connected to Windows 7:
The OpenSearch protocol gives you a lot of hooks into the system to customize the way results are displayed within Windows Explorer. For example you can:
There is a lot more to learn about how to create your own OpenSearch provider. If you are interested, read the Windows 7 Federated Search Provider Implementer’s Guide and view the Federated Search video created by Sasha Goldstein, one of the Introducing Windows 7 for Developers authors.
Last updated: April 14, 2010
This post is an update to the first Windows 7 Programming Guide – Libraries post. It provides an index to the recent Windows 7 Libraries series, including new relevant Channel 9 videos and links to additional sources of information, as well as code examples for programming Windows 7 Libraries.
In addition, we have added 4 new How-to videos (created by Sasha Goldstein, one of the Introducing Windows 7 for Developers authors) showing how to use both native and managed APIs to work with Windows 7 Libraries.
Please note that the some of the videos include advanced patterns for listening to library structure changes, allowing you to update you application’s UI. Each video also includes the source code for its demos.
Posts
Resources
Videos
During PDC, I had the amazing opportunity to join a group of remarkable engineers in presenting part of the Windows 7 Boot Camp pre-con event. As I’ve reported live, the event took place on November 16th, in a room filled with 750 attendees who heard about the changes to Windows 7 and Server R2 Kernel, as well as some of the new “user-mode” APIs such as Taskbar, Libraries, touch, sensors, and DirectX.
This post (a little overdue), gives you the opportunity to see the video recordings and download the presentations and demo code. So even if you missed this pre-con you can enjoy it all from the comfort of your PC.
Mark Russinovich, Technical Fellow and the man behind SysInternals and many of the improvements in Windows 7, opened the day with a short introduction to the work done by the Kernel team and as a setup for the following two sessions. You can watch Mark’s presentation recording (time code – 00:00:00 – 00:13:45) and download his slides.
Arun Kishan, a Principal Architect for the process management components, described his work around the thread and process allocation that frees the kernel from its thread dispatcher locks and gives Windows 7 the ability to scale seamlessly to many (256) cores. Arun also talked about the new User Mode Scheduling in Windows 7 that enables quicker context switches between threads (since the threads run in user mode context), while at the same time allowing the kernel to “control” blocking threads, and thus not lose the LP to a thread outside its control. You can watch Arun’s presentation recording (time code 00:13:45 – 00:54:26) and download his slides.
The last speaker in the opening session was Landy Wang, a Distinguished Engineer in the Kernel team. Landy really drilled into the changes to Windows 7 Memory Management, and the amazing work done by the team to reduce the memory footprint, making the entire operating system run fast (real fast). Landy described the work being done to optimize the memory working sets, demystified some of the questions about the Task Manager’s main screen, and how the Task Manager shows the memory working set, along with some other useful information. You can watch Landy’s presentation recording (time code 00:54:26 – 01:50:43) and download his slides.
After lunch, we switched gears and reviewed the API for some of the UI elements of Windows 7. Jaime Rodriguez started the second part of the day with a great talk about the Windows 7 Taskbar, showing multiple ways (native and managed, using Window API Code Pack and WPF 4) to add great Taskbar functionality to your application. You can watch Jaime’s presentation recording (time code 00:00:00 – 00:44:07)
I followed with quick Windows libraries overview, focusing on the things you need to remember as developers since libraries may sometimes break your application. Here are the Windows 7 library presentation and code demos. You can watch the presentation video recording (time code 00:44:07 – 01:19:05)
My Second presentation that day was about the Windows 7 Sensor and Location Platform. I just love this platform, as it offers such great ways for developers to enable their applications respond to changes in the computer’s environment. Showing the light optimizing MSDN Reader and the racing game always gets great reactions from the audience. Here is the Windows 7 Sensor and Location Platform presentation. You can watch the presentation recording (time code 01:20:04 – 02:10:43 ) and download the slides.
Next, Michael Oneppo explained the changes in the Windows 7 graphics stack. Michael’s presentation is very interesting, as it describes some of the DirectX API that was down-ported to Windows 7 as a part of the Platform Update for Windows Vista and the Platform Update for Windows Server 2008. You can watch Michael’s presentation recording (time code 00:00:00 – 00:50:03) and download his slides.
Jaime was the last speaker of the day, covering Windows 7 Multitouch. Jaime explained the concept of multitouch using the native API, but switched to WPF 4.0 support for multitouch. You can watch Jaime’s presentation video recording (time code 00:53:50 – 01:34:37).
Last but not least, I want to express my appreciation and say a very big thank you to everyone who participated and helped make the boot camp a success. First to Jaime Rodriguez who made this event possible and helped set up and organize it, to the great speakers Mark Russinovich, Arun Kishan, Landy Wang, and Michael Oneppo, and for the entire crew of PDC.
See you at the next PDC! I am sure I will be there talking about Windows …
Most of the content presented during this day is based on the Windows 7 Training kit that is available from the Channel 9 Learning Center
A few days ago, we launched the Windows 7 Test Drive site. This site offers developers a chance to get first-hand experience in developing for Windows 7, even if they don’t have Windows 7 installed on their development environment. Using the Windows 7 Test Drive site, you can learn about developing on Windows 7 in a virtual environment. This experience provides the user with a guided tour of Windows 7 features from a developer’s perspective with the goal of engaging and enabling them to develop on the Windows Platform. You can
The idea behind the Test Drive lab is to create a very low barrier-to-entry development experience for Windows 7. It is a free tool for you to use whenever you want and requires no special software installation (besides a single ActiveX). All you need is a Windows Live ID, a few clear hours, and a visit to the Windows 7 Test Drive for Developers to take a guided tour of Windows 7. The short virtual labs and supporting videos will give you a chance to explore Windows 7 feature by feature with no installation required. Try out a few of the virtual labs and watch a few videos today to learn how and why you should develop on the Windows.
The first version of the Windows 7 Test Drive includes the majority of the Windows 7 Training kit topics, but not all of the labs. For example, the Test Drive includes the following labs:
This content along with the Windows 7 Training Course on Channel 9 Learning Center, is a great resource for developers.
It is time to return to our usual routine of describing Windows 7 APIs. We already covered the basics of the Windows 7 Taskbar in Developing for the Windows 7 Taskbar – Application ID, and how you can create a Jump List for your application in Developing for the Windows 7 Taskbar – Jump into Jump Lists – Part 1, Part 2, and Part 3). This post focuses on using thumbnail toolbars to enhance end user productivity while surfacing specifics common to the Thumbnail Preview.
To make sure everyone understands the concepts, let’s dive into a quick review. If you are already familiar with what thumbnail toolbars are, then feel free to jump towards the middle of this post – where the fun starts with some real code.
| As we said, thumbnail toolbars are an amazing productivity feature that enables users to access the application’s functionality even when the application is not in focus (or even visible). Specifically, this enables you to access to the application without the need to switch to it (make it the active window.) Thumbnail toolbars are a set of up to seven buttons at the bottom of the taskbar’s icon thumbnail preview. |
Another great example we mentioned few weeks ago is the Fishbowl for Facebook application. This application uses the thumbnail preview to provide quick and easy access to the most common task any Facebook user performs, surfacing actions like view your home’s or friend’s feeds to the thumbnail toolbar. As you can see in the following image, the Fishbowl thumbnail toolbar has five buttons (actually six, but we’ll get to this in a second.)
Now that we established the need for using this cool taskbar feature, let’ see what it takes to implement it. First, few ground rules:
As usual, we’ll start with native code (Win32) implementation. You can find the following example in the Windows 7 SDK.
To add a thumbnail toolbar button you need to use the ITaskbarList4 Interface that exposes methods that allow you to dynamically add, remove, and activate items on the taskbar. Specifically, for working with the thumbnail toolbar you need to use the following methods:
Like every Taskbar icon-related operation, you need to make sure you have a Taskbar icon to work with; to ensure that you have one, you need to register the “TaskbarCreatedMessage” using the RegisterWindowMessage method. Then you need to wait for the message to arrive to your Win32 WndProc method. Once your application receives this message, you are safe to go ahead and create the thumbnail toolbar buttons. The same WndProc method will also receive the WM_COMMAND message when any of the thumbnail buttons you created is clicked. The lower word of the wParam parameter holds the specific button id, signifying which button was pushed, while the upper word is just set to THBN_CLICKED. The following code snippet illustrates this process
LRESULT CALLBACK WndProc(
HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
static UINT s_uTBBC = WM_NULL;
if (s_uTBBC == WM_NULL)
{
// Compute the value for the TaskbarButtonCreated message
s_uTBBC = RegisterWindowMessage(L"TaskbarButtonCreated");
// In case the application is run elevated, allow the
// TaskbarButtonCreated and WM_COMMAND messages through.
ChangeWindowMessageFilter(s_uTBBC, MSGFLT_ADD);
ChangeWindowMessageFilter(WM_COMMAND, MSGFLT_ADD);
}
if (message == s_uTBBC) //wmTaskbarButtonCreated)
{
// Once we get the TaskbarButtonCreated message, we can create
// our window's thumbnail toolbar.
CreateThumbnailToolbar(hWnd);
}
else switch (message)
{
case WM_COMMAND:
{
int const wmId = LOWORD(wParam);
switch (wmId)
{
case IDTB_BUTTON1:
case IDTB_BUTTON2:
case IDTB_BUTTON3:
{
WCHAR szMsg[100];
StringCchPrintf(
szMsg, ARRAYSIZE(szMsg),
L"Thumbnail toolbar button clicked,
ID=%d", wmId);
MessageBox(hWnd, szMsg, L"Application", MB_OK);
break;
}
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
}
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
Note that right after you register to listen for the TaskbarCreatedMessage message, you call the ChangeWindowMessageFilter method. This method adds or removes a message from the User Interface Privilege Isolation (UIPI) message filter. You need to do so in case you are running elevated application. In short, the Taskbar is part of the explorer.exe process, which runs in medium integrity level – that is, as a standard user. Since Windows Vista and the introduction of UIPI, lower level privileged applications can’t send Windows messages to high level applications. Therefore, you need to change the filter to allow specific messages to be received from a lower integrity sender, specifically the result of the TaskbarCreatedMessage and WM_COMMAND. This looks like a topic for another post just about UIPI, which I’ll write sometime soon.
Back to our topic, you can see that we handle the WM_COMMAND in a very simple way, extracting the specific button ID from the lower word of the wParam parameter. We don’t really do anything with it (the switch is the same for all buttons); it is just an example.
Next let’s describe what it takes to register the thumbnail toolbar. In the above code snippet, we call the CreateThumbnailToolbar helper method. The following is the relevant code snippet.
HRESULT CreateThumbnailToolbar(HWND hWnd)
{
ITaskbarList4 *pTaskbarList;
HRESULT hr = CoCreateInstance(
CLSID_TaskbarList,
NULL,
CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(&pTaskbarList));
if (SUCCEEDED(hr))
{
hr = pTaskbarList->HrInit();
if (SUCCEEDED(hr))
{
// Figure out what bitmap to use for the
// thumbnail toolbar buttons - we decision
// based on the system's small icon width.
// This will make us DPI-friendly.
struct
{
PCWSTR pbmp;
int cx;
}
const bitmaps[3] =
{
{ MAKEINTRESOURCE(IDB_BUTTONIMAGES_96), 16 },
{ MAKEINTRESOURCE(IDB_BUTTONIMAGES_120), 20 },
{ MAKEINTRESOURCE(IDB_BUTTONIMAGES_144), 24 }
};
int const cxButton = GetSystemMetrics(SM_CXSMICON);
int iButtons = 0;
for (int i = 0; i < ARRAYSIZE(bitmaps); i++)
{
if (bitmaps[i].cx <= cxButton)
{
iButtons = i;
}
}
HIMAGELIST himl = ImageList_LoadImage(
g_hInstance,
bitmaps[iButtons].pbmp,
bitmaps[iButtons].cx,
0,
RGB(255,0,255),
IMAGE_BITMAP,
LR_CREATEDIBSECTION);
if (himl)
{
hr = pTaskbarList->ThumbBarSetImageList(hWnd, himl);
if (SUCCEEDED(hr))
{
THUMBBUTTON buttons[3] = {};
// First button
buttons[0].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
buttons[0].dwFlags = THBF_ENABLED | THBF_DISMISSONCLICK;
buttons[0].iId = IDTB_BUTTON1;
buttons[0].iBitmap = 0;
StringCchCopy(buttons[0].szTip,
ARRAYSIZE(buttons[0].szTip), L"Button 1");
// Second button
buttons[1].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
buttons[1].dwFlags = THBF_ENABLED | THBF_DISMISSONCLICK;
buttons[1].iId = IDTB_BUTTON2;
buttons[1].iBitmap = 1;
StringCchCopy(buttons[1].szTip,
ARRAYSIZE(buttons[1].szTip), L"Button 2");
// Third button
buttons[2].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
buttons[2].dwFlags = THBF_ENABLED | THBF_DISMISSONCLICK;
buttons[2].iId = IDTB_BUTTON3;
buttons[2].iBitmap = 2;
StringCchCopy(buttons[2].szTip,
ARRAYSIZE(buttons[2].szTip), L"Button 3");
// Set the buttons to be the thumbnail toolbar
hr = pTaskbarList->ThumbBarAddButtons(
hWnd,
ARRAYSIZE(buttons),
buttons);
}
ImageList_Destroy(himl);
}
}
// It's OK to release ITaskbarList3 here;
// the thumbnail toolbar will remain.
pTaskbarList->Release();
}
return hr;
}
First, you need to Co-Create the ITasbarList4 COM interface. Next as standard practice, you need to call HrInit to initialize the Taskbar list object. This method must be called before any other ITaskbarList methods can be called. Next, set up a bitmap list to work with. Note that you need to check the recommended size of the width (in pixels) of a small icon: your DPI setting can affect this. Finally, call ThumbBarSetImageList to set the icons of the buttons. When you download the source code, try to comment this line and run the app. What do you think happens?
Next, we create an array of three THUMBBUTTONs and for each button we set the bitmap, tooltip, and flags. This is used to configure the toolbar button. For example, the bitmap value indicates that the value of the iBitmap field (part of THUMBBUTTON) is valid. The THB_FLAGS is more interesting as you can use it to specify the button’s states and behaviors, like enable, disable, or hidden. You can find more options in the SDK. We also set the button ID to distinguish between each button once it is clicked; this ID is sent with the WM_COMMAND message.
You can use the Windows API Code Pack to create thumbnail toolbars for managed code applications. The following is part of the Windows 7 Training Kit that is available on the Channel 9 Learning Center. The Taskbar Concepts demo, created by Jaime Rodriguez, is a WPF application that showcases EVERY little feature the Windows Taskbar has to offer developers. We’ll explore just the thumbnail toolbar part, and I will leave the rest for you to explore on your own. From time to time, we’ll use this as base to our managed code samples for WPF applications.
As always while using the Windows API Code Pack, you don’t have to worry about registering or handling any Windows messages. Just use the TaskbarManager. Specifically, you want to work with ThumbnailToolbars, which has an AddButtons method that you need to use while adding ThumbnailToolbarButton objects. The ThumbnailToolbarButton represents a taskbar thumbnail button through which you can enable or disable the taskbar button, change its icon or tooltip, and control its visibility. You can also attach an event handler to the button Click event, as you would expect from managed code (note: there is no need to handle funky Windows Messages). You can find the following code snippet in the ToolbarButtons.xaml.cs file. It shows how easy it is to add thumbnail toolbars to your managed code application
private void CreateToolbarButtons()
{
buttonFirst = new ThumbnailToolbarButton(
TaskbarConcepts.Resources.first, "First Image");
buttonFirst.Enabled = false;
buttonFirst.Click += buttonFirst_Click;
buttonPrevious = new ThumbnailToolbarButton(
TaskbarConcepts.Resources.prevArrow, "Previous Image");
buttonPrevious.Enabled = false;
buttonPrevious.Click += buttonPrevious_Click;
buttonNext = new ThumbnailToolbarButton(
TaskbarConcepts.Resources.nextArrow, "Next Image");
buttonNext.Click += buttonNext_Click;
buttonLast = new ThumbnailToolbarButton(
TaskbarConcepts.Resources.last, "Last Image");
buttonLast.Click += buttonLast_Click;
TaskbarManager.Instance.ThumbnailToolbars.AddButtons
(
new WindowInteropHelper(Application.Current.MainWindow).Handle,
buttonFirst,
buttonPrevious,
buttonNext,
buttonLast
);
}
The rest of the code in this file is responsible for the logic and handling of different events. This results in the ability to control the different images displayed in the main application as you can see in the following image.
I hope by now you see the value of including thumbnail toolbar (where appropriate), and how easy it is to implement.
I still owe you explanation for the reason there are six buttons and not five in the Fishbowl thumbnail toolbar (see image). If you take a careful look at the image, you’ll notice that the four left buttons directly effects the application’s behavior, where the right single button simply lunch your default browser and automatically loads Facebook website. Therefore it makes sense to a graphical separation between the different sets of buttons. The application creates six buttons, but the fifth one is hidden, creating the illusion of space between the buttons. To do so, you need to use ThumbBarUpdateButtons for Win32 application.
Managed developer will find it much easier to hide a ThubmnailButton. A closer look into the Windows API Code pack, you will find that the ThubmnailButton class has a Visible property for controlling the visibility of the specific toolbar button. At the end of the Visible Set section you will find a call UpdateThumbnailButton() function which is basically a wrapper for the native ThumbBarUpdateButtons method.
You can download the Win32 Native sample.
You can download the managed code (WPF) sample
You can find more Windows 7 Taskbar training at the Channel 9 Learning Center
During PDC, we announced the availability of a new version of the Windows API Code Pack (version 1.0.1). That same day, I had the pleasure of demo-ing how to use the API Code Pack to build great Windows 7 applications. If you missed the session (or weren’t able to attend PDC), you can check out the video recording and grab the decks from session page – Developing with the Windows API Code Pack for Microsoft .NET Framework.
While Windows 7 is an awesome operating system that runs faster while consuming fewer resources than its predecessor, it also includes new exciting features and capabilities that both users and developers can enjoy. Taskbar, Sensor and Location platform, Libraries, Multitouch, new DirectX capabilities, and graphics improvements are just a few of the many technologies and features that Windows 7 offers developers to help your applications shine while running on Windows 7.
The number of commercial applications that leverage the various Windows 7 technologies is too long to list, but here are a few popular applications that we demonstrated during the PDC Keynote and that shine on Windows 7: iTunes, Kindle for PDC, Autodesk Project Cooper, and Seesmic Desktop.
While not all of the above-mentioned applications use the API Code Pack (some are not even managed), they all tap Windows 7 features to enhance the user experience. The Windows API Code Pack enables managed code developers to take advantage of such features and build great windows applications. During the session, I presented a few examples of managed applications that leverage Windows 7 features:
Next we dived into a few demos showcasing implementation of the Windows API Code Pack. I included the code for each demo:
You can download the updated deck including the speaker notes and watch the video.
You can learn about the above mentioned technologies and on developing for Windows 7 using the Windows 7 Training Kit for Developers or by viewing Windows 7 videos on Channel 9.
During Wednesday’s keynote, Brian Goldfarb demoed an amazing Silverlight 4 client for Facebook. Beyond its amazing looks, this Silverlight 4 demo provides a full and complete desktop client application for Windows (and Mac). SilverFace is built on top of Silverlight 4 – also announced during the keynote. If you want a cool Facebook client application to work on from your Windows desktop, you should take a look at the Fishbowl for Facebook Preview. Fishbowl is a great WPF application that you can install and enjoy as a user, and at the same time it is a great code sample for developers whom are looking to write WPF applications that use Windows 7 features. If you are interested, you can download the source code for Fishbowl.
In today’s world, the client’s experience is more important than ever before. Your application doesn’t just have to be fun and interesting; it has to be good looking, polished, and functional, providing a “natural” user experience that just works. As a developer, you need to push the envelope and use any available technical tool that the OS provides or any other available means (if installed on mobile devices) to provide a superior user experience, or users will switch to the next guy. In such a competitive scenario, using the Windows 7 Taskbar to shave a few seconds from day-to-day tasks looks like a very obvious choice.
Both Silverlight 4 demo and Fishbowl applications each provide a great UX and enhance user productivity. Scott Guthrie also announced the Facebook SDK for managed code applications that combines the latest in Web and Client platform innovations with leading Social technologies (services) to help developers plug into Facebook. But, beside the new Facebook SDK and beside the great looks, the Fishbowl application is a great WPF (3.5) example that demonstrates how to write applications that produce amazing experiences on Windows 7.
As a WPF application, Fishbowl runs on multiple Windows versions, including Windows XP, Windows Vista, and Windows 7, and it integrates with the Windows 7 Taskbar and Multitouch. One of the main ideas behind the Taskbar is to provide users with quick and easy access to their content and help them accomplish tasks and navigate between windows easier and with more confidence. For example, JumpList provides a great tool for surfacing common work items and tasks. If you have a task that you perform once or twice a day, taking two or three clicks to perform the task is not that bad. However, if you have a task that you perform 10, 20, or even 30 more times, using JumpList tasks or items in the recent category list goes a long way. Facebook users often check their wall, write notifications and messages, view friends’ pictures, and so on. Therefore, in some scenarios, the Taskbar JumpList tasks, icon notification, thumbnail buttons, and other functionality become major tools in the application.
Fishbowl uses the taskbar to provide a quick, easy, and seamless integration with Facebook functionality directly from your Taskbar. Let’s review some of the user functionality before jumping into code behind.
different scenarios provides an amazing user experience in heavily used application like Fishbowl.
When Fishbowl runs in normal mode, the Taskbar JumpList reflects items and tasks that you can actually perform in the context of a running application, like viewing the last few notifications and messages that you received without opening the application, as shown by the following image.
If you hover with the mouse above the Fishbowl control, you see the thumbnail preview provided by Windows 7 taskbar. However, Fishbowl uses the thumbnail button again allowing you to both view a preview of the application and act immediately upon the thumbnail preview as shown in the following image.
(And thank you Raman for writing so many PDC tweets J)
Fishbowl also has a mini-mode operation mode. This mode shows just one message in a small window. As you can see in the following image, a small arrow allows you to switch between messages. When you hover over Fishbowl taskbar icon, you can see the preview but you can also control the message, again using the taskbar thumbnail preview.
Besides great Taskbar integration, Fishbowl offers a great Multitouch experience, allowing you to scroll between messages using your finger to touch the touch screen. It is a little hard to illustrate Multitouch with screen capture so you will have to trust me on this one.
We’ve covered most of the Fishbowl features unique to Windows 7, and in the next post I will dive into the API that enabled these Taskbar and Multitouch features. If you are interested, you can download the source code for Fishbowl.
I am glad to announce that today we shipped a new version of the Windows API Code Pack – version 1.0.1. This is not a major version with a lot of new features, but rather a minor version focused on fixing bugs, improving performance, adding demos and few features updates (new wrappers…)
But before we dive into this new version of the Windows Code Pack let’s better understand what this Windows API Code Pack is all about.
Windows 7 offers new features like the taskbar, libraries, and the Sensor and Location platform, to name a few. These features enable new scenarios and create new opportunities for developers to make their applications shine on Windows 7. All these great features are exposed via the Win32 native API. Currently there is no “Windows 7” namespace in the .NET Framework, and no easy way to use these features from managed code applications. To help managed code developers access them, we released version 1.0 of the Windows API Code Pack for the .NET Framework in August (just after Windows 7 RTM).
The Windows API Code Pack is a free, managed Source Code Library provided by Microsoft as is. You should consider this library as if you wrote it yourself, as if it is your own code. It is a great starting point and provides a really good and solid solution for managed code developers. It covers a lot of the new Windows 7 features as well as some more fundamental core features from the Windows Vista timeframe. You may think of the Windows API Code Pack as the closest thing to an “official” managed API for Windows. But you need to remember that it’s not a product with 24×7 technical support available from Microsoft Customer Service and Support. We believe it is a great solution, and that the codebase is very solid and high quality.
Our goal with the code pack is to enable managed code developers to take advantage of Windows APIs that are not part of the .NET Framework. We feel that as a shared source that is separate from the .NET runtime libraries, the Windows API Code Pack provides an optimal compromise between the Microsoft Win32 managed wrapper, short time-to-market -we released the Windows API Code Pack just a month after the Win7 RTM, and we ship full source code of the library.
The Windows API Code Pack includes a great deal of managed API for Windows (7). For example:
Each technology represented in the Windows API Code Pack has multiple demos and examples (including source) in C# and VB. We are planning on releasing updates to the Windows API Code Pack roughly every three months. We will be investing mainly in stability (meaning fixing bugs), fundamentals, testing and documentation, as well as new feature support (based on customer feedback).
You may ask yourself, “Why isn’t the Windows API Code Pack part of the .NET Framework?”
We ship open source code that we might bring into the runtime sometime in the future, if we feel it’s sufficiently core to the entire framework to be worth the size increase. Remember the .NET Framework runs on both Windows Vista and Windows XP. However, Windows 7 is here now, and we want to enable you to access this set of free, open source library sooner rather than later. We’re shipping this library in a community-supported form and, as you can see, we intend to keep updating it. While this version (1.0.1) is a minor release, we are planning on another release in the next few months. In the meantime, you get the best of both worlds in a package that you can use as a whole or in parts without restriction.
Another question you may ask is, “Will .NET 4 replace the need to use the Windows API Code pack?”
When .NET 4 ships, you will be able to use its Windows 7 features such as Taskbar and multitouch integration with WPF, DirectWrite support, and the location API via the Devices namespace. Continue to access other features such as libraries, Restart Manager, and Sensors via the Windows API Code Pack.
Last but not least, we are looking for feedback from the community – that is you the .NET developer using this library to write managed code applications for Windows 7. On the Windows API Code Pack site, you can ask questions, provide feedback, report bugs, and follow open bugs. Your input is critical for the continuation of this library, so please send us your feedback and questions.
To learn more about how to use the Windows API Code Pack check the Windows 7 Training on Channel 9

Categories
Tag Cloud
Blog RSS
Comments RSS
Last 50 Posts
Back
Back
Void « Default
Life
Earth
Wind
Water
Fire
Light 