Pregunta

Sé que probablemente me falta algo, pero parece que no puedo obtener ventanas para mostrar la vista previa en miniatura en vivo correctamente cuando uso una ventana que tiene una región. Al presionar el botón minimizar, la vista previa se recortará al tamaño minimizado (160x25) en lugar de mostrar la vista previa completa (como lo hace con otras ventanas).

Pocos puntos para hacer:

1) La vista previa funciona bien en Windows Live Messenger, por lo que Microsoft descubrió una forma de hacerlo.

2) Si llamo a SetWindowRgn solo antes de que una ventana sea visible, funciona bien (por lo que no es culpa del DWM no saber cómo lidiar con las ventanas regionales). Puedo llamar a SetWindowRgn muchas veces antes de que la ventana sea visible y funciona muy bien.

3) Necesito establecer la región de la ventana después de mostrar la ventana en caso de un cambio de tamaño. Entonces, una solución para configurarlo antes no funcionará.

4) Incluso cuando se utiliza el procedimiento de ventana predeterminado, el error aún ocurre. Por lo tanto, no es un error procesar un mensaje incorrectamente (pero podría ser un error de "no procesar" uno :))

5) Al minimizar haciendo clic en el botón de la barra de tareas (en lugar del botón de minimizar en la ventana), la vista previa normalmente funciona bien (incluso después de configurar la región cuando es visible). Una vez más, demuestra que no se trata de lidiar con la vista previa.

El error ocurre si configuro una región después de haber mostrado la ventana. Código a seguir:

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;
}
¿Fue útil?

Solución

Microsoft respondió a un incidente de soporte técnico y lo enumeró como un error en Vista.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top