How to restore a minimized window without flickering

I created a vulnerability for Windows Vista that sometimes requires a minimized window to be restored. I managed to do this using the SetWindowPlacement function. The problem is that it also redraws the window, which looks like crap after the window glides beautifully into the screen.

This is the code I use to bring the window to the top and focus:

    private static void ActivateWindow(IntPtr windowToShow)
    {
        RectAPI r = new RectAPI();
        Win32.GetWindowRect(windowToShow, ref r);

        if (r.top == -32000) //r.top is -32000 if the window is in minimized state
        {
            WINDOWPLACEMENT wp = new WINDOWPLACEMENT();
            Win32.GetWindowPlacement(windowToShow, ref wp);

            if (wp.flags == WindowPlacementFlags.WPF_RESTORETOMAXIMIZED)
                wp.showCmd = cmdShow.SW_SHOWMAXIMIZED;
            else
                wp.showCmd = cmdShow.SW_RESTORE;

            Win32.SetWindowPlacement(windowToShow, ref wp);
        }

        Win32.SetForegroundWindow(windowToShow);
    }

If I use it in a window that has already been restored, it will only call SetForegroundWindow, and the window will go to the top of the z-order and get focus without any flicker.

But if I call it in a minimized window, I must also use SetWindowPlacement to return the window to a restored state. This is what makes the window redraw and flicker: /

, .

+5
3

- : , , . , , , . , ?..

, , WM_ERASEBKGND (, , , ), ---.

+2

MSDN , . , /, .

!!

+1

OP... cookie.

, flip3d , , . , flip3d, 3d-, .

, , , :/

0

All Articles