Please, add this component unit in your package project then install. Enjoy it!
FileName: DBLookupComboBoxBorderless.pas
unit DBLookupComboBoxBorderless;
interface
uses
System.SysUtils, System.Classes, Vcl.Controls, Vcl.DBCtrls, Vcl.Graphics,
Winapi.Messages, Winapi.Windows;
type
TDBLookupComboBoxBorderless = class(TDBLookupComboBox)
private
{ Private declarations }
FInnerBorderColor: TColor;
FOuterBorderColor: TColor;
procedure WMPaint (var Message: TWMPaint); message WM_PAINT;
procedure SetInnerBorderColor(const Value: TColor);
procedure SetOuterBorderColor(const Value: TColor);
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; Override;
published
{ Published declarations }
property InnerBorderColor: TColor read FInnerBorderColor Write SetInnerBorderColor;
property OuterBorderColor: TColor read FOuterBorderColor Write SetOuterBorderColor;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('emarti', [TDBLookupComboBoxBorderless]);
end;
{ TDBLookupComboBoxBorderless }
constructor TDBLookupComboBoxBorderless.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ParentColor:= false;
FInnerBorderColor:= clWhite;
FOuterBorderColor:= clWhite;
end;
destructor TDBLookupComboBoxBorderless.Destroy;
begin
inherited;
end;
procedure TDBLookupComboBoxBorderless.SetInnerBorderColor(const Value: TColor);
begin
FInnerBorderColor:= Value;
Invalidate;
end;
procedure TDBLookupComboBoxBorderless.SetOuterBorderColor(const Value: TColor);
begin
FOuterBorderColor:= Value;
Invalidate;
end;
procedure TDBLookupComboBoxBorderless.WMPaint(var Message: TWMPaint);
var
OuterBrush, InnerBrush: HBRUSH;
DC: hdc;
R: TRect;
begin
inherited;
DC:= GetWindowDC(Handle);
try
OuterBrush:= CreateSolidBrush(FOuterBorderColor);
InnerBrush:= CreateSolidBrush(FInnerBorderColor);
try
GetWindowRect(Handle, R);
OffsetRect(R, -R.Left, -R.Top);
FrameRect(DC, R, OuterBrush);
InflateRect(R, -1, -1);
FrameRect(DC, R, OuterBrush) ;
InflateRect(R, -1, -1);
FrameRect(DC, R, InnerBrush);
finally
DeleteObject(InnerBrush);
DeleteObject(OuterBrush);
end;
finally
ReleaseDC(Handle, DC);
end;
end;
end.
Hiç yorum yok:
Yorum Gönder