在BCB中陣列的妙用和紀錄和改變控制元件的狀態 (轉)

worldblog發表於2007-12-11
在BCB中陣列的妙用和紀錄和改變控制元件的狀態 (轉)[@more@]

如果能巧妙地運用陣列會給我們帶來很多方便;以下是我的一些用法,還覺得自己每掌握它的精髓;希望大家多多指點;(現醜了)


void ) __declspec(dllexport) myList::ReadList(AnsiString TS)
{//讀出ini的資料
  System::AnsiString LabPath=ExtractFilePath(".");
  TIniFile *LabIni=new TIniFile(LabPath+"LabIni.ini");


  Form2->AddList();
  for(int i=0;iLabelList->Count;i++)
  {
  TLabel *Lab;
  Lab=(TLabel *)Form2->LabelList->Items[i];
  Lab->Left=LabIni->ReadInteger(TS,"Left"+IntToStr(i), Lab->Left);
  Lab->Top=LabIni->ReadInteger(TS,"Top"+IntToStr(i),Lab->Top);
  }
}


void myList::WriteList(AnsiString TS)
{//寫入檔案
  System::AnsiString LabPath=ExtractFilePath(".");
  TIniFile *LabIni=new TIniFile(LabPath+"LabIni.ini");
  Form2->AddList();
  for(int i=0;iLabelList->Count;i++)
  {
  TLabel *Lab;
  Lab=(TLabel *)Form2->LabelList->Items[i];
  LabIni->WriteInteger(TS,"Left"+IntToStr(i), Lab->Left);
  LabIni->WriteInteger(TS,"Top"+IntToStr(i),Lab->Top);
  }
}



 System::AnsiString LabPath=ExtractFilePath(".");
  TIniFile *LabIni=new TIniFile(LabPath+"LabIni.ini"); 


  TList *LabelList;
  LabelList=new TList;
  LabelList->Add(Label1);
  LabelList->Add(Label2);
  LabelList->Add(Label3);
  LabelList->Add(Label4);
  LabelList->Add(Label5);
  LabelList->Add(Label6);
  LabelList->Add(Label7);
  LabelList->Add(Label8);
  LabelList->Add(Label9);
  LabelList->Add(Label10);
  LabelList->Add(Label11);
  LabelList->Add(Label12);
  LabelList->Add(Label13);
  LabelList->Add(Label14);
  LabelList->Add(Label15);



void myList::NmyChick(TMenuItem *Item,AnsiString STR,int BL)
{
  TMenuItem 的狀態:
  static TMenuItem *sItem=0;
  >PopupMenu1->Items;
  (Form2->WindowMenu->Items->GetParentMenu);
  if(sItem==Item){
  Item->Checked=false;
  return;
  }
  else if(sItem) sItem->Checked=false;
  Item->Checked=true;
  sItem=Item;
  if(Item->Checked==true){
  ̬¸Ä±äForm2µÄ´óСºÍÐÎ×´
  if(BL){
  Form2->Image1->Picture->Bitmap->Height =500;
  Form2->Image1->Picture->Bitmap->Width  =732;
  Form2->Image1->Stretch = false;


  >Image2->Picture->LoadFromFile(".LOGO.bmp");
  Form2->Image2->Width = Form2->Image2->Picture->Width;
  Form2->Image2->Height = Form2->Image2->Picture->Height;
  Form2->Image2->Top  = 12;
  Form2->Image2->Left = 15;
  Form2->Height = 500;
  Form2->Width = 732;
  Form2->Top = 0;
 Form2->Left = Screen->Width-Form2->Width;
 TCanvas *TSS =Form2->Image1->Picture->Bitmap->Canvas;
  Form1->DrawBarCode(TSS,120,300,125);
  Form2->Update();
 }
  else
  {
  Form2->Image1->Picture->Bitmap->Height =732;
  Form2->Image1->Picture->Bitmap->Width  =555;
  Form2->Image1->Stretch = false;


 Form2->Image2->Width = Form2->Image2->Picture->Width;
  Form2->Image2->Height = Form2->Image2->Picture->Height;
  Form2->Image2->Top  = 12;
  Form2->Image2->Left = 15;
  Form2->Height =732 ;
  Form2->Width = 555;
  Form2->Top = 0;
  Form2->Left = Screen->Width-Form2->Width;
  Form1->MakeLabel();
  }
  Form2->Caption = String(Form2->Image1->Picture->Bitmap->Height)+" - "+
  String(Form2->Image1->Picture->Bitmap->Width);
 
  ReadList(STR);
  Form2->Update();


  }
}



void __fastcall TForm2::FormH(T *Sender)
{
  AnsiString bj[]={"打橫1","打豎1","打橫2","打豎2","打橫3","打豎3","還原原此設定"};
  for(int i=0;iItems->Count;i++){
  if(PopupMenu1->Items->Items[i]->Checked) LT->WriteList(bj[i]);


  }


}



void __fastcall TForm2::N4Click(TObject *Sender)
{
  LT->NmyChick(Form2->N4,"打豎2",0);
}


void __fastcall TForm2::N5Click(TObject *Sender)
{
  LT->NmyChick(Form2->N5,"打橫2",1);
}


void __fastcall TForm2::N31Click(TObject *Sender)
{
  LT->NmyChick(Form2->N31,"打豎3",0);
}


void __fastcall TForm2::N32Click(TObject *Sender)
{
  LT->NmyChick(Form2->N32,"打橫3",1);
}


 


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752043/viewspace-991318/,如需轉載,請註明出處,否則將追究法律責任。

相關文章