Смекни!
smekni.com

Работа со списками (стр. 4 из 4)

int i=0;

while (i<number){object++;i+=Objects.getvalue(object);}

if (object==0) object=1;

return (object);

}//end function

//---------------------------------------------------------------------------

void __fastcall TfrmMain::ListBox1Click(TObject *Sender)

{

Tline l1;

l1=LineBufer.getvalue(ListBox1->ItemIndex+1);

frmMain->lblPicture->Refresh();

LoadLines(chkSecondary->Checked);

for (int i=2;i>0;i--){

frmMain->lblPicture->Canvas->Pen->Color=clbSelect->Selected;

frmMain->lblPicture->Canvas->Ellipse(l1.p1.x-i,l1.p1.y-i,l1.p1.x+i,l1.p1.y+i);

frmMain->lblPicture->Canvas->Ellipse(l1.p2.x-i,l1.p2.y-i,l1.p2.x+i,l1.p2.y+i);

frmMain->lblPicture->Canvas->MoveTo(l1.p1.x,l1.p1.y);

frmMain->lblPicture->Canvas->LineTo(l1.p2.x,l1.p2.y);

}//next

}

//---------------------------------------------------------------------------

void __fastcall TfrmMain::ListBox1KeyDown(TObject *Sender, WORD &Key,

TShiftState Shift)

{

if (Key==46){

int object=WhichObject(ListBox1->ItemIndex+1);

frmMain->lblPicture->Refresh();

int z=ListBox1->ItemIndex;

LineBufer.remove(ListBox1->ItemIndex+1);ListBox1->Items->Delete(ListBox1->ItemIndex);

ListBox1->ItemIndex=z;

Objects.change(object,Objects.getvalue(object)-1);

if (Objects.getvalue(object)==0) {Objects.remove(object);lstObjects->Items->Delete(object-1);}

LoadLines(chkSecondary->Checked);

}//end if

}

//---------------------------------------------------------------------------

void __fastcall TfrmMain::lstObjectsClick(TObject *Sender)

{

int begin=0;

for (int i=0;i<lstObjects->ItemIndex;i++)begin+=Objects.getvalue(i);

ListBox1->ItemIndex=begin;

}

//---------------------------------------------------------------------------

void __fastcall TfrmMain::lblPictureMouseMove(TObject *Sender,

TShiftState Shift, int X, int Y)

{

lblCoords->Caption=IntToStr(X)+"; "+IntToStr(Y);

}

//---------------------------------------------------------------------------