我在winxp下运行,发现speedbutton的down属性设了true以后,背景色变成了白色。
但是我希望它的背景色是灰的,怎么设。
我修改了speedbutton的winproc事件,当重画时,修改背景色为灰,但是不行。
如果down属性设为false,又可以。
请问是怎么回事?
当down=true时,speedbutton的背景色就自动变为他的parent的颜色了
刚刚试了一下,看了一下效果和源程序,这样改写:
void __fastcall TMySpeedButton::WndProc(TMessage& Msg)
{
TRect Rect;
TControlCanvas* Canvas;
Graphics::TBitmap* Bmp;
TControl::WndProc(Msg);
if (Msg.Msg!=WM_PAINT) return;
Canvas = new TControlCanvas;
Canvas->Control = this;
Bmp = new Graphics::TBitmap;
Rect = this->ClientRect;
Bmp->Width = Rect.Width();
Bmp->Height = Rect.Height();
Bmp->Canvas->CopyRect(Rect,
Canvas, Rect);
Bmp->Transparent = true;
for(int n=0; n<2; n++) {
if (n==1 && !Btn->Down) break;
//对于Down的情形,需要做2次处理
Bmp->TransparentColor = n==1 ?
clBtnHighlight : clBtnFace;
Canvas->Brush->Color = FColor;
Canvas->FillRect(Rect);
Canvas->Draw(Rect.left, Rect.top, Bmp);
}
delete Bmp; delete Canvas;
}