当前位置导航:炫浪网>>网络学院>>编程开发>>C++教程>>C++ Builder教程

在BCB中数组的妙用和纪录和改变控件的状态

如果能巧妙地运用数组会给我们带来很多方便;以下是我的一些用法,还觉得自己每掌握它的精髓;希望大家多多指点;(现丑了)


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;i<Form2->LabelList->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);
    }
}
file://----------------------------------------------------------------------------


void myList::WriteList(AnsiString TS)
{//写入文件
   System::AnsiString LabPath=ExtractFilePath(\".\\\\\");
   TIniFile *LabIni=new TIniFile(LabPath+\"LabIni.ini\");
   Form2->AddList();
   for(int i=0;i<Form2->LabelList->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);
    }
}


file://------------------------------------------------------------------------------------------


  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);


file://------------------------------------------------------------------------------------------------------


void myList::NmyChick(TMenuItem *Item,AnsiString STR,int BL)
{
   file://记录TMenuItem 的状态:
   static TMenuItem *sItem=0;
   file://Item=Form2->PopupMenu1->Items;
   file://Item=dynamic_cast<TMenuItem *>(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){
       file://¶¯Ì¬¸Ä±äForm2µÄ´óСºÍÐÎ×´
       if(BL){
         Form2->Image1->Picture->Bitmap->Height =500;
         Form2->Image1->Picture->Bitmap->Width  =732;
         Form2->Image1->Stretch = false;


         file://Form2->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();

共2页 首页 上一页 1 2 下一页 尾页 跳转到
相关内容
赞助商链接