Writing to the Windows 7 “preview” window area

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 06:45:17

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;
}

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!