在delphi中combobox,updown的那个键头下的灰色背景,如何才能透明(或者说是更改为与表单背景色一致) 

解决方案 »

  1.   

    用用FlatStyle控件试一试,代码当然可以解决,只是不会
      

  2.   

    不用代码 ,那你可以去修改combox的源代码呀
      

  3.   

    这里不能贴图我将效果图放在下面:http://www.myf1.net/bbs/dispbbs.asp?boardID=5&ID=273922
      

  4.   

    以下方法仅供参考,具体自己画出来:
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        ComboBox1: TComboBox;
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
        CBOldProc: TWndMethod;
      public
        { Public declarations }
        procedure CBNewWndProc(var message: TMessage);
      end;var
      Form1: TForm1;implementation{$R *.dfm}
    procedure TForm1.CBNewWndProc(var message: TMessage);
    var
      cbInfo: TComboBoxInfo;
      AP: array [0..2] of TPoint;
    begin
      if message.Msg = WM_PAINT then
      begin
        CBOldProc(Message);
        cbInfo.cbSize:= SizeOf(cbInfo);
        GetComboBoxInfo(ComboBox1.Handle, cbInfo);
        ComboBox1.Canvas.Pen.Width:= 1;
        ComboBox1.Canvas.Brush.Style:= bsSolid;
        if cbInfo.stateButton = STATE_SYSTEM_PRESSED then
          ComboBox1.Canvas.Brush.Color:= clGreen
        else
          ComboBox1.Canvas.Brush.Color:= clRed;
        ComboBox1.Canvas.Rectangle(cbInfo.rcButton);
        ComboBox1.Canvas.Brush.Color:= clBlack;
        ComboBox1.Canvas.Polygon(Ap);
      end
      else
        CBOldProc(Message);
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      CBOldProc:= Combobox1.WindowProc;
      ComboBox1.WindowProc:= CBNewWndProc;
    end;end.
      

  5.   

    上面的ComboBox1.Canvas.Polygon(Ap);去掉吧,你自己设计一个样式,或者用图片。
      

  6.   

    //放一个SpeedButton在ComboBox中,在SpeedButton中用图片 :)
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      SpeedButton1.Height := ComboBox1.ClientHeight - 3;
      SpeedButton1.Width := ComboBox1.ClientHeight - 3;
      SpeedButton1.Parent := ComboBox1;
      SpeedButton1.Left := ComboBox1.ClientWidth - SpeedButton1.Width - 2;
      SpeedButton1.Top := 2;
    end;procedure TForm1.SpeedButton1Click(Sender: TObject);
    begin
      ComboBox1.DroppedDown := not ComboBox1.DroppedDown;
    end;