|
아래와 같이 코딩을 하였는데 에러 생겼어요
도와주세요
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
CheckListBox1->Style=lbOwnerDrawFixed;
CheckListBox1->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::CheckListBox1ClickCheck(TObject *Sender)
{
CheckListBox1->Invalidate();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::CheckListBox1DrawItem(TWinControl *Control,
int Index, TRect &Rect, TOwnerDrawState State)
{
Graphics::TBitmap *pBitmap=new Graphics::TBitmap;
int Offset = 2;
TCanvas *pCanvas = ((TListBox *)Control)->Canvas;
pCanvas->FillRect(Rect);
pBitmap = (Graphics::TBitmap *)((TListBox *)Control)->Items->Objects[Index];
if (pBitmap)
{
pCanvas->BrushCopy(Bounds(Rect.Left + Offset, Rect.Top, pBitmap->Width, pBitmap->Height),
pBitmap, Bounds(0, 0, pBitmap->Width, pBitmap->Height), clRed);
Offset += pBitmap->Width + 4;
}
if( CheckListBox1->Checked[Index] ) {
// Checked 상태인 경우 Font 색상을 변경함.
pCanvas->Font->Color = clRed;
}
else {
// Font 정보를 그대로 유지하기 위하여 아무 처리도 하지 않음.
}
pCanvas->TextOut( Rect.Left + Offset, Rect.Top, ((TListBox *)Control)->Items->Strings[Index]);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ListBox1Click(TObject *Sender)
{
CheckListBox1->Clear();
if(ListBox1->Selected[ListBox1->ItemIndex])
{
for(int i=0;i<10;i++)
{
CheckListBox1->AddItem(AnsiString(i),Application);
}
}
}
|