C++Builder 2010 CheckBox 自适应文本宽度
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Graphics::TBitmap *bitmp = new Graphics::TBitmap;
bitmp->Canvas->Font = CheckBox1->Font;
int captionWidth = bitmp->Canvas->TextWidth(CheckBox1->Caption);
CheckBox1->Width = captionWidth + 18;
delete bitmp;
}