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