Jump to content

[Solved] Example of TUniEdit descendent with OnChange Overridden


Rebelss

Recommended Posts

No one ?

we normally do something like this :

unit MyEdit;

interface

uses
  Vcl.StdCtrls, vcl.Dialogs;

Type
  TMyEdit = class(TEdit)
  public
    procedure Change; override;
  end;

procedure Register;

implementation

uses
  System.Classes;

procedure Register;
begin
  RegisterComponents('MySuite', [TMyEdit]);
end;


{ TMyEdit }

procedure TMyEdit.Change;
begin
  inherited;
  showmessage('MyOnChange');
end;

end.

But in Unigui the procedure "Change" doesn't exists on TUniEdit. 
 

Here is my code : 

unit MyUniEdit;

interface

uses
  Classes, uniGuiTypes, uniGUIClasses, uniGUIForm, UniEdit;

type
  TMyUniEdit = class(TUniEdit)
  public
    procedure Change; override;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('MyUnigui', [TMyUniEdit]);
end;

{ TMyUniEdit }

procedure TMyUniEdit.Change;
begin
  inherited;
  if (Assigned(OnChange)) then
    showmessage('MyOnChange');
end;

end.

but the compiler message is : [dcc32 Error] MyUniEdit.pas(11): E2137 Method 'Change' not found in base class

Link to comment
Share on other sites

Hello guys, i figure out. I just have to override the DoOnChange event.

 

unit MyUniEdit;

interface

uses
  Classes, uniGuiTypes, uniGUIClasses, UniGuiDialogs, UniEdit;

type
  TMyUniEdit = class(TUniEdit)
  public
    procedure DoOnChange; override;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('MyUnigui', [TMyUniEdit]);
end;

{ TMyUniEdit }

procedure TMyUniEdit.DoOnChange;
begin
  inherited DoOnChange;
  // code something
end;

end.

 

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...