SetWindowRgn的Vista实时缩略图问题

问题描述:

我知道我可能丢失了一些东西,但是当使用具有区域的窗口时,似乎无法让窗口正确显示实时缩略图预览.按下最小化"按钮时,预览将裁剪为最小尺寸(160x25),而不是显示完整的预览(就像其他窗口一样).

I know I am probably missing something, but I can't seem to get windows to show the live thumbnail preview correctly when using a window that has a region. When hitting the minimize button the preview will clip to the minimized size (160x25) rather than showing the full preview (like it does with other windows).

要点:

1)预览在Windows Live Messenger中工作正常,因此Microsoft找到了一种方法.

1) The preview works fine in Windows Live Messenger, so Microsoft figured out a way to do it.

2)如果仅在窗口可见之前调用SetWindowRgn,则它可以正常工作(因此,DWM不知道如何处理区域窗口是不对的.)我可以在窗口可见之前多次调用SetWindowRgn.它很棒.

2) If I call SetWindowRgn only before a window is visible, it works fine (so its not a fault of the DWM not knowing how to deal with regioned windows.) I can call SetWindowRgn many times before the window is visible and it works great.

3)在调整大小后,我需要在显示窗口后设置窗口区域.因此,仅在之前进行设置的修补程序将无法正常工作.

3) I need to set the window region after I show the window in case of a resize. So a fix to just set it before will not work.

4)即使使用默认的窗口过程,该错误仍然会发生.因此,这不是错误地处理消息的错误(但可能是未处理"的错误:))

4) Even when using the default window procedure, the bug still happens. So it is not a fault of processing a message incorrectly (but could be a fault of 'not processing' one :) )

5)当通过单击任务栏按钮(而不是窗口中的最小化按钮)进行最小化时,预览正常运行(即使在设置了可见区域后也是如此).再次证明它不会如何处理预览.

5) When minimizing by clicking the taskbar button (instead of the minimize button in the window), the preview normally works fine (even after setting the region when visible). Again proving that it does not how to deal with the preview.

如果在显示窗口后设置区域,则会发生该错误.遵循的代码:

The bug happens if I set a region after I have shown the window. Code to follow:

void create(HINSTANCE hInst)
{
    char* className = "default";

    /* Register
    */
    WNDCLASSEX wcex;
    memset(&wcex,0,sizeof(wcex));
    wcex.cbSize = sizeof(WNDCLASSEX);
    wcex.style          = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc    = DefWindowProc;
    wcex.hInstance      = hInst;
    wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
    wcex.lpszClassName  = className;
    RegisterClassEx(&wcex);

    /* Create
     */
    HWND hwnd = CreateWindow(className, className, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL);

    /* 
     * Set the region
     * If set before the window is shown for the first time, minimize preview on vista works
     */

    RECT rect;
    GetWindowRect(hwnd,&rect);
    HRGN rgn = CreateRoundRectRgn(0,0,rect.right-rect.left,rect.bottom-rect.top,15,15);
    SetWindowRgn(hwnd,rgn,TRUE);

    /* Show the window
     */

    ShowWindow(hwnd,SW_SHOW);

    /* 
     * Set the region a second time.
     * Doing this will break minimize preview on vista
     */

    rgn = CreateRoundRectRgn(0,0,rect.right-rect.left,rect.bottom-rect.top,35,35);
    SetWindowRgn(hwnd,rgn,TRUE);
}

int APIENTRY _tWinMain(HINSTANCE hInstance,
                 HINSTANCE hPrevInstance,
                 LPTSTR    lpCmdLine,
                 int       nCmdShow)
{
    MSG msg;

    create(hInstance);

    while (GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    return (int) msg.wParam;
}

Microsoft对技术支持事件做出了回应,并将其列为Vista中的错误.

Microsoft responded to a tech support incident and listed this as a bug within Vista.