着急:用bitbmp画出一个区域,读进文字,怎么样可以使这个区域是透明的啊?? Image1.Canvas.Brush.Style := bsclear;//背景色为空我用上面的方法不行,改成从TPaintBox继承也不行。请问应该怎么做啊?? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个是我的代码 TextBitmap := TBitmap.Create; ...... TextBitmap.Canvas.Brush.Style := bsclear; TextBitmap.Canvas.FillRect(Rect(0,0,TextBitmap.width,TextBitmap.height)); 用这种方法作出来的背景是白色的!!汗 我想把这个TextBitmap 放在一个动画控件上面。使TextBitmap 上面的文字能叠加在动画上面,怎么做到啊 ??SOS!!! 活活 楼上的 是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; 方法1:TextBitmap从TImage继承,把属性Transparent设为True;方法2:既然你了解了此控件把文本分段的原理,可以不用此控件,自己写代码。直接把文字写到动画控件上。方法:dc : HDC;dc := GetDC( 动画控件.Handle );SetBKMode(dc,TRANSPARENT);TextOut(dc,.....);ReleaseDC(动画控件.Handle, dc); 把属性Transparent设为True之后 好像还是没有效果啊 關於 SQL 日期時間轉換問題 如何判断服务器是否连接正常? DLLEntryPoint 方法在哪个单无,怎样用? 一个关于远程数据模块的问题!+一个全局变量的问题! 地址 小弟接了一个图书管理系统?大家来讨论讨论! 使用动态数组的几个问题 listview拖动标题列后如何保存 TStringGrid问题:假设一共7行,其中2、3、4、5行只能有。。。。 还是关于importedconstraint的疑问,诸位大虾请进! 字段添加? 交叉表,各位高手请进来!
......
TextBitmap.Canvas.Brush.Style := bsclear;
TextBitmap.Canvas.FillRect(Rect(0,0,TextBitmap.width,TextBitmap.height));
汗 我想把这个TextBitmap 放在一个动画控件上面。
使TextBitmap 上面的文字能叠加在动画上面,
怎么做到啊 ??SOS!!!
我用一个专门读入文字的第三方控件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;
方法2:既然你了解了此控件把文本分段的原理,可以不用此控件,自己写代码。直接把文字写到动画控件上。
方法:dc : HDC;dc := GetDC( 动画控件.Handle );
SetBKMode(dc,TRANSPARENT);
TextOut(dc,.....);
ReleaseDC(动画控件.Handle, dc);