首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

TcomboBox上拉内容的背景颜色

2013-01-02 
TcomboBox下拉内容的背景颜色[imghttp://hi.csdn.net/space-88775-do-album-picid-1033752.html][/img]如

TcomboBox下拉内容的背景颜色
[img=http://hi.csdn.net/space-88775-do-album-picid-1033752.html][/img]
如图,如何才能把下拉内容选择后的背景蓝颜色去掉, 选择完以后就是白色底那样
[解决办法]
加一句,改变边框线条颜色

void __fastcall TForm1::ComboBox1DrawItem(TWinControl *Control, int Index,
      TRect &Rect, TOwnerDrawState State)
{
   TComboBox *cbb = (TComboBox *)Control;
   String strText = cbb->Items->Strings[Index];
   cbb->Canvas->Brush->Color = clWhite;
   cbb->Canvas->FillRect(Rect);
   if(State.Contains(odSelected))
   {
       if(State.Contains(odFocused))
           ::DrawFocusRect(cbb->Canvas->Handle, &Rect);
       if( cbb->DroppedDown )
       {
          cbb->Canvas->Pen->Color = clBlack;  //边框线条颜色  
          cbb->Canvas->Brush->Color =   RGB(49,106,197); 
          cbb->Canvas->Rectangle(Rect.Left, Rect.Top, Rect.Right, Rect.Bottom);
       }
       else
       {

          cbb->Canvas->Pen->Color = clWhite;  //边框线条颜色
          cbb->Canvas->Brush->Color = clWhite;      //背景色 你要的颜色
          cbb->Canvas->Rectangle(Rect.Left, Rect.Top, Rect.Right, Rect.Bottom);
       }
   }
   cbb->Canvas->Font->Color = clBlack;
   cbb->Canvas->Brush->Style = bsClear;
   cbb->Canvas->TextOutA(Rect.Left + 2, Rect.Top , strText);
  

热点排行