GDI+桌面歌词 BCB版

jaffy 2011-05-31 11:04:20
加精
前些天看到一个DELPHI的桌面歌词,用的是IGDI的接口,我用了一下那个接口,对DELPHI挺方便的;
但自我感觉还没有MAOZEFA封装的库好用;这两天找了时间写了这个程序,分别用的就是MAOZEFA的GDI+库,和妖哥的Gdiplus库

这里给出主要函数的源码,需要全部源码的去我空间下载吧!

bool __fastcall TForm1::UpdateDisplay(WideString pszbuf,bool bBack,int Transparent)
{
HDC hdcTemp,hdcScreen,m_hdcMemory;
HBITMAP hBitMap;
BLENDFUNCTION blend;
TPoint ptWinPos,ptSrc;
SIZE sizeWindow;

hdcTemp = GetDC(this->Handle);
m_hdcMemory = CreateCompatibleDC(hdcTemp);
hBitMap = CreateCompatibleBitmap(hdcTemp,755,350);

SelectObject(m_hdcMemory,hBitMap);
if ((Transparent < 0) ||(Transparent > 100))
Transparent = 100;

blend.BlendOp = AC_SRC_OVER;
blend.BlendFlags = 0;
blend.AlphaFormat = AC_SRC_ALPHA;
blend.SourceConstantAlpha = int(Transparent * 2.55);;

hdcScreen = GetDC(this->Handle);

TRect rct;
GetWindowRect(this->Handle,&rct);

ptWinPos.x = rct.Left;
ptWinPos.y = rct.Top;

TGpGraphics *graphics = new TGpGraphics(m_hdcMemory);

graphics->SmoothingMode = SmoothingModeAntiAlias; //指定平滑(抗锯齿)
graphics->InterpolationMode = InterpolationModeHighQualityBicubic;//指定的高品质,双三次插值

TGpFontFamily *fontFamily = new TGpFontFamily(WideString("宋体")); //△字体,效果图为'微软雅黑'字体

TGpStringFormat *strFormat = new TGpStringFormat();
TGpGraphicsPath *path = new TGpGraphicsPath();

path->AddString(pszbuf,fontFamily,TFontStyles()<<fsBold,38,TGpPoint(10,10),strFormat);

TGpPen *pen = new TGpPen(TGpColor(155,215,215,215),3);

graphics->DrawPath(pen,path);

TGpLinearGradientBrush *linGrBrush;
linGrBrush = new TGpLinearGradientBrush(TGpPoint(0,0), //线性渐变起始点
TGpPoint(0,90), //线性渐变终结点
TGpColor(255,255,255,255), //线性渐变起始色
TGpColor(255,30,120,195));

TGpLinearGradientBrush *linGrBrushW;
linGrBrushW = new TGpLinearGradientBrush(TGpPoint(0,10),
TGpPoint(0,60),
TGpColor(255,255,255,255),
TGpColor(15,1,1,1));

//---------------------开始:画字符串阴影--------------------------------------
for(int i=0;i<8;i++)
{
pen->Width = i+1;
pen->Color = TGpColor(62, 0, 2,2);
pen->LineJoin = LineJoinRound;
graphics->DrawPath(pen,path);
}
//---------------------开始:画背景框和背景图----------------------------------
if(bBack)
{
TGpSolidBrush *brush = new TGpSolidBrush(TGpColor(25,228,228,228));
TGpPen *pen1 = new TGpPen(TGpColor(155, 223, 223,223),3);
TGpPen *pen2 = new TGpPen(TGpColor(55, 223, 223,223),3);

TGpImage *Image = new TGpImage("back.png");

graphics->FillRectangle(brush,3,5,750,90);
graphics->DrawRectangle(pen1,2,6,751,91);
graphics->DrawRectangle(pen2,1,5,753,93);
graphics->DrawImage(Image,600,25);
}
graphics->FillPath(linGrBrush,path);
graphics->FillPath(linGrBrushW,path);

sizeWindow.cx = 755;
sizeWindow.cy = 350;
ptSrc.x = 0;
ptSrc.y = 0;
UpdateLayeredWindow(this->Handle,hdcScreen,&ptWinPos,&sizeWindow,m_hdcMemory,
&ptSrc,0,&blend,ULW_ALPHA);
ReleaseDC(this->Handle,hdcScreen);
ReleaseDC(this->Handle,hdcTemp);
DeleteObject(hBitMap);
DeleteDC(m_hdcMemory);
return true;
}
//---------------------------------------------------------------------------

bool __fastcall TForm1::UpdateDisplay(WideString pszbuf,bool bBack,int Transparent)
{
HDC hdcTemp,hdcScreen,m_hdcMemory;
HBITMAP hBitMap;
BLENDFUNCTION blend;
TRect rct;
TPoint ptWinPos,ptSrc;
SIZE sizeWindow;

hdcTemp = GetDC(Handle);
m_hdcMemory = CreateCompatibleDC(hdcTemp);
hBitMap = CreateCompatibleBitmap(hdcTemp,755,350);
SelectObject(m_hdcMemory,hBitMap);
if ((Transparent < 0) ||(Transparent > 100))
Transparent = 100;
blend.BlendOp = AC_SRC_OVER;
blend.BlendFlags = 0;
blend.AlphaFormat = AC_SRC_ALPHA;
blend.SourceConstantAlpha = ceil(Transparent * 2.55);

hdcScreen = GetDC(Handle);
GetWindowRect(Handle,&rct);

ptWinPos.x = rct.Left;
ptWinPos.y = rct.Top;

Gdiplus::Graphics graphics(m_hdcMemory);

graphics.SetSmoothingMode(SmoothingModeAntiAlias); //指定平滑(抗锯齿)
graphics.SetInterpolationMode(InterpolationModeHighQualityBicubic);//指定的高品质,双三次插值

Gdiplus::FontFamily fontFamily(WideString("宋体")); //△字体,效果图为'微软雅黑'字体

Gdiplus::StringFormat strFormat;
Gdiplus::GraphicsPath path;
path.AddString(pszbuf, -1, &fontFamily, 0,38,PointF(10,10),&strFormat);

Gdiplus::Pen pen(Gdiplus::Color(155, 215, 215,215),3);

graphics.DrawPath(&pen,&path);

Gdiplus::LinearGradientBrush linGrBrush(Gdiplus::Point(0,0),Gdiplus::Point(0,90)
,Gdiplus::Color(255,255,255,255),Gdiplus::Color(255,30,120,195)); //线性渐变起始色

Gdiplus::LinearGradientBrush linGrBrushW(Gdiplus::Point(0,10),Gdiplus::Point(0,60)
,Gdiplus::Color(255,255,255,255),Gdiplus::Color(15,1,1,1));

//---------------------开始:画字符串阴影--------------------------------------
for(int i=0;i<8;i++)
{
pen.SetWidth(i+1);
pen.SetColor(Gdiplus::Color(62, 0, 2,2));
pen.SetLineJoin(LineJoinRound);
graphics.DrawPath(&pen,&path);
}
//---------------------开始:画背景框和背景图----------------------------------
if(bBack)
{
Gdiplus::SolidBrush brush(Gdiplus::Color(25,228,228,228));
Gdiplus::Pen pen1(Gdiplus::Color(155, 223, 223,223),3);
Gdiplus::Pen pen2(Gdiplus::Color(55, 223, 223,223),3);
Image *image;
image = Gdiplus::Image::FromFile(L"back.png");

graphics.FillRectangle(&brush,3,5,750,90);
graphics.DrawRectangle(&pen1,2,6,751,91);
graphics.DrawRectangle(&pen2,1,5,753,93);
graphics.DrawImage(image,600,25);
}
graphics.FillPath(&linGrBrush,&path);
graphics.FillPath(&linGrBrushW,&path);

sizeWindow.cx = 755;
sizeWindow.cy = 350;
ptSrc.x = 0;
ptSrc.y = 0;
UpdateLayeredWindow(Handle,hdcScreen,&ptWinPos,&sizeWindow,m_hdcMemory,
&ptSrc,0,&blend,ULW_ALPHA);

ReleaseDC(0,hdcScreen);
ReleaseDC(0,hdcTemp);
DeleteObject(hBitMap);
DeleteDC(m_hdcMemory);

return true;
}
//---------------------------------------------------------------------------

...全文
4305 59 打赏 收藏 转发到动态 举报
写回复
用AI写文章
59 条回复
切换为时间正序
请发表友善的回复…
发表回复
mmfeng 2011-06-06
  • 打赏
  • 举报
回复
先研究一下。
shimayao 2011-06-05
  • 打赏
  • 举报
回复
太专业 不懂 楼主上面的程序怎么用 用什么软件执行
cxwwll 2011-06-04
  • 打赏
  • 举报
回复
很多嘛,学起来很麻烦
wohen505 2011-06-04
  • 打赏
  • 举报
回复
传两个效果图吧,看的頭大了
xxiju203 2011-06-03
  • 打赏
  • 举报
回复
这个歌词在XP下叠加在视频播放窗口上效果似乎不是很好,有无解决办法呢?
天鹅梦 2011-06-03
  • 打赏
  • 举报
回复
马克一下,很不错
周药师 2011-06-03
  • 打赏
  • 举报
回复
支持一下!
CppFile 2011-06-03
  • 打赏
  • 举报
回复
很不错的效果,赞一个
jaffy 2011-06-03
  • 打赏
  • 举报
回复
[Quote=引用 48 楼 maozefa 的回复:]
顶一个!
[/Quote]
您来了,请上座啊!
shagege0 2011-06-03
  • 打赏
  • 举报
回复
看的頭大了
dfdscx 2011-06-03
  • 打赏
  • 举报
回复
不错,感谢分享
dlmult 2011-06-03
  • 打赏
  • 举报
回复
学习 一下,支持。
lonely 2011-06-03
  • 打赏
  • 举报
回复
嘿嘿 挺不错 哦
tj_swjtu 2011-06-02
  • 打赏
  • 举报
回复
收藏!!!
ncuyzq236 2011-06-02
  • 打赏
  • 举报
回复
学习了
阿发伯 2011-06-02
  • 打赏
  • 举报
回复
顶一个!
yinhongkai2008 2011-06-02
  • 打赏
  • 举报
回复
good
ai5699 2011-06-02
  • 打赏
  • 举报
回复
这个不错,哈哈!!!
Jonix 2011-06-02
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 xiaopo_poxiao 的回复:]
妖哥是何方神兽?
[/Quote]

太原一只修炼成神兽的妖精,不知道有多少年道行...
D19690207 2011-06-02
  • 打赏
  • 举报
回复
学习了。
加载更多回复(39)
2008-12-04 22:13 3,118 Builder中使用Access数据库.txt 2009-01-09 23:36 131,577 builder组件继承关系.pdf 2009-07-31 02:52 5,311 Builder聊天.txt 2009-07-31 02:49 1,863 BUilder高效率代码.txt 2009-07-31 02:36 11,941 C++ Builder VCL库函数简介.txt 2008-12-28 21:37 879 DistanceInEarth.txt 2008-12-28 20:13 1,823 earth.txt 2009-07-31 14:47 94 Edit格式化输入.txt 2009-06-29 13:05 774 Font.txt 2009-07-29 12:37 774 FontStyle.txt 2009-06-28 10:21 96 Google代理.txt 2009-09-05 14:39 135 Release_脱离变异环境运行程序.txt 2009-01-09 19:52 1,076 下载google卫片链接.txt 2009-07-31 00:12 4,761 不规则窗体.txt 2009-01-09 22:45 4,689 中英文输入法的自动切换.txt 2009-07-07 23:15 97 代理.txt 2008-12-12 00:54 1,402 任意角度图片旋转.txt 2009-06-24 23:42 1,596 使用GDI+绘制旋转的图形及图片.txt 2009-07-02 09:22 5,000 创建快捷方式Builder.txt 2009-07-02 01:37 9,018 双击打开文件.txt 2009-07-31 10:51 352 图像中心扩散.txt 2008-12-06 12:25 126 图像抖动如何解决.txt 2009-01-09 22:34 938 在桌面上画图.txt 2009-06-29 01:05 1,158 多语言支持——修改caption.txt 2008-12-04 13:35 192 实现全屏.txt 2008-12-07 21:31 1,615 怎样旋转一个TBitmap图片.txt 2009-07-30 23:27 55 改扩展名.txt 2009-07-30 23:34 2,230 文件夹遍历.txt 2008-12-08 23:50 9,043 文件的存取.txt 2009-09-11 01:09 37 新建 文本文档.bat 2009-07-31 01:27 2,362 模拟键盘输入.txt 2008-12-04 22:56 2,455 用C连接数据库.txt 2009-01-09 23:43 16 程序暂停.txt 2009-01-09 19:42 157 调用IE打开网站.txt 2009-01-06 11:31 762,901 麦卡托投影法 .mht

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧