Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.184 Beiträge
Delphi 12 Athens
|
Re: OnChange-Verarbeitung bei eigenem Edit-Objekt
20. Apr 2010, 22:47
Wie gesagt, TInputBlock ist ja nun selber das Panel, also wenn man es richtig initialisiert.
Delphi-Quellcode:
type TInputBlock = class(TPanel)
private
FEdit: TEdit;
FOnChange: TNotifyEvent;
...
protected
procedure Change(Sender: TObject);
...
public
constructor Create(Owner: TWinControl; InputData: TInputData; InputDDName: TInputDDNames; col: integer);
property OnChange: TNotifyEvent read FOnChange write FOnChange;
...
end;
...
constructor TInputBlock.Create(OwnerAndParent: TWinControl; InputData: TInputData; InputDDName: TInputDDNames; col: integer);
begin
inherited create(OwnerAndParent);
Parent := OwnerAndParent;
SetBounds(0,(col-1)*25,250,25);
...
FEdit:=TEdit.Create(Self);
FEdit.Parent:=Self;
FEdit.SetBounds(120,2,60,20);
FEdit.Text := dd2s(FInputData[FInputDDName],-1);
FEdit.OnChange := Change;
...
end;
...
procedure TInputBlock.Change;
var dd: Double;
begin
if s2dd(FEdit.Text,dd) then
begin
// erfolgreiche Umwandlung in Double => Wert speichern
FInputData[FInputDDName] := dd;
FEdit.Color:= clYellow;
...
end else begin
FEdit.Color:= clRed;
...
end;
if Assigned(FOnChange) then FOnChange(Self);
inherited;
end;
...
procedure TFormSingle.FormCreate(Sender: TObject);
begin
...
inpX := TInputBlock.Create(scrInput, myData,iTS, col);
inpX.OnChange := InputChanged;
...
end;
procedure TFormSingle.InputChanged(Sender: TObject);
begin
...
Label1.Caption := 'Test';
...
end;
$2B or not $2B
|
|
Zitat
|