Damien
Damien

Reputation: 1647

GDI+ and AnimateWindow

I'm drawing an image onto my client area using GDI+, which works great until I use AnimateWindow to show the dialog. In this scenario and drawing done by GDI+ is not shown. Is there a way around this? I am using Win32 C++. My code so far:

BOOL CALLBACK MyClass::DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    HDC hdc;
    PAINTSTRUCT ps;

    switch(msg)
    {
    case TRACK_CHANGED:
        if(IsWindowVisible(hWnd)) {
            RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE);
        }
        else {
            //ShowWindow(hWnd, SW_SHOW);
            AnimateWindow(hWnd, 200, AW_ACTIVATE | AW_BLEND);
        }
        break;

    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);
        OnPaint(hdc);
        EndPaint(hWnd, &ps);
        return FALSE;
        break;

    case WM_CLOSE:
        //ShowWindow(hWnd, SW_HIDE);
        AnimateWindow(hWnd, 200, AW_HIDE | AW_BLEND);
        break;

    case WM_COMMAND:
        switch(LOWORD(wParam))
        {
        case IDC_CLOSE:
            //ShowWindow(hWnd, SW_HIDE);
            AnimateWindow(hWnd, 200, AW_HIDE | AW_BLEND);
            break;
        }
        break;

    default:
        return FALSE;
    }
    return TRUE;
}

void MyClass::OnPaint(HDC hdc)
{
    Graphics graphics(hdc);
    Image image(L"testImage.png");
    graphics.DrawImage(&image, 0, 0);
}

Upvotes: 1

Views: 829

Answers (0)

Related Questions