着急:用bitbmp画出一个区域,读进文字,怎么样可以使这个区域是透明的啊??

shmilyjiujiu 2003-10-15 04:20:56
Image1.Canvas.Brush.Style := bsclear;//背景色为空

我用上面的方法不行,
改成从TPaintBox继承也不行。

请问应该怎么做啊??
...全文
76 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
shmilyjiujiu 2003-10-15
  • 打赏
  • 举报
回复
把属性Transparent设为True之后 好像还是没有效果啊
flyinwuhan 2003-10-15
  • 打赏
  • 举报
回复
方法1:TextBitmap从TImage继承,把属性Transparent设为True;
方法2:既然你了解了此控件把文本分段的原理,可以不用此控件,自己写代码。

直接把文字写到动画控件上。
方法:

dc : HDC;

dc := GetDC( 动画控件.Handle );
SetBKMode(dc,TRANSPARENT);
TextOut(dc,.....);
ReleaseDC(动画控件.Handle, dc);
shmilyjiujiu 2003-10-15
  • 打赏
  • 举报
回复
活活 楼上的 是SDK2000 是个第三方控件的说。
我用一个专门读入文字的第三方控件Text 在程序运行的时候读入文本文件,这个控件可以随意变化大小的,我希望能把这个控件的背景色变成透明。放在动画控件上的时候 不会遮住动画。
下面的是text控件初始化的源码
procedure TMText.AdjustSize;
var
CurrentLine : Integer;
PerDispLines :integer; //每片能显示的文本行数
allLines :integer; //文本总共行数
linebeginPos: integer; //显示某行文本在窗口的第几行位置
begin
PerDispLines:=0; //置初值
allLines:=0;

if TheHeight<=-Font.height + 4 then //当上下调整高度,如果高度小于字体高度时,就强制最小高度为字体高度;
begin
TheHeight:=-Font.height + 4; height:= -Font.height + 4;
end;
if TheWidth <=Font.Size then //当左右调整宽度,如果宽度小于字体大小时,就强制最小宽度为字体宽度;
begin
TheWidth:=Font.size; width:=Font.Size;
end;

TheText.Height := TheHeight;
TheText.Width := TheWidth;
if TextBitmap <> nil then
TextBitmap.Free;
TextBitmap := TPaintBox.Create(owner);
TextBitmap.Parent := playform;
TextBitmap.Canvas.Font := Font;
TextBitmap.Width := TheWidth;
if (-Font.height + 4) * (TheText.Lines.Count + 1)>32767 then
TextBitmap.height:=32760 //当宽度被压的很小的时候,一旦打开文件,文件的TheText.Lines.Count与
else //-Font.height + 4的乘积远大于height的integer性数值范围,为保护做强制处理;
TextBitmap.Height := (-Font.height + 4) * (TheText.Lines.Count + 1);

if DisplayMode = piece then // 分片显示
begin
PerDispLines:= theHeight div (-Font.height + 4);
//PerDispLines:= Height div (-Font.height + 4); //计算每片能显示的文本行数
Height := PerDispLines * (-Font.height + 4); //可能因为不能整除,调整显示控件的高度
if PerDispLines=0 then PerDispLines:=1;
DevidePageNum:=(TheText.Lines.Count+1) div PerDispLines; //计算分多少片显示

if (TheText.Lines.Count+1) mod PerDispLines <> 0 then //如100行,每片8行,除为12.5,为12,需要13片显示
Inc(DevidePageNum); //能整除则不需要处理;
end;

TextBitmap.Canvas.brush.Color := Color;
TextBitmap.Canvas.Brush.Style := bsclear;
TextBitmap.Canvas.FillRect(Rect(0,0,TextBitmap.width,TextBitmap.height));

if TheText.Lines.Count > 0 then
begin
if DisplayMode = piece then // 分片处理
begin
linebeginPos:=0; //从显示窗口的第0行开始显示
for CurrentLine:=(CurDevPageNum-1)*PerDispLines to CurDevPageNum*PerDispLines-1 do
begin
TextBitmap.Canvas.TextOut(0,linebeginPos*(-Font.height + 4),TheText.Lines[CurrentLine]);
linebeginPos:=linebeginPos+1;
end;
end
else
begin
for CurrentLine := 0 to TheText.Lines.Count - 1 do
begin
TextBitmap.Canvas.TextOut(0,CurrentLine*(-Font.height + 4),
TheText.Lines[CurrentLine]);
end;
end;
end
else //Add Text Element's Title by WY
begin
TextBitmap.width := 100;
TextBitmap.Canvas.Font.Name := '宋体';
TextBitmap.Canvas.Font.Size := 11;
TextBitmap.Canvas.Font.Color := clBlack;
TextBitmap.Canvas.brush.Color := clWhite;
TextBitmap.Canvas.TextOut(1,1,'文本(Text)');
end;
end;
flyinwuhan 2003-10-15
  • 打赏
  • 举报
回复
那个动画控件叫什么名字?
flyinwuhan 2003-10-15
  • 打赏
  • 举报
回复
不懂你 什么意思。详细点
shmilyjiujiu 2003-10-15
  • 打赏
  • 举报
回复
用这种方法作出来的背景是白色的!!
汗 我想把这个TextBitmap 放在一个动画控件上面。
使TextBitmap 上面的文字能叠加在动画上面,
怎么做到啊 ??

SOS!!!
shmilyjiujiu 2003-10-15
  • 打赏
  • 举报
回复
这个是我的代码

TextBitmap := TBitmap.Create;
......
TextBitmap.Canvas.Brush.Style := bsclear;
TextBitmap.Canvas.FillRect(Rect(0,0,TextBitmap.width,TextBitmap.height));

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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