当前位置:主页>仓库管理软件> 列表

今天面试后,备受打击

财务软件版1楼: 创建一个控件
LABEL +IMAGE
就是把两个控件合并成一个控件 还可以修改LABEL的CAPTION属性 及IMAGE的属性

谁知道如何解决

[:(][:(][:(][:(]

2楼: 继承就OK了 如设备管理软件

3楼: 正在试试。

4楼: 继承panel,把label,image放在上面
or 从Twincontrol继承

5楼: 我认为从TGraphicControl 继承是最好的。

6楼: type
TXLabImage = class(TGraphicControl)
private
FLabel: TLabel;
FImage: TImage;
procedure SetImage(const Value: TImage);
procedure SetLabel(const Value: TLabel);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property XLabel: TLabel read FLabel write SetLabel;
property XImage: TImage read FImage write SetImage;
end;

财务软件版7楼: 继承panel,把label,image放在上面
or 从Twincontrol继承

还要label,image SetSubComponent(true)

8楼: 放在一个FRAME上面

9楼: 放在一个Frameh上应该可以的

10楼: 创建一个控件 , 不Frame, 面试要小心,不能答非所问, 还是从Tpanel继承简单

11楼: 这个叫聚合控件开发,开发这类控件,主要是选取主控件,把次要的控件当作它的子件来解决。像这个LABEL +IMAGE的控件,你可以选IMAGE作为主控件,即继承TIMAGE类,再在类里申明一个TLABEL变量和一个CAPTION属性,至于它们的显示位置,你可以在IMAGE.OnPaint里面写代码,把TLabel和IMAGE的关系统处理好。做这个控件不是很复杂,多试试相信你能做好的。

12楼: TWinControl继承是最好的 如服装进销存软件破解

13楼: 继承 Timage
声明个 Label:Tlabel;
重载下 Create
在 Create 时候创建 Label

财务软件版14楼: 从Tgraphic继承 就无法给句柄。 比如说一起拖动就不行。 所以最好是从twincontrol继承。当然, 继承panel是个捷径。

15楼: TO jfyes,  这样建立控件后 在应用程序里里添加控件 LABEL和 IMAGE之间的位置如何

16楼: 从panel中创建比较好。在创建时设好位置,重载panel的caption,当改变其caption时改变lable的caption,再新加几个属性,当这些属性改变时相应改变image的属性,那就得了

17楼: 谁有代码?详细的

18楼: unit XControl;

interface

uses
Windows, Messages, SysUtils, Classes, Controls, StdCtrls, Mask, DB, DBCtrls, VDBConsts,
Forms, Dialogs, Buttons, ComCtrls, Graphics, ExtCtrls, Grids, DBGrids, ADODB, CheckLst,
Menus, Inifiles, ActiveX, ComObj, DBTables, DBClient, SqlExpr, Jpeg, CommCtrl,
Variants, TypInfo, ShellAPI, ZLib;

type
TXLabImage = class(TPanel)
private
FLabel: TLabel;
FImage: TImage;
procedure SetLabel(const Value: TLabel);
procedure SetImagel(const Value: TImage);


public
constructor Create(AOwner:TComponent); override;
destructor Destroy; override;
published
property XLabel: TLabel read FLabel write SetLabel;
property XImage: TImage read FImage write SetImagel;
end;
procedure Register;

implementation

procedure Register;
begin
RegisterComponents(''Jfyes Express'', [TXLabImage]);
end;

{ TXLabImage }

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

FImage := TImage.Create(Self);
FImage.Parent := Self;
FImage.Name := ''SubImage'';
FImage.SetSubComponent(True);

FLabel := TLabel.Create(Self);
FLabel.Name := ''SubLabel'';
FLabel.SetSubComponent(True);
FLabel.Parent := Self;
FLabel.FocusControl := Self;
end;

destructor TXLabImage.Destroy;
begin
FLabel.Free;
FImage.Free;
inherited Destroy;
end;

procedure TXLabImage.SetImagel(const Value: TImage);
begin


FImage := Value;
end;

procedure TXLabImage.SetLabel(const Value: TLabel);
begin
FLabel := Value;
end;

19楼: SetSubComponent(True); 很重要,不然是保存不SubComponent的数据
property XLabel: TLabel read FLabel write SetLabel; // delete write SetLabel
property XImage: TImage read FImage write SetImagel;// delete write SetImagel

20楼: 呵呵,授人以鱼不如授人以渔,楼主看看 TLabeledEdit 的实现代码不就知道了,它就是组合了 Edit 和 Label,并且也可以调整 Lable 的位置,就在 ExtCtrls.pas 单元中。

财务软件版21楼: 好的 多谢了 看来DELPHI学的并不好呀
还好同方收留了我
学VC了

22楼: 靠,我好久没有上过这里了,怎么看帖子都没有啊,只是时间。 如免费超市管理软件

23楼: 楼主,你学什么也没有,delphi你知道多少,你干脆该行算了.

24楼: TLabeledEdit最适合你,聚合控件!

25楼: to jfyes
FImage.Parent := Self; 出现错误:
[Error] XLabImage.pas(43): Incompatible types: ''TWinControl'' and ''TXLabImage''
能解释一下吗> 谢谢

26楼: yuanxianer ,你到家?那么快呀?路上还好吧?
TXLabImage 是继承TPanel,怎么会不是TWinControl呢?你看到了上次在我的那测试能行,
你可掉了些代码吧?

27楼: 关键就是一句话,SetSubComponent

财务软件版28楼: http://www.delphibbs.com/delphibbs/dispq.asp?lid=3230608

29楼: 好啊,看看

30楼: 现在 改用VC
今天经理出了一道题总算让我用VC实现了
兴奋 哈哈 ~~~~`

31楼: 狗日的,党组织关系可能要丢了
今天打电话过去问,组织关系还在学校