Einzelnen Beitrag anzeigen

Benutzerbild von Stevie
Stevie

Registriert seit: 12. Aug 2003
Ort: Soest
4.016 Beiträge
 
Delphi 10.1 Berlin Enterprise
 
#5

AW: DSharp, DevExpress Editors, Bindings

  Alt 10. Sep 2019, 12:18
Delphi-Quellcode:
type
  TcxTextEdit = class(cxTextEdit.TcxTextEdit, INotifyPropertyChanged)
  private
    FNotifyPropertyChanged: TNotifyPropertyChanged;
    property NotifyPropertyChanged: TNotifyPropertyChanged
      read FNotifyPropertyChanged implements INotifyPropertyChanged;
    procedure WMChar(var Message: TWMChar); message WM_CHAR;
  protected
    procedure DoTextChanged; override;
    procedure CMExit(var Message: TCMExit); message CM_EXIT;
  public
    constructor Create(AOwner: TComponent); override;
  end;

procedure TcxTextEdit.CMExit(var Message: TCMExit);
begin
  try
    FNotifyPropertyChanged.NotifyOfPropertyChange('Text', utLostFocus);
    inherited;
  except
    on EValidationError do
    begin
      SetFocus;
    end;
  end;
end;

constructor TcxTextEdit.Create(AOwner: TComponent);
begin
  inherited;
  FNotifyPropertyChanged := TNotifyPropertyChanged.Create(Self);
end;

procedure TcxTextEdit.DoTextChanged;
begin
  inherited;
  FNotifyPropertyChanged.NotifyOfPropertyChange('Text');
end;

procedure TcxTextEdit.WMChar(var Message: TWMChar);
begin
  inherited;
  if Message.CharCode = VK_RETURN then
  begin
    FNotifyPropertyChanged.NotifyOfPropertyChange('Text', utExplicit);
  end;
end;
Stefan
“Simplicity, carried to the extreme, becomes elegance.” Jon Franklin

Delphi Sorcery - DSharp - Spring4D - TestInsight
  Mit Zitat antworten Zitat