0

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).

Few points to make:

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

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

1 回答 1

0

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

于 2009-09-28T16:27:22.870 回答