picyka Posted April 15, 2012 Share Posted April 15, 2012 How do I override methods type TUniEditText = class(TUniEdit) private { Private declarations } protected { Protected declarations } procedure DoEnter; override; procedure DoExit; override; public Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted April 15, 2012 Administrators Share Posted April 15, 2012 You already answered your question. 1 Quote Link to comment Share on other sites More sharing options...
picyka Posted April 15, 2012 Author Share Posted April 15, 2012 yes, but my schedule did not work on the web, what do this wrong, is attached. unit UniEditText; interface uses System.SysUtils, System.Classes, Vcl.Controls, uniGUIBaseClasses, uniGUIClasses, uniEdit, uniLabel, Vcl.Graphics, Data.Bind.Components, Dialogs; type TUniEditText = class(TUniEdit) private FNewValue: String; FOldValue: String; FBindObject: TBindingsList; procedure SetBindObject(const Value: TBindingsList); { Private declarations } protected { Protected declarations } procedure DoEnter; override; procedure DoExit; override; public { Public declarations } constructor Create(AOwner: TComponent); override; destructor Destroy; override; published { Published declarations } property OldValue : String read FOldValue write FOldValue; property NewValue : String read FNewValue write FNewValue; property BindObject : TBindingsList read FBindObject write SetBindObject; end; procedure Register; implementation procedure Register; begin RegisterComponents('LS Unigui Componentes', [TUniEditText]); end; { TUniEditText } constructor TUniEditText.Create(AOwner: TComponent); begin inherited Create(AOwner); end; destructor TUniEditText.Destroy; begin inherited Destroy; end; procedure TUniEditText.DoEnter; begin Self.FOldValue := Self.Text; Self.Color := $00C4FFFF; inherited DoEnter; end; procedure TUniEditText.DoExit; begin if Trim(Self.FNewValue) <> Trim(Self.Text) then begin if Self.FBindObject <> nil then Self.FBindObject.Notify(Self,'Text'); Self.FNewValue := Self.Text; end; Self.Color := clWindow; inherited DoExit; end; procedure TUniEditText.SetBindObject(const Value: TBindingsList); begin FBindObject := Value; end; end. Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted April 16, 2012 Administrators Share Posted April 16, 2012 In uniGUI method names are: procedure DoOnEnter; virtual; procedure DoOnExit; virtual; Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted April 16, 2012 Administrators Share Posted April 16, 2012 Another thing: In web mode DoOnEnter and DoOnExit aren't called unless user event handlers are assigned. Solution: constructor TUniEditText.Create(AOwner: TComponent); begin inherited Create(AOwner); PersistentEvents := PersistentEvents + [evEnter, evExit]; end; 1 Quote Link to comment Share on other sites More sharing options...
picyka Posted April 17, 2012 Author Share Posted April 17, 2012 it worked, the veses it loses focus, I'm doing another component that could help it follows: unit UniEditFind; interface uses System.SysUtils, System.Classes, Vcl.Controls, uniGUIBaseClasses, uniGUIClasses, uniEditText, Winapi.Windows, uniSpeedButton, Vcl.Graphics, Messages; type TUniEditFind = class(TUniEditText) private { Private declarations } FOnBtnClick : TNotifyEvent; FButton: TUniSpeedButton; function GetGlyph : TBitmap; procedure SetGlyph(Pic: TBitmap); procedure CMVisiblechanged(var Message: TMessage); message CM_VISIBLECHANGED; procedure CMEnabledchanged(var Message: TMessage); message CM_ENABLEDCHANGED; procedure WMSize(var Message: TWMSize); message WM_SIZE; procedure SetEditRect; protected { Protected declarations } procedure aClick (Sender: TObject); virtual; public { Public declarations } constructor Create(AOwner: TComponent); override; destructor Destroy; override; property Button: TUniSpeedButton read FButton; property Glyph : TBitmap read GetGlyph write SetGlyph; property OnBtnClick : TNotifyEvent read FOnBtnClick write FOnBtnClick; published { Published declarations } end; procedure Register; implementation procedure Register; begin RegisterComponents('LS Unigui Componentes', [TUniEditFind]); end; { TUniEditFind } procedure TUniEditFind.aClick(Sender: TObject); begin if not ReadOnly then begin iF Assigned(FOnBtnClick) then begin SetFocus; FOnBtnClick(Self); end; end; end; procedure TUniEditFind.CMEnabledchanged(var Message: TMessage); begin if Assigned(Self.FButton) then Self.FButton.Enabled := Enabled; end; procedure TUniEditFind.CMVisiblechanged(var Message: TMessage); begin if Assigned(Self.FButton) then Self.FButton.Visible := Visible; end; constructor TUniEditFind.Create(AOwner: TComponent); begin inherited Create(AOwner); FButton := TUniSpeedButton.Create(Self); FButton.Width := 15; FButton.Height := 17; FButton.Parent := Self; FButton.Cursor:=crHandPoint; FButton.ShowHint := True; FButton.Hint := 'Consultar <F4>'; Self.Alignment := taCenter; end; destructor TUniEditFind.Destroy; begin FButton := nil; inherited; end; function TUniEditFind.GetGlyph: TBitmap; begin Result := FButton.Glyph; end; procedure TUniEditFind.SetEditRect; var Loc: TRect; begin SendMessage(Handle, EM_GETRECT, 0, LongInt(@Loc)); Loc.Bottom := ClientHeight + 1; Loc.Right := ClientWidth - FButton.Width - 2; Loc.Top := 0; Loc.Left := 0; SendMessage(Handle, EM_SETRECTNP, 0, LongInt(@Loc)); SendMessage(Handle, EM_GETRECT, 0, LongInt(@Loc)); end; procedure TUniEditFind.SetGlyph(Pic: TBitmap); begin FButton.Glyph.Assign(Pic); end; procedure TUniEditFind.WMSize(var Message: TWMSize); var MinHeight: Integer; begin inherited; MinHeight := 5; if Height < MinHeight then Height := MinHeight else if FButton <> nil then begin FButton.Width := Height; if NewStyleControls and Ctl3D then FButton.SetBounds(Width - FButton.Width - 4, 0, FButton.Width, Height - 4) else FButton.SetBounds (Width - FButton.Width, 1, FButton.Width, Height - 1); SetEditRect; end; end; end. grateful 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.