当前位置: 首页>>代码示例>>C++>>正文


C++ AnsiString::SetLength方法代码示例

本文整理汇总了C++中AnsiString::SetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ AnsiString::SetLength方法的具体用法?C++ AnsiString::SetLength怎么用?C++ AnsiString::SetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AnsiString的用法示例。


在下文中一共展示了AnsiString::SetLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: WMDropFiles

//---------------------------------------------------------------------------
void __fastcall TRefEditForm::WMDropFiles(TWMDropFiles &message)
{
  AnsiString FileName;
  FileName.SetLength(MAX_PATH);

  int Count = DragQueryFile((HDROP)message.Drop, 0xFFFFFFFF, NULL, MAX_PATH);

  // index through the files and query the OS for each file name...
  for (int index = 0; index < Count; ++index)
  {
    // the following code gets the FileName of the dropped file.  I know it
    // looks cryptic but that's only because it is.  Hey, Why do you think
    // Delphi and C++ Builder are so popular anyway?
    FileName.SetLength(DragQueryFile((HDROP)message.Drop, index,
      FileName.c_str(), MAX_PATH));

    // examine the filename's extension.
    // If it's a Word file then ...
    if (UpperCase(ExtractFileExt(FileName)) == ".DOC")

    {
      ListBox_Words->Items->Add(FileName);
    }
  }
  // tell the OS that we're finished...
  DragFinish((HDROP) message.Drop);
}
开发者ID:DmytroBiriukov,项目名称:RefEditor,代码行数:28,代码来源:vocab.cpp

示例2: if

// fires an event when a file, or files are dropped onto the application.
void __fastcall TForm1::WMDropFiles(TWMDropFiles &message)
{ AnsiString FileName;
  FileName.SetLength(MAX_PATH);
  FileName.SetLength(DragQueryFile((HDROP)message.Drop, 0,FileName.c_str(), MAX_PATH));

  if(UpperCase(ExtractFileExt(FileName)) == ".BMP")
  {   bmp->LoadFromFile(FileName) ;
      img->Picture->Bitmap->Assign(bmp) ;
  } else if(UpperCase(ExtractFileExt(FileName)) == ".JPG")
         {   TJPEGImage * jpeg = new TJPEGImage();
             jpeg->LoadFromFile(FileName);
             jpeg->DIBNeeded();   
             bmp->Assign(jpeg);
             img->Picture->Bitmap->Assign(bmp) ;
             delete jpeg;
         }
  preview->frmSelect->Position = 0 ;
  outType->ItemIndex = 1 ;
  if(preview->Visible) updatePreview();
  int l = bmp->Width, h = bmp->Height ;
  transType->ItemIndex = 0 ;
  //preview->TransparentColor = 0 ;
  // auto compute frame number and frameset way
   if(l < 142 || h < 142)
    {  
       int s ; int yyop ; int *v=&h, *vh=&l ;
       if(l > h*2) { v=&l ; vh=&h ; vertical=0 ; } // horizontal frameset
       else vertical = 1 ;
       flipWay->Checked = !vertical ;
       s = *vh + 3 ;
       do { yyop = (*v)/s ; } while(s && yyop*s-- != *v) ; ++s ;
       if(s < 4)
       {  frmNb->Text = 1 ;
          sprintf(msg,"frames of %i*%i",l,h) ;
          LabelSize->Caption = msg ; fsx = l ; fsy = h ;
       }
       else {nb = yyop ; fsx = s ; fsy = *vh ;
             frmNb->Text = yyop ;
             sprintf(msg,"frames of %i*%i",s,*vh) ;
             LabelSize->Caption = msg ;
       }
    } else { frmNb->Text = 1 ;
             sprintf(msg,"frames of %i*%i",l,h) ;
             LabelSize->Caption = msg ;
             nb=1 ;
           }
  preview->ClientHeight = h ;
  preview->ClientWidth  = l + (nb > 1)*15 ;
  preview->Caption      = FileName + " (" + nb + ")" ;
  fname = FileName ;
  outTypeChange((TObject*)42) ;
  Form1->Button1->Enabled = 1 ;
  Form1->Height = 304 ;
  Form1->StatusBar->Visible = 1 ;
  // tell the OS that you're finished...
  DragFinish((HDROP) message.Drop);
}
开发者ID:r043v,项目名称:g.m4kr,代码行数:58,代码来源:Unit1.cpp

示例3: ReadDataFromRegistry

//===========================================================================
void Tform_Main::ReadDataFromRegistry()
{
    AnsiString Name;
    TRegistry *Reg = NULL;
    try {
        try {
           Reg = new TRegistry;
           AnsiString appName = ExtractFileName(Application->ExeName);
           appName.SetLength(appName.Length() - 4);

           Reg->RootKey = HKEY_LOCAL_MACHINE;
           Reg->OpenKey("Software\\InnalabsUA\\ccg_QFactor", true);

            DFT_DeltaFreq = Reg->ReadFloat("DFT_DeltaFreq");

            DTF_InterpolationPointsCount = Reg->ReadInteger("DTF_InterpolationPointsCount");
            FFT_MaxPointsCount = Reg->ReadInteger("FFT_MaxPointsCount");
            SoundCardIndex = Reg->ReadInteger("SoundCardIndex");
            FreqSoundCardIndex = Reg->ReadInteger("FreqSoundCardIndex");

       } catch ( ... ){
            Reg->CloseKey();
            SaveDataToRegistry();
        }
    } __finally {
        Reg->CloseKey();
        if (Reg != NULL)
            delete Reg;
    }
}
开发者ID:Medcheg,项目名称:sources_old,代码行数:31,代码来源:unit_main.cpp

示例4: LoadIniFile

void Global::LoadIniFile(AnsiString asFileName)
{
    int i;
    for (i = 0; i < 10; ++i)
    { // zerowanie pozycji kamer
        pFreeCameraInit[i] = vector3(0, 0, 0); // wspó³rzêdne w scenerii
        pFreeCameraInitAngle[i] = vector3(0, 0, 0); // k¹ty obrotu w radianach
    }
    TFileStream *fs;
    fs = new TFileStream(asFileName, fmOpenRead | fmShareCompat);
    if (!fs)
        return;
    AnsiString str = "";
    int size = fs->Size;
    str.SetLength(size);
    fs->Read(str.c_str(), size);
    // str+="";
    delete fs;
    TQueryParserComp *Parser;
    Parser = new TQueryParserComp(NULL);
    Parser->TextToParse = str;
    // Parser->LoadStringToParse(asFile);
    Parser->First();
    ConfigParse(Parser);
    delete Parser; // Ra: tego jak zwykle nie by³o wczeœniej :]
};
开发者ID:kononowicz24,项目名称:maszyna,代码行数:26,代码来源:Globals.cpp

示例5: LoadFormPos

//---------------------------------------------------------------------------
void __fastcall LoadFormPos(TForm *Form,
                            const AnsiString IniFileName,
                            const AnsiString SectionName,
                            const AnsiString KeyName)
{
    TIniFile   *IniFile;
    AnsiString sWindowPositions;

    if (IniFileName.Length() == 0)
        return;

    // Create inifile object => Open ini file
    IniFile = new TIniFile(IniFileName);

    // Formatage par défaut de la ligne de la section window
    sWindowPositions.SetLength(256);
    WindowPosToStr(sWindowPositions.c_str(), Form);

    // Get widow's position and size from ini file
    sWindowPositions = IniFile->ReadString(SectionName,
                                           KeyName,
                                           sWindowPositions);
    StrToWindowPos(sWindowPositions.c_str(), Form);

    // Destroy inifile object => close ini file
    IniFile->Free();
}
开发者ID:KayvanGuo,项目名称:FTPRipper,代码行数:28,代码来源:OverbyteIcsFormPos.cpp

示例6: CallDllButtonClick

//---------------------------------------------------------------------------
void __fastcall TDllTestForm::CallDllButtonClick(TObject *Sender)
{
    AnsiString Buffer;
    int        BufSize;
    int        Status;

    Display("Calling DLL...");
    BufSize = 100;
    Buffer.SetLength(BufSize);
    Status = IcsDllDemo(AnsiString(HostnameEdit->Text).c_str(),
                        AnsiString(PortEdit->Text).c_str(),
                        &Buffer[1], &BufSize);
    Buffer.SetLength(BufSize);
    if (Status)
        Display("Error #" + IntToStr(Status));
    Display(Buffer);
    Display("Done with DLL");
}
开发者ID:KayvanGuo,项目名称:FTPRipper,代码行数:19,代码来源:OverbyteIcsDllTst1.cpp

示例7: W2MB

/**
 * @brief Encoding wide to multibyte std::string
 * @param $src UnicodeString
 * @param $cp code page
 * @return multibyte std::string
 */
AnsiString W2MB(const wchar_t * src, const UINT cp)
{
  // assert(src);
  if (!src || !*src)
  {
    return AnsiString("");
  }

  intptr_t reqLength = WideCharToMultiByte(cp, 0, src, -1, 0, 0, nullptr, nullptr);
  AnsiString Result;
  if (reqLength)
  {
    Result.SetLength(reqLength);
    WideCharToMultiByte(cp, 0, src, -1, const_cast<LPSTR>(Result.c_str()),
      static_cast<int>(reqLength), nullptr, nullptr);
    Result.SetLength(Result.Length() - 1);  //remove NULL character
  }
  return Result; //.c_str();
}
开发者ID:nineclock,项目名称:Far-NetBox,代码行数:25,代码来源:Classes.cpp

示例8: if

String			TSearchFilesFrm::GetSearchData()
{
    AnsiString data;
    AnsiString content_text = edtSearchContent->Text;

    if(cbSearchMode->ItemIndex == 0)
    {
        data = content_text;
    }
    else if(cbSearchMode->ItemIndex == 1)
    {
        data = BinToStr(content_text.c_str(), content_text.Length());
    }
    else if(cbSearchMode->ItemIndex == 2)
    {
        DWORD num = content_text.ToInt();
        data.SetLength(4);
        int pos = 0;
        WriteDWORD(data.c_str(), pos, num);
        data = BinToStr(data.c_str(), data.Length());
    }
    else if(cbSearchMode->ItemIndex == 3)
    {
        WORD num = content_text.ToInt();
        data.SetLength(2);
        int pos = 0;
        WriteWORD(data.c_str(), pos, num);
        data = BinToStr(data.c_str(), data.Length());
    }
    else if(cbSearchMode->ItemIndex == 4)
    {
        BYTE num = content_text.ToInt();
        data.SetLength(1);
        int pos = 0;
        WriteBYTE(data.c_str(), pos, num);
        data = BinToStr(data.c_str(), data.Length());
    }
    return	data;
}
开发者ID:eggxp,项目名称:SuperParse,代码行数:39,代码来源:FrmSearchFiles.cpp

示例9: TForm

//---------------------------------------------------------------------------
__fastcall TfrmAbout::TfrmAbout(TComponent* Owner)
        : TForm(Owner)
{
                        
   AnsiString ExaName = ExtractFileName(Application->ExeName);
   ProductName->Caption = ExaName.SetLength(ExaName.Length()-4);
   int aTopPosition = 0;

// if (WhoUseProgram == wupTanjaKvant) Label22->Visible = true;

   if (!Label22->Visible) {
      BitBtn1->Top = Label22->Top;
      ClientHeight = BitBtn1->BoundsRect.Bottom + 4;
   }
}
开发者ID:Medcheg,项目名称:sources_old,代码行数:16,代码来源:Unit_About.cpp

示例10: TForm

//---------------------------------------------------------------------------
__fastcall TEnumWinForm::TEnumWinForm(TComponent* Owner)
  : TForm(Owner)
{
  TStringList *list = new TStringList();
  list->LoadFromFile("winmsgs.txt");
  AnsiString str;
  int k;
  for(int i = 0; i < list->Count; i++)
    {
    str.SetLength(100);
    sscanf(list->Strings[i].c_str(),"%s %X\n",str.c_str(),&k);
    MsgComboBox->Items->AddObject(str,(TObject *)k);
    }
  delete list;
  MsgComboBox->ItemIndex = 0;
}
开发者ID:majioa,项目名称:enumwin,代码行数:17,代码来源:EnumWinUnit.cpp

示例11: DoObjectLoad

void __fastcall TTMTimeLineMainForm::DoObjectLoad(TObject* Sender, TStream* Stream, TObject *&AObject)
{
 AnsiString S;
 int Count;

  // Get the length of the string:
  Stream->Read(&Count,sizeof(Count));
  S.SetLength(Count);
  // need we read any more ?
  if( Count > 0 )
  {
    Stream->Read(&S[1],Count);
    AObject = new TStringList();
    dynamic_cast<TStringList* >(AObject)->Text = S;
  }
}
开发者ID:kaan3434,项目名称:gvindelen,代码行数:16,代码来源:TMTimeLineMainFormU.cpp

示例12: StringFromFile

AnsiString StringFromFile(const AnsiString FileName, __int64& FileSize)
{
  TFileStream* fs = new TFileStream(FileName, fmOpenRead);
  AnsiString Result;
  try
  {
    FileSize = fs->Size;
    Result.SetLength(FileSize);
    if (fs->Size > 0)
      fs->Read(Result.c_str(), FileSize);
  }
  __finally
  {
    delete fs;
  }
  return Result;
}
开发者ID:kaan3434,项目名称:gvindelen,代码行数:17,代码来源:MainSpeedForm.cpp

示例13: LoadFromFile

bool TCurve::LoadFromFile(AnsiString asName)
{
    DecimalSeparator = '.';
    TFileStream *fs;
    fs = new TFileStream(asName, fmOpenRead | fmShareCompat);
    AnsiString str = "xxx";
    int size = fs->Size;
    str.SetLength(size);
    fs->Read(str.c_str(), size);
    str += "";
    delete fs;
    TQueryParserComp *Parser;
    Parser = new TQueryParserComp(NULL);
    Parser->TextToParse = str;
    Parser->First();
    Load(Parser);

    delete Parser;
    DecimalSeparator = ',';
}
开发者ID:shaxbee,项目名称:maszyna,代码行数:20,代码来源:Curve.cpp

示例14: SaveDataToRegistry

//===========================================================================
void Tform_Main::SaveDataToRegistry()
{
    TRegistry *Reg = NULL;
    try {
        Reg = new TRegistry;
        AnsiString appName = ExtractFileName(Application->ExeName);
        appName.SetLength(appName.Length() - 4);

        Reg->RootKey = HKEY_LOCAL_MACHINE;
        Reg->OpenKey("Software\\InnalabsUA\\ccg_QFactor", true);

        Reg->WriteFloat("DFT_DeltaFreq", DFT_DeltaFreq);

        Reg->WriteInteger("DTF_InterpolationPointsCount", DTF_InterpolationPointsCount);
        Reg->WriteInteger("FFT_MaxPointsCount", FFT_MaxPointsCount);
        Reg->WriteInteger("SoundCardIndex", SoundCardIndex);
        Reg->WriteInteger("FreqSoundCardIndex", FreqSoundCardIndex);

    } __finally {
        Reg->CloseKey();
        if (Reg != NULL)
            delete Reg;
    }
}
开发者ID:Medcheg,项目名称:sources_old,代码行数:25,代码来源:unit_main.cpp

示例15: AddNewFileToMainMenu

//===========================================================================
//===========================================================================
//===========================================================================
//===========================================================================
void AddNewFileToMainMenu(TPopupMenu *PopupMenu, AnsiString FileName, TNotifyEvent NotifyEvent)
{
  TRegistry *Reg = new TRegistry;
  bool      FirstInput = false;
  bool      FileExist  = false;
  int       Counter    = 0;
  int       posFileNameInMenu = -1;
  AnsiString appName = ExtractFileName(Application->ExeName); appName.SetLength(appName.Length() - 4);

  try {
     Reg->RootKey = HKEY_LOCAL_MACHINE;  /// ---- Находитться в Uses Windows
     Reg->OpenKey("Software\\Digital Systems & Technologies\\" + appName, true); //create a new key >> .ext
     //-------------------
     if (FileName == "Load") {
            for ( int i = 0; i < CountFileName; i++){
              FileNameStackArray[i] = "";
              FileNameStackArray[i] = Reg->ReadString("FileName"+IntToStr(i+1));
              if (FileNameStackArray[i] != "") {
                 Counter = Counter + 1;
                 addMenuItem (Counter, PopupMenu, "&"+IntToStr(Counter) + ". " + GetShortFileName(FileNameStackArray[i]), NotifyEvent);
                 FirstInput = true;
              }
            }

            if (FirstInput) addMenuItem (Counter + 1,PopupMenu,"-", NULL);
     } else {
            // --- Проверка на повтор файла -----------
            for ( int i = 0; i < CountFileName; i++)
               if (FileName == FileNameStackArray[i]) {
                  FileExist         = true;
                  FileNameStackArray[i]  = "";
                  posFileNameInMenu = i;
               }
            // -------- Если файл уже существует то удаляем его из списка, сортируем список
            if (FileExist) {
               for ( int i = posFileNameInMenu; i < CountFileName - 1; i++ ) {
                    FileNameStackArray[i] = FileNameStackArray[i+1];
               }
               FileNameStackArray[CountFileName - 1] = "";
            }
            // ----- Добавляем в "Стек" ---------
            for ( int i = CountFileName - 1; i > 0; i--)
                if (FileNameStackArray[i-1].data() != NULL)
                    FileNameStackArray[i] = FileNameStackArray[i-1];
            FileNameStackArray[0] = FileName;

            // ---- Удаляю все файлы с менюхи  ---------
            for ( int i = PopupMenu->Items->Count-1; i >= 0; i--)
                 if (PopupMenu->Items->Items[i]->Name[1] == 'F')
                      delete PopupMenu->Items->Items[i];

            // ---- Добавляю новые файлы в менюху ------
            Counter = 0;
            for ( int i = 0; i < CountFileName - 1; i++ ) {
              if (FileNameStackArray[i] != "") {
                 Counter = Counter + 1;
                 addMenuItem (Counter, PopupMenu, "&" + IntToStr(Counter) + ". " + GetShortFileName(FileNameStackArray[i]), NotifyEvent);
              }
            }
            // ---- Добавляю черту ------
            addMenuItem (Counter + 1,PopupMenu,"-", NULL);
     }

     // ---- Записываю в Реестр -------
     for ( int i = 0; i < CountFileName; i++)
        Reg->WriteString("FileName" + IntToStr(i+1), FileNameStackArray[i]);
     //-------------------
     Reg->CloseKey();
  } __finally {
    delete Reg;
  }
}
开发者ID:Medcheg,项目名称:sources_old,代码行数:76,代码来源:mpiFileMenuStack.cpp


注:本文中的AnsiString::SetLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。