3

This is an image from a TForm where I have a TEdit at top and a TComboBox at down.

enter image description here

As you can see, the TEdit does not have the classic 3D border of the Windows controls default theme. That's because I set the Ctl3D property of that component to False. Then you see that the TComboBox has it's normal 3D border, but in this case I also set the Ctl3D property of that component to False, but it continues to show the 3D border.

It seems to be a Delphi bug at development level. How could I fix that at code?


After testing RRUZ answer, BevelKind=bkFlat, this came:

enter image description here

I do not know why it was so different... and bizarre. :-/

NaN
  • 8,596
  • 20
  • 79
  • 153
  • Other component packages that brings ComboBox variations corrects this but then we can't set the border color to black like those TEdits – NaN Oct 08 '12 at 20:03
  • 2
    Try setting the BevelKind property of the ComboBox to `bkFlat`. – RRUZ Oct 08 '12 at 20:19

3 Answers3

8

You can remove the 3D border setting the BevelKind property of the TComboBox to bkFlat.

enter image description here

RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • I put the result in the question. I don't know why but it was far from your Delphi. :( – NaN Oct 10 '12 at 02:16
1

I Found it:

We have to set:

BevelInner to bvNone ;

BevelKind to bkFlat ;

BevelOuter to bvSpace .

NaN
  • 8,596
  • 20
  • 79
  • 153
0

this is best way which support BidiMode and resize; and can fill border with client color:

TTestComboBox=class(TComboBox)
protected
  procedure WMPaint(var Msg: TMessage); message WM_Paint;
End;

Procedure TTestComboBox.WMPaint(var Msg: TMessage);
var MCanvas: TControlCanvas;
    R: TRect;
Begin
  inherited;
  MCanvas:=TControlCanvas.Create;
  Try
    MCanvas.Control:=Self;
    With MCanvas do begin
      R:=ClientRect;
      Brush.Style:= bsClear;
      Pen.Color:= Color;
      Pen.Width:= 3;
      if BiDiMode in [bdRightToLeft, bdRightToLeftNoAlign] then begin
        if Style = csSimple then                   //remove border and space
          Rectangle(1, 1, R.Width - 1, R.Height-1) else Rectangle(-1, 1, R.Width, R.Height-1);
        if Style in [csDropDown, csOwnerDrawFixed, csOwnerDrawVariable] then begin
          Pen.Width:= 5;                           //remove space btw editor and button
          MoveTo(18, 0);
          LineTo(18, R.Height-1);
        end;
      end else begin
        if Style = csSimple then
          Rectangle(1, 1, r.Width - 1, R.Height-1) else Rectangle(1, 1, r.Width + 1, R.Height-1);
        if Style in [csDropDown, csOwnerDrawFixed, csOwnerDrawVariable] then begin
          Pen.Width:= 5;
          MoveTo(R.Width - 18, 0);
          LineTo(R.Width - 18, R.Height-1);
        end;
      end;
    end;
  finally
    MCanvas.Free;
  End;
End;
MohsenB
  • 1,669
  • 18
  • 29