Mirror

Create a borderless TComboBox (Views: 100)


Problem/Question/Abstract:

Is it possible to create a flat or borderless combo box? If so, how would I go about it.

Answer:

{ ... }
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;

<< Back to main page