请教各位,这是什么原因呢?

解决方案 »

  1.   

    有什么特点呢?GDI+使用了哪些东西?
      

  2.   

    是不是DLL没放对地方啊。
      

  3.   

    不好意思,没有说清楚
    我使用了UpdateLayeredWindow
    SetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE,GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE)^0x80000)
    其他就是使用常用的Graphics的DrawImage
      

  4.   

    OnPaint中的代码void Cw4uDlg::OnPaint() 
    {
    if (IsIconic())
    {
    CPaintDC dc(this); // 用于绘制的设备上下文 SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); // 使图标在工作矩形中居中
    int cxIcon = GetSystemMetrics(SM_CXICON);
    int cyIcon = GetSystemMetrics(SM_CYICON);
    CRect rect;
    GetClientRect(&rect);
    int x = (rect.Width() - cxIcon + 1) / 2;
    int y = (rect.Height() - cyIcon + 1) / 2; // 绘制图标
    dc.DrawIcon(x, y, m_hIcon);
    }
    else
    {
    CPaintDC dc(this);
    CRect rcClient;
    GetClientRect(&rcClient);
    // 建立内存DC
    CDC tempdc;
    HDC m_hdcMemory = CreateCompatibleDC(dc.m_hDC);
    HBITMAP hBitMap = CreateCompatibleBitmap(dc.m_hDC,rcClient.Width(),rcClient.Height()); HBITMAP oldBmp = (HBITMAP)SelectObject(m_hdcMemory, hBitMap);
        
    //使用GDI+绘制内存DC,它可以加入Aphla通道
    Gdiplus::Graphics graph(m_hdcMemory);
    DrawPic(graph);  // 在这里写字+阴影
    // 用这个GDI+画好的DC代替窗体原来的图形
    CRect rect;
    this->GetWindowRect( rect );
    POINT ptWinPos = {rect.left,rect.top};
    SIZE sizeWindow = {rect.Width(), rect.Height()};
    POINT ptSrc = {0, 0};
    BLENDFUNCTION Blend={AC_SRC_OVER,0,255,AC_SRC_ALPHA}; BOOL bRet = UpdateLayeredWindow( this->m_hWnd, dc.m_hDC, &ptWinPos,&sizeWindow, m_hdcMemory, &ptSrc, 0, &Blend, 0x0002);// ShowErrorMsg( GetLastError() ); DeleteObject(hBitMap); SelectObject(m_hdcMemory,oldBmp); graph.ReleaseHDC(m_hdcMemory);

    DeleteDC(m_hdcMemory);
    }
    }
    绘制文本的代码void Cw4uDlg::DrawPic(Gdiplus::Graphics &graph)
    {
    using namespace Gdiplus; Gdiplus::FontFamily fontFamily(L"幼圆");
    Gdiplus::Font font(&fontFamily, 24); 
    CRect t_rect;
    GetClientRect( t_rect );
    Gdiplus::Rect r(t_rect.left,t_rect.top,t_rect.Width(),t_rect.Height()); Gdiplus::PointF pt(0, r.Height / 3);
    SolidBrush brSolid( Gdiplus::Color::CornflowerBlue );  // 前景色
    SolidBrush brSolid1( Gdiplus::Color::Yellow );  // 前景色
    SolidBrush brShadowSolid( Gdiplus::Color::Black );  // 阴影色
    Pen p(Color::Black,1); GraphicsPath pth; int style = FontStyleRegular;
    pth.AddString(text,-1,&fontFamily,style,49,Point(0,0),NULL);

    // 建立内存位图
    const float f = 1.0/2.0;
    Gdiplus::Bitmap bmp(r.Width * f, r.Height * f, &graph);
    {
    Gdiplus::Graphics bg(&bmp);
    bg.SetTextRenderingHint(TextRenderingHintAntiAlias);
    bg.SetSmoothingMode(SmoothingModeAntiAlias); //缩放输出阴影文字
    Gdiplus::Matrix m(f , 0, 0, f , -0.2, -0.4);
    bg.SetTransform(&m); bg.FillPath( &brShadowSolid, &pth );
    bg.DrawPath( &p, &pth );
    } // 设置插值模式为高质量双三次插值法
    graph.SetInterpolationMode(InterpolationModeHighQualityBilinear);
    graph.SetTextRenderingHint(TextRenderingHintAntiAlias); // 放大输出阴影位图到画布
    graph.DrawImage(&bmp, r, 0, 0, bmp.GetWidth(), bmp.GetHeight(), UnitPixel);}
      

  5.   

    把GdiPlus.dll拷贝过去, 这个dll版本很多, 最好在你的程序目录中放一个你自己的版本QQ就是这样的