以下是源码,注释掉的那一行就是导致出错的根源,去掉它就ok,否则虽可编译通过,但在往form上放时就会报上面的错。不知真正的原因在哪?
谢谢指教!unit M_QJ;
interface
uses
SysUtils, Classes, Controls, StdCtrls, Messages,DBCtrlsEh,ExtCtrls,
Dialogs,Graphics,DateUtils;type
TM_QJ = class(TWinControl) private
FQJ :TComboBox;
public
constructor Create(AOwner:TComponent);override;
destructor destroy;override;
{ Public declarations }
published
property QJ:TCombobox read FQJ write FQJ;
{ Published declarations }
end;procedure Register;implementation
//------------
procedure Register;
begin
RegisterComponents('MyCls', [TM_QJ]);
end;//------------
constructor TM_QJ.Create(AOwner:TComponent);
var
i:Integer;
begin
inherited;
FQJ:=TCombobox.Create(self);
FQJ.parent:=self;
FQJ.Items.Add('200503'); //!!!导致出错的行!!!
end;//------------
destructor TM_QJ.destroy;
begin
FQJ.free;
inherited;
end;end.
谢谢指教!unit M_QJ;
interface
uses
SysUtils, Classes, Controls, StdCtrls, Messages,DBCtrlsEh,ExtCtrls,
Dialogs,Graphics,DateUtils;type
TM_QJ = class(TWinControl) private
FQJ :TComboBox;
public
constructor Create(AOwner:TComponent);override;
destructor destroy;override;
{ Public declarations }
published
property QJ:TCombobox read FQJ write FQJ;
{ Published declarations }
end;procedure Register;implementation
//------------
procedure Register;
begin
RegisterComponents('MyCls', [TM_QJ]);
end;//------------
constructor TM_QJ.Create(AOwner:TComponent);
var
i:Integer;
begin
inherited;
FQJ:=TCombobox.Create(self);
FQJ.parent:=self;
FQJ.Items.Add('200503'); //!!!导致出错的行!!!
end;//------------
destructor TM_QJ.destroy;
begin
FQJ.free;
inherited;
end;end.
解决方案 »
- delphi Oracle :delphi连接oracle,从数据字典中查询出数据,通过delphi编程显示输出
- 关于数据输入奇怪的问题,请高手帮一帮
- 不定时出现的错误信息是“无法为更新行集定位:一些值可能以在最后读取后改变”????
- 大哥大姐,小妹有一个问题请教,多谢,在线等!!!
- 过程的嵌套!求助!!
- 请问有谁用过DevExpress D7版的? 救急!!!
- 请问,那些工具栏上speedbutton上的小图标 ,都位于哪些文件夹下?
- 关于delphi.net
- 请问各位哪里能申请中文的免费网站空间,50分谢谢。
- 有点难度的sql语句,如何用一条sql语句删掉记录中某个字段的值中的空格。。。
- 如何把ListBox1里的每一行中的"yesterday"字符串改为"tommrow"字符串?
- 菜鸟求救:用delphi,Mapinfo开发Gis,如何设置环境
constructor TM_QJ.Create(AOwner:TComponent);
var
i:Integer;
begin
inherited;
FQJ:=TCombobox.Create(AOwner);
FQJ.parent:=AOwner;
FQJ.Items.Add('200503'); //!!!导致出错的行!!!
end;
谢谢您关注,我按您的思路,做了以下两种,都可编译通过,但放在form上后就是两块区域,互不相干一样.即使想把FQJ那个combobox移动到TWinControl上都不行,后者总在前面. 不知道可不可以不用TWinControl,直接由TComboBox继承面来. FQJ:=TCombobox.Create(self);
FQJ.parent:=TWinControl(AOwner);
------------------------------
FQJ:=TCombobox.Create(AOwner);
FQJ.parent:=TWinControl(AOwner);
真是奇怪啊! 那如果要封装基于TCombobox的组件是不是就没办法了呢?unit M_QJ;
interface
uses
SysUtils, Classes, Controls, StdCtrls, Messages,ExtCtrls,
Dialogs,Graphics,DateUtils;type
TM_QJ = class(TCombobox)
end;procedure Register;
implementation//------------
procedure Register;
begin
RegisterComponents('MyCls', [TM_QJ]);
end;end.
然后重载creat函数不行么 ?
interface
uses
SysUtils, Classes, QControls, QStdCtrls;type
TE_QJ = class(TComboBox)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
end;procedure Register;
implementationprocedure Register;
begin
RegisterComponents('MyCls', [TE_QJ]);
end;
end.
但是,无论如何都无法把它变成平面的,即使不封装组件,放一个普通的ComboBox在form上也变不过来,请大伙教我一下,谢谢! Parent.Ctl3D:=False;
Ctl3D:=False;
同时用上都无效的。
不可琢磨啊! 真是搞死人了.
但不明白的是,delphi在这里的Ctl3D又是干啥用的.总觉得delphi怪怪的.下面是调试成功的代码,简单地封装一下TcomboBox,再放一个它的实例到form上,运行form的效果就很奇怪,form上被挖去了一个洞,象碉堡的射击孔! 有举的朋友可以试试看,好奇怪哟!unit M_QJ;
interface
uses
SysUtils, Classes, Controls, StdCtrls, Messages,ExtCtrls,
Dialogs,Graphics,DateUtils,windows;type
TM_QJ = class(TCombobox)
constructor Create(AOwner:TComponent);override;
end;procedure Register;
implementation//--------------------
procedure Register;
begin
RegisterComponents('MyCls', [TM_QJ]);
end;//--------------------
constructor TM_QJ.Create(AOwner:TComponent);
begin
inherited;
end;
end.