使用GDI+编写的程序,在windows server 2003以及有些xp系统下无法显示 请教各位,这是什么原因呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 有什么特点呢?GDI+使用了哪些东西? 是不是DLL没放对地方啊。 不好意思,没有说清楚我使用了UpdateLayeredWindowSetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE,GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE)^0x80000)其他就是使用常用的Graphics的DrawImage 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);} 把GdiPlus.dll拷贝过去, 这个dll版本很多, 最好在你的程序目录中放一个你自己的版本QQ就是这样的 WinMain的原型的问题 在什么地方放置一个函数,可以让其它类都可以调用啊? 提问 要想从文件的某一个位置读数据用什么类方便一点 程序运行到CoUninitialize就出错,是为什么呢? 希望得到帮助,感激不尽!!! 一个与PDF有关地小项目,欢迎大家接着 能ping通一个网站,却连不上。请高手详细解释一下原因。谢谢! 如何用应用程序访问web服务器,向服务器发送数据或从服务器接收数据? 请教:在VC下用MD5算法写的加密DLL,用Delphi和VC调用后,所加密的字串不一样,为什么?怎样解决?谢谢! vc 如何打内存补丁? 指针字符串的截取 请高手帮忙·谢谢
我使用了UpdateLayeredWindow
SetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE,GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE)^0x80000)
其他就是使用常用的Graphics的DrawImage
{
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);}