unit otAutoComboBox;
interface
uses
System.SysUtils, System.Classes,
Vcl.Controls,
Vcl.StdCtrls, Graphics,
Winapi.Messages, System.Generics.Collections, UnitOtObject;
type
TOtAutoComboBox = class(TCustomComboBox)
procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
private
{ Private-Deklarationen }
procedure setObjectList(aObjectList: TObjectList<TOtObject>);
protected
{ Protected-Deklarationen }
public
{ Public-Deklarationen }
property objectList: TObjectList<TOtObject> write setObjectList;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published-Deklarationen }
property Align;
property Font;
property Height default 24;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('XXXXX', [TOtAutoComboBox]);
end;
{ TOtAutoComboBox }
procedure TOtAutoComboBox.setObjectList(aObjectList: TObjectList<TOtObject>);
var
i: Integer;
begin
Items.Clear;
if aObjectList <> nil then
for i := 0 to aObjectList.Count - 1 do
Items.AddObject(aObjectList.Items[i].ToString, aObjectList.Items[i]);
end;
procedure TOtAutoComboBox.WMPaint(var Message: TWMPaint);
var
CC: TControlCanvas;
begin
inherited;
CC := TControlCanvas.Create;
try
cc.Control := Self;
CC.Brush.Color := clGray;
CC.FrameRect(ClientRect);
finally
CC.Free;
end;
end;
constructor TOtAutoComboBox.Create(AOwner: TComponent);
begin
inherited;
AutoSize := False;
ParentCtl3D := False;
Ctl3D := False;
Constraints.MaxHeight := 24;
Height := 24;
Font.Size := 11;
BevelInner := bvNone;
Parent := AOwner as TWinControl;
end;
destructor TOtAutoComboBox.Destroy;
begin
objectList := nil;
inherited;
end;
end.