谁有从twincontrol继承的可以在上面画图的控件啊,比如image,panel这样的,??(50分)

  • 主题发起人 terminal_guo
  • 开始时间
T

terminal_guo

Unregistered / Unconfirmed
GUEST, unregistred user!
我想在一个控件上面勇canvas画图,本来勇的是timage,可是他是从tcontrol继承的,
我找了个drage控件,可以从别的程序拖放到image上面来,但是只有从twincontrol继承
的控件才可以接受的到,所以想找一个这样的
 
你可以继承Tpanel
在里面放一个Timage
type
newclass = class(Tpanel)
mainimage : Timage;
....
end;
在构造函数里面创建Timage,然后设置mainimage.parent := self;
一切OK!!
 
eric.youbin: 你比较完整的源代码码,能发给我看看码,谢谢了!!
那样他就能接受到拖放相应了吗,
 
unit MNewPanel;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;

type
NewPanel= class(Tpanel)
MainImg : Timage;
private
{ Private declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;


implementation


{ newclass }

constructor NewPanel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);

MainImg := TImage.Create(nil);
MainImg.Parent := Self;
MainImg.Width := Self.Width;
MainImg.Height := Self.Height;
end;

destructor NewPanel.Destroy;
begin

MainImg.Destroy;
inherited Destroy();;
end;

end.

我把以上的控件安装上去了,编译没有错误,可是在程序里运行的时候就报错了,错误:
Class TImage not found!!
能帮我看看马,谢谢了,

 
MainImg := TImage.Create(nil);
改成
MainImg := TImage.Create(self);
 
我怎样让MainImg随panel大小的改变而改变阿
 
我靠,就是
mainimage.align := alclient;
你在创建的时候设定它
 
好了,谢谢你了,真实不好意思,
 
我用这个控件画图的时候,,用TIMER2秒钟一次,先将图画到BITMAP上面,然后用NewPanel.
MainImg.Canvas.Draw(0,0,bitmap);
老是有闪烁的感觉,好象PANEL在不断的刷新,
我原来只用TIMAGE用这种方式就没有闪烁的感觉,不知道怎么解决,麻烦帮我分析一下,
谢谢了,,,,,
 
解决了,
 
顶部