«« Site Rescued »»

While the site is still going to move from its current host, a new site will now take its place. More Info.

The new site may have less content, but the core will now remain. And it will now play nicely with phones! Keep an eye on the DelphiDabbler Blog for news.

» Help

How to create a borderless TComboBox

   
Question
Is it possible to create a flat or borderless combo box? If so, how would I go about it?
{ ... }
TNoBorderComboBox = class(TComboBox)
  protected
    procedure WMPaint(var Msg: TMessage); message WM_PAINT;
  end;

procedure TNoBorderComboBox.WMPaint(var Msg: TMessage);
var
  C: TControlCanvas;
  R: TRect;
begin
  inherited;
  C := TControlCanvas.Create;
  try
  C.Control := Self;
  with C do
  begin
    Brush.Color := clBtnFace;
    R := ClientRect;
    FrameRect(R);
    InflateRect(R, - 1, - 1);
    FrameRect(R);
    end;
  finally
    C.Free;
  end;
end;
Original resource: The Delphi Pool
Author: Xavier Pacheco
Added: 2009-08-24
Last updated: 2009-08-24

« Return to contents »