1

我正在使用 GDI+ 将图像绘制到我的客户区,在我使用 AnimateWindow 显示对话框之前效果很好。在这种情况下,由 GDI+ 完成的绘图未显示。有没有解决的办法?我正在使用 Win32 C++。到目前为止我的代码:

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

0 回答 0