views:

48

answers:

3

How can I write or draw controls to the Windows 7 preview area using C#? For an example of what I am talking about, open Windows Media Player in Windows 7 and play a song. While the song is playing, minimize Windows Media player, then hover your mouse over the Windows Media Player icon and you will see a pause, rewind and fast forward button just below the actual Media Player preview window. How can I duplicate this kind of behavior in C#?

+2  A: 

You're looking for Windows 7 Thumbnail Toolbars:

Thumbnail toolbars provide a mini "remote-control" opportunity for a window from its thumbnail. For example, to switch to the next song in Windows Media Player you don't need to use the clumsy Media Player desk band or to switch to the Media Player application. Instead, you can use the thumbnail toolbar directly to perform this task, without interrupting your work flow by jumping to another application.

Copied shamelessly from that MSDN article:

//In your window procedure:
switch (msg) {
    case g_wmTBC://TaskbarButtonCreated
        THUMBBUTTON buttons[2];
        buttons[0].dwMask = THB_ICON|THB_TOOLTIP|THB_FLAGS;
        buttons[0].iId = 0;
        buttons[0].hIcon = GetIconForButton(0);
        wcscpy(buttons[0].szTip, L"Tooltip 1");
        buttons[0].dwFlags = THBF_ENABLED;
        buttons[1].dwMask = THB_ICON|THB_TOOLTIP|THB_FLAGS;
        buttons[1].iId = 1;
        buttons[1].hIcon = GetIconForButton(1);
        wcscpy(buttons[0].szTip, L"Tooltip 2");
        buttons[1].dwFlags = THBF_ENABLED;
        VERIFY(ptl->ThumbBarAddButtons(hWnd, 2,buttons));
        break;
    case WM_COMMAND:
        if (HIWORD(wParam) == THBN_CLICKED)
        {
            if (LOWORD(wParam) == 0)
                MessageBox(L"Button 0 clicked", ...);
            if (LOWORD(wParam) == 1)
                MessageBox(L"Button 1 clicked", ...);
        }
        break;
}
Michael Petrotta
A: 

That's the thumbnail area:

Setting a Bitmap in Windows 7 thumbnail preview (C#)

Working with Windows 7 Thumbnails (this one shows exactly what you described about Windows Media Player)

Leniel Macaferi
A: 

Since this had the C# tag I'm guessing you would like to do this in managed code. Take a look at the Windows API Code Pack which includes samples of live thumbnails, thumbnail buttons, clipped thumbnails, tabbed thumbnails etc. It is thumbnail buttons that you are looking for and two or three lines of code will take care of it.

BTW, the preview area is what you get in Windows explorer when you select say a .txt file and can see the content to the right. Most office files have previewers and you can write your own too.

Kate Gregory