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


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

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


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

示例1: ChangeFileExt

//---------------------------------------------------------------------------
void __fastcall TTableForm::SpeedButton3Click(TObject *Sender)
{
	Form1->m_Descr.Clear();
   AnsiString str =  ChangeFileExt(Form1->m_strFileName, ".xml");
   Form1->m_Descr.SaveXML(str.c_str());
	Form1->FImage1->Init(Form1->m_strFileName, NULL);
    Form1->FImage1->BestFit();
    this->ListView1->Clear();
}
开发者ID:telnykha,项目名称:VideoA,代码行数:10,代码来源:TableViewForm.cpp

示例2: WriteToLog

void WriteToLog(String S) {
	HANDLE LogFile;
	String LogPath;
	String LogFileName;
	DWORD dwSize;
	AnsiString SS;
	TDateTime DateTime;
	LPDWORD NumberOfBytesWritten = new DWORD;

	try { // except
		DateTime = Now();

		LogPath = ExtractFilePath(Application->ExeName) + LoadStr(IDS_LOG_PATH);
		if (!DirectoryExists(LogPath))
			CreateDir(LogPath);

		LogFileName = IncludeTrailingPathDelimiter(LogPath) +
			ChangeFileExt(ExtractFileName(Application->ExeName),
			LoadStr(IDS_LOG_EXT));

		LogFile = CreateFile(LogFileName.w_str(), GENERIC_READ, FILE_SHARE_READ,
			NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);

		dwSize = 0;
		if (LogFile != INVALID_HANDLE_VALUE) {
			dwSize = GetFileSize(LogFile, NULL);
			CloseHandle(LogFile);
		}

		if (dwSize > MaxLogSize) {
			String NewFileName = IncludeTrailingPathDelimiter(LogPath) +
				OnlyFileName(Application->ExeName) + SPACE + FormatDateTime
				(LoadStr(IDS_DATETIME_FORMAT_FILENAME), DateTime) +
				LoadStr(IDS_LOG_EXT);
			MoveFile(LogFileName.w_str(), NewFileName.w_str());
		}

		LogFile = CreateFile(LogFileName.w_str(), GENERIC_WRITE,
			FILE_SHARE_READ, NULL, OPEN_ALWAYS,
			FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_COMPRESSED, 0);

		if (LogFile != INVALID_HANDLE_VALUE) {
			SS = AnsiString(FormatDateTime(LoadStr(IDS_DATETIME_FORMAT_LOG),
				DateTime) + "; " + AnsiReplaceStr(S, sLineBreak, SPACE) +
				sLineBreak);

			if (SetFilePointer(LogFile, 0, NULL,
				FILE_END) != INVALID_SET_FILE_POINTER)
				WriteFile(LogFile, SS.c_str(), SS.Length(),
				NumberOfBytesWritten, NULL);

			CloseHandle(LogFile);
		}
	}
	catch (...) {
	}
}
开发者ID:P3tr0viCh,项目名称:UtilsAndComps,代码行数:57,代码来源:UtilsLog.cpp

示例3: BtnAlarmEditSaveClick

void __fastcall TFrmAlarmDetailList::BtnAlarmEditSaveClick(TObject *Sender)
{
	bSaveChkFlag = false;
	SaveErrorDatas(lblAlarmCode->Caption.ToInt());

	AnsiString szQuery = "SELECT * FROM " + g_szDBList[_nTableIndex];
	tblAlarm = dbMain.getTable( szQuery.c_str() );
	_nMaxAlarmCnt = tblAlarm.numRows();
}
开发者ID:japgo,项目名称:mygithub,代码行数:9,代码来源:AlarmDetailScrn.cpp

示例4: _GetItem

LPCSTR _GetItem(LPCSTR src, int index, AnsiString& dst, char separator, LPCSTR def, bool trim)
{
    LPCSTR ptr;
    ptr = _SetPos(src, index, separator);
    if (ptr) _CopyVal(ptr, dst, separator);
    else dst = def;
    if (trim) dst = dst.Trim();
    return dst.c_str();
}
开发者ID:BubbaXXX,项目名称:xray-16,代码行数:9,代码来源:xr_trims.cpp

示例5: WinExec

void __fastcall TForm1::mnuFTPClick(TObject *Sender)
{
    if(lvList->Selected == NULL)
        return;
    AnsiString sCmd;
    sCmd = "ftp.exe "+ lvList->Selected->SubItems->Strings[1];
    WinExec(sCmd.c_str(),SW_SHOW);

}
开发者ID:zjhupo,项目名称:mstscManage,代码行数:9,代码来源:mstscManFrm.cpp

示例6: Edit

bool TMeasurementColorHistory::Edit(AnsiString& strId, AnsiString& strValue)
{
	TiXmlElement* e = Find(strId);
	if (e)
	{
		e->SetAttribute("descr", strValue.c_str());
	}
	return true;
}
开发者ID:telnykha,项目名称:Colorimetr,代码行数:9,代码来源:HistoryUnit.cpp

示例7: SendButtonClick

//---------------------------------------------------------------------------
void __fastcall TClientForm::SendButtonClick(TObject *Sender)
{
    AnsiString Buf;

    Buf = DataEdit->Text + "\r\n";
    Socket->Send(Buf.c_str(), Buf.Length());
    DataEdit->Text = "";
    ActiveControl  = DataEdit;
}
开发者ID:halaszk,项目名称:old-delphi-codes,代码行数:10,代码来源:tnsrv2.cpp

示例8: ExtractFilePath

void __fastcall TfrmMainFormServer::DeltaCopyHelp1Click(TObject *Sender)
{
    AnsiString helpFileName = ExtractFilePath(Application->ExeName) + "\\DeltaCopy.chm";

    ShellExecute(Handle,
                 "open",
                 helpFileName.c_str(),
                 NULL, NULL, SW_SHOWDEFAULT);    
}
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:9,代码来源:MainFormServer.cpp

示例9: GetObjectName

AnsiString CFolderHelper::GetObjectName(const AnsiString& full_name, AnsiString& dest)
{
    for (int i=full_name.Length(); i>=1; i--)
    	if (full_name[i]=='\\'){
        	dest=full_name.SubString(i+1,full_name.Length());
            break;
        }
    return dest.c_str();
}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:9,代码来源:FolderLib.cpp

示例10: 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

示例11: LoadSelection

void TItemList::LoadSelection(TFormStorage* storage)
{
	last_selected_items.clear();
    int cnt 			= storage->ReadInteger("sel_cnt",0);
    for (int k=0; k<cnt;k++){
    	AnsiString tmp = storage->ReadString(AnsiString().sprintf("sel%d",k),"");
        if (!tmp.IsEmpty())last_selected_items.push_back(tmp.c_str());
    }
}
开发者ID:NeoAnomaly,项目名称:xray,代码行数:9,代码来源:ItemList.cpp

示例12: TForm

__fastcall TFrmAlarmDetailList::TFrmAlarmDetailList(TComponent* Owner)
	: TForm(Owner)
{        
	_nOldErrCode = 0;
	_nTableIndex = 0;

	AnsiString szQuery = "SELECT * FROM Alarm";

	dbMain.open( AnsiString( g_MainDBPath ).c_str() );
	tblAlarm = dbMain.getTable( szQuery.c_str() );
	_nMaxAlarmCnt = tblAlarm.numRows();

	szQuery = "SELECT * FROM Warning";

	dbMain.open( AnsiString( g_MainDBPath ).c_str() );
	tblWarning = dbMain.getTable( szQuery.c_str() );
	_nMaxAlarmCnt = tblAlarm.numRows();
}
开发者ID:japgo,项目名称:mygithub,代码行数:18,代码来源:AlarmDetailScrn.cpp

示例13: InValidChar

bool __fastcall TEntryForm::InValidChar(AnsiString label, TEditPlus *edit)
{
  if (edit->Text.Length() > 0)
    return false;
  AnsiString msg = "The field "+label+" contains the value '"+edit->Text+"'."
                  +" This is invalid for a non null char field.";
  Application->MessageBox(msg.c_str(), "Invalid Char", ID_OK);
  return true;
}
开发者ID:VincentRisi,项目名称:jportal,代码行数:9,代码来源:GFEEntryUnit.cpp

示例14: BookComboBoxDrawItem

void __fastcall TMainForm::BookComboBoxDrawItem(TWinControl *Control, int Index,
      TRect &Rect, TOwnerDrawState State)
{
	TComboBox *c = (TComboBox*)Control;
	TRect rect, r;
	AnsiString s;
	HDC dc;
	HFONT font1, font2;
	HGDIOBJ old;
	TBook *b;

	b = (TBook*)(c->Items->Objects[Index]);
	r = rect = Rect;
//	dc = GetDC(Control->Handle);
	c->Canvas->FillRect(rect);

	dc = c->Canvas->Handle;
	font1 = CreateFontA(Font->Height, 0, 0, 0, 0, 0u, 0u, 0u, RUSSIAN_CHARSET, 0u, 0u, 0u, 0u, TEXT("Tahoma"));
	font2 = CreateFontA(Font->Height, 0, 0, 0, 0, 1u, 0u, 0u, RUSSIAN_CHARSET, 0u, 0u, 0u, 0u, TEXT("Tahoma"));
//
	old = SelectObject(dc, font1);
	SetTextColor(dc, 0x00000000);

	rect = r;
	rect.Bottom -= 14;
	rect.left += 2;
//	SetBkMode(dc, TRANSPARENT);
	s = b->BookName;
	DrawTextA(dc, s.c_str(), s.Length(), &rect, DT_LEFT);

	rect = r;
	rect.Top += 14;
	rect.left += 10;
//    rect.bottom -= 2;
	SelectObject(dc, font2);
//	SetTextColor(dc, 0x0000ff00);
	s = b->BookAuthor;
	DrawTextA(dc, s.c_str(), s.Length(), &rect, DT_LEFT);

	SelectObject(dc, old);
//	ReleaseDC(c->Canvas, dc);
	DeleteObject(font1);
	DeleteObject(font2);
}
开发者ID:IshPeredysh,项目名称:udd2,代码行数:44,代码来源:MainUnit.cpp

示例15: LoadFromFile

//---------------------------------------------------------------------------
void __fastcall TMainForm::LoadFromFile(const AnsiString FileName)
{
  std::ifstream in_file(FileName.c_str());
  if (!in_file)
  {
    ShowError("File cannot be opened!");
    return;
  }
  switch (FileName[FileName.Length()])
  {
    case 'm':
    case 'M':
    in_file >> rows >> cols >> lyrs;
    if (rows > MAX_DIM || cols > MAX_DIM || lyrs > MAX_DIM)
    {
      ShowError(("An array dimension cannot be more than " +
        IntToStr(MAX_DIM)).c_str());
      return;
    }
    pgcProblems->ActivePage = tbsMatrix;
    udwRows->Position = rows;
    udwColumns->Position = cols;
    udwLayers->Position = lyrs;
    udwLayer->Position = 1;
    for (int k = 0; k < lyrs; k++)
      for (int i = 0; i < rows; i++)
        for (int j = 0; j < cols; j++)
          in_file >> a[i][j][k];
    ShowMatrix();
    break;
    case 'l':
    case 'L':
    pgcProblems->ActivePage = tbsStudents;
    std::string tmps;
    StudList->Items->BeginUpdate();
    StudList->Clear();
    for (;;)
    {
      using std::getline;
      getline(in_file, tmps);
      if (!(tmps.length() && in_file)) goto ready;
      TListItem *Item = StudList->Items->Add();
      Item->Caption = tmps.c_str();
      for (int i = 0; i < 8; i++)
      {
        getline(in_file, tmps);
        Item->SubItems->Add(tmps.c_str());
      }
      while (in_file.get() != '\n')
        if (!in_file) goto ready;
    }
    ready:
    StudList->Items->EndUpdate();
    break;
  }
}
开发者ID:aababilov,项目名称:bcb-programs,代码行数:57,代码来源:Main.cpp


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