//--------------------------------------------------------------------- #include #pragma hdrstop #include "MainForm.h" #include "CreatAni.h" //--------------------------------------------------------------------- #pragma resource "*.dfm" TDlgAni *DlgAni; //--------------------------------------------------------------------- __fastcall TDlgAni::TDlgAni(TComponent* AOwner) : TForm(AOwner) { } //--------------------------------------------------------------------- void SetHorizontalScrollBar(TListBox * lb) { int j; int MaxWidth; MaxWidth= 0; for (j= 0; j < lb->Items->Count; j ++) { if(MaxWidth < lb->Canvas->TextWidth(lb->Items->Strings[j])) MaxWidth= lb->Canvas->TextWidth(lb->Items->Strings[j]); } SendMessage(lb->Handle, LB_SETHORIZONTALEXTENT, MaxWidth + 5, 0); } //--------------------------------------------------------------------- void __fastcall TDlgAni::FormCreate(TObject *Sender) { if (MainFrm->ActiveMDIChild == NULL) return ; int i; SrcList = new TList(); DstList = new TList(); for (i = (MainFrm->MDIChildCount-1); i >=0 ; i--) { SourcList->Items->Add(MainFrm->MDIChildren[i]->Caption); SrcList->Add((TChildImage *)MainFrm->MDIChildren[i]); } SetHorizontalScrollBar(SourcList); } //--------------------------------------------------------------------------- TList * __fastcall TDlgAni::GetDstList(void) { return(DstList) ; } //--------------------------------------------------------------------------- void __fastcall TDlgAni::AddClick(TObject *Sender) { if (SourcList->ItemIndex == -1) return ; DestList->Items->Add(SourcList->Items->Strings[SourcList->ItemIndex]); DstList->Add(SrcList->Items[SourcList->ItemIndex]); Remove->Enabled = true; OK->Enabled = true; SetHorizontalScrollBar(DestList); } //--------------------------------------------------------------------------- void __fastcall TDlgAni::RemoveClick(TObject *Sender) { if(DestList->ItemIndex == -1) return ; DstList->Delete(DestList->ItemIndex); DestList->Items->Delete(DestList->ItemIndex); if(DestList->Items->Count == 0) { Remove->Enabled = false; OK->Enabled = false; } SetHorizontalScrollBar(DestList); } //--------------------------------------------------------------------------- void __fastcall TDlgAni::OKClick(TObject *Sender) { ModalResult = mrOk; } //--------------------------------------------------------------------------- void __fastcall TDlgAni::DestListDblClick(TObject *Sender) { RemoveClick(this); } //--------------------------------------------------------------------------- void __fastcall TDlgAni::SourcListDblClick(TObject *Sender) { AddClick(this); } //--------------------------------------------------------------------------- void __fastcall TDlgAni::CancelClick(TObject *Sender) { ModalResult = mrCancel; } //---------------------------------------------------------------------------