I think ,you should move the visible code:
try this:
constructor TFLEdit.Create(AOwner: TComponent);
const
Gap = 5;
begin
inherited;
Width := 200;
Height := 25; FLabel := TLabel.Create(Self);
FLabel.AutoSize :=true;
FLabel.Parent := Self;
FLabel.Caption := 'Temp';
FLabel.Left := Gap;
FLabel.Top := Gap;
FLabel.Width := 55;
FLabel.Height := 15;
//FLabel.Visible := True;
FEdit := TFlatEdit.Create(Self);
FEdit.Parent :=Self;
FEdit.Left := FLabel.Left+FLabel.Width+3;
FEdit.Top := FLabel.Top-3;
FEdit.Width := Width - FEdit.Left - Gap;
//FEdit.Visible := True;
end;
try this:
constructor TFLEdit.Create(AOwner: TComponent);
const
Gap = 5;
begin
inherited;
Width := 200;
Height := 25; FLabel := TLabel.Create(Self);
FLabel.AutoSize :=true;
FLabel.Parent := Self;
FLabel.Caption := 'Temp';
FLabel.Left := Gap;
FLabel.Top := Gap;
FLabel.Width := 55;
FLabel.Height := 15;
//FLabel.Visible := True;
FEdit := TFlatEdit.Create(Self);
FEdit.Parent :=Self;
FEdit.Left := FLabel.Left+FLabel.Width+3;
FEdit.Top := FLabel.Top-3;
FEdit.Width := Width - FEdit.Left - Gap;
//FEdit.Visible := True;
end;
谢谢您,您还在吗?
FLabel.Name := 'MyLabel';
FEdit.Name := 'MyEdit';
这样出错时候就比较好诊断哪个控件有问题。
FEdit := TFlatEdit.Create(Self);(可能是没有父控件)
FEdit.Parent :=Self;
FEdit.Left := FLabel.Left+FLabel.Width+3;
FEdit.Top := FLabel.Top-3;
FEdit.Width := Width - FEdit.Left - Gap;
//FEdit.Visible := True;
如果把TFLATEDIT换成TEDIT就可以了不知为什么?
试一试!
我已经在create里改成了 inherited Create(AOwner);
还是不行?
FEdit := TFlatEdit.Create(Self); FLabel := TLabel.Create(Self);
FLabel.AutoSize :=true;
FLabel.Parent := Self;
FEdit.Parent :=Self;
FEdit.Left := FLabel.Left+FLabel.Width+3;
FEdit.Top := FLabel.Top-3;
FEdit.Width := Width - FEdit.Left - Gap;
你在这个控件的create过程里设定flabel及fedit的parent是什么意思???
procedure CreateWND(); override;
begin
FLabel := TLabel.Create(Self);
FLabel.AutoSize :=true;
FLabel.Parent := Self;
FLabel.Caption := 'Temp';
FLabel.Left := Gap;
FLabel.Top := Gap;
FLabel.Width := 55;
FLabel.Height := 15;
FLabel.Visible := True;
FEdit := TFlatEdit.Create(Self);
FEdit.Parent :=Self;
FEdit.Left := FLabel.Left+FLabel.Width+3;
FEdit.Top := FLabel.Top-3;
FEdit.Width := Width - FEdit.Left - Gap;
FEdit.Visible := True;end;在create中只要现在的前三句。
我现在不方便打开delphi。所以看不出来效果。如果正确请给我发一个mail:
[email protected]