我有一个程序delphi5 在windows98下编译后运行正常

ljklxlj 2012-03-08 02:16:09
我有一个程序delphi5 在win98下编译后运行正常 ,同样用delphi5,在xp下编译后,正常通过编译,没有任务错误提示,但运行后确不正常了,本来能连续播放的图片,不能正常播放了。图片是在canvas上画的,代码如下:
procedure TLedTextObject.Draw(canvas: tcanvas);
var
tempcolor:tcolor;
x,y,i:integer;
size: tsize;
begin
inherited;
if not visible then exit;
canvas.pen.color:=color;
canvas.brush.style:=bsclear;
canvas.font:=font;
canvas.TextRect(Rect(locate.x,locate.y,locate.x+width,locate.y+height),locate.x,locate.y,caption);
size:=canvas.TextExtent('测试');
y:=0;
for i:=0 to strs.count-1 do
begin
y:=locate.y+i*(size.cy+linedistance);
canvas.TextRect(Rect(locate.x,y,locate.x+width,locate.y+height),locate.x,y,strs[i]);
end;
drawselected(canvas);

end;



procedure TLedTextObject.GetBmp(srcbmp,bmp:tbitmap;canvas:tcanvas);
var
tempcolor:tcolor;
x,y,i:integer;
size: tsize;
begin
bmp.canvas.font:=font;
bmp.canvas.brush.color:=bakcolor;
bmp.canvas.brush.style:=bsclear;
bmp.Canvas.copyrect(rect(0,0,width,height),srcbmp.canvas,rect(locate.x,locate.y,locate.x+width,locate.y+height));
size:=bmp.canvas.TextExtent('测试');
y:=0;
for i:=0 to strs.count-1 do
begin
y:=i*(size.cy+linedistance);
bmp.canvas.TextRect(Rect(0,y,width,height),0,y,strs[i]);
end;
end;

procedure TLedTextObject.drawself(templocate: tpoint; bmp: tbitmap;
canvas: tcanvas);
var
y,i:integer;
size:tsize;
begin
inherited;
bmp.canvas.font:=font;
bmp.canvas.pen.color:=color;
bmp.canvas.brush.style:=bsclear;
// bmp.Canvas.pen.Mode:=pmXor;
size:=bmp.canvas.TextExtent('测试');
y:=0;
for i:=0 to strs.count-1 do
begin
y:=templocate.y+i*(size.cy+linedistance);
bmp.canvas.TextRect(Rect(templocate.x,y,templocate.x+width,templocate.y+height),templocate.x,y,strs[i]);
end;
canvas.lock;
canvas.draw(0,0,bmp);
canvas.Unlock;
end;

这个是用线程开启的,我觉得和线程关系也不大,线程也贴上:
procedure TDisThread.Execute;
begin
freeonterminate:=true;
repeat
frmmain.Timer_screen.enabled:=true;
if frmmaincode.screens.Count>=screencode then
begin
try
frmmaincode.screens.Item[screencode].playscreen;
sleep(50);
except
end;
end;
until terminated;
end;

...全文
102 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ljklxlj 2012-06-30
  • 打赏
  • 举报
回复
都出手啊
金卯刀 2012-03-13
  • 打赏
  • 举报
回复
线程中的代码frmmain,以及playScreen,都是主线程的东西。存在线程安全问题。

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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