I have a composite component that consists of a TEdit
and a TButton
(yes, I know about TButtonedEdit
) that inherits from TCustomControl
. The edit and button are created in its constructor and placed on itself.
At designtime the selection box is not drawn properly - my guess is that the edit and button are hiding it because its been drawn for the custom control and then overdrawn by them.
Here the comparison:
I have also seen this for other 3rd party components (like the TcxGrid also only draws the outer part of the selection indicator)
Question: how can I change that?
Most simple case for reproducing:
unit SearchEdit;
interface
uses
Classes, Controls, StdCtrls;
type
TSearchEdit = class(TCustomControl)
private
fEdit: TEdit;
public
constructor Create(AOwner: TComponent); override;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Custom', [TSearchEdit]);
end;
{ TSearchEdit }
constructor TSearchEdit.Create(AOwner: TComponent);
begin
inherited;
fEdit := TEdit.Create(Self);
fEdit.Parent := Self;
fEdit.Align := alClient;
end;
end.
fEdit.PaintTo(...)
in the parent at design time and paint directly to the parents canvas. – Graymatter