void __fastcall TForm1::OpenPicture1Click(TObject *Sender) { OpenPictureDialog1->Filter = "Bmp files (*.bmp)|*.BMP| JPEG images (*.jpg) | *.jpg; " ; if (OpenPictureDialog1->Execute()) { if (!FileExists(OpenPictureDialog1->FileName)) return; AnsiString temp2 = ExtractFileName(OpenPictureDialog1->FileName); AnsiString temp = ExtractFileExt(OpenPictureDialog1->FileName); AnsiString Ext = temp.LowerCase(); if (Ext.AnsiPos("jpg") > 0) { TJPEGImage *myjpeg = new TJPEGImage(); myjpeg->LoadFromFile(OpenPictureDialog1->FileName); myjpeg->DIBNeeded(); Image1->Picture->Bitmap->Assign(myjpeg); delete myjpeg; } else if (Ext.AnsiPos("bmp") > 0) { Image1->Picture->Bitmap->LoadFromFile(OpenPictureDialog1->FileName); } } { Undo1->Enabled=false; //apenergopoioume ta undo/redo Redo1->Enabled=false; ToolUndo->Enabled=false; ToolRedo->Enabled=false; } }
//--------------------------------------------------------------------------- TStringList* StringToTok2( AnsiString Words, AnsiString Dlmtr1, AnsiString Dlmtr2 ) { AnsiString Work = Words.Trim(); int spos; TStringList *Making = new TStringList; int spos1 = Work.AnsiPos(Dlmtr1); int spos2 = Work.AnsiPos(Dlmtr2); while (spos1 || spos2) { // int spos = 0; if (!spos1 && spos2) spos = spos2; else if (!spos2 && spos1) spos = spos1; else spos = (spos1 < spos2) ? spos1 : spos2; Making->Add(Work.SubString( 1, spos-1)); Work = Work.SubString( spos+1, Work.Length() - spos); Work = Work.Trim(); spos1 = Work.AnsiPos(Dlmtr1); spos2 = Work.AnsiPos(Dlmtr2); } // while if (Work != "") Making->Add(Work); return Making; }
//--------------------------------------------------------------------------- double __fastcall CNHB300::GetWeight() { char strReceive[300]={0}; AnsiString strMsg; AnsiString strMsgNew; if(ReadSizeData(strReceive)) { AnsiString strMsg=strReceive; int nPosStart=strMsg.AnsiPos("ST,"); int nPosEnd=strMsg.SubString(nPosStart,15).AnsiPos("g")+nPosStart-1; if(nPosStart>0 && nPosEnd>0 && (nPosEnd-nPosStart)>5) { strMsgNew=strMsg.SubString(nPosEnd-8,8); if(strMsgNew.AnsiPos("-")>0) { strMsgNew=strMsg.SubString(nPosEnd-7,7); return strMsgNew.ToDouble()*-1.0; } else return strMsgNew.ToDouble(); } else return -999.0; } else return -999.0; }
//simvan gia tin apothikeusi tis eikonas otan patiete to save //dinatotita gia apothikeusi se bmp & jpg morfi void __fastcall TForm1::SavePic1Click(TObject *Sender) { SavePictureDialog1->Title = "Save Image"; SavePictureDialog1->DefaultExt = "jpg"; SavePictureDialog1->Filter = "JPEG images (*.jpg) | *.jpg; | Bmp files (*.bmp)|*.BMP" ; SavePictureDialog1->FilterIndex = 1; if (SavePictureDialog1->Execute()) { AnsiString temp2 = ExtractFileName(SavePictureDialog1->FileName); AnsiString temp = ExtractFileExt(SavePictureDialog1->FileName); AnsiString Ext = temp.LowerCase(); if (Ext.AnsiPos("jpg") > 0) { TJPEGImage *jp = new TJPEGImage(); try { jp->Assign(Image1->Picture->Bitmap); jp->SaveToFile(SavePictureDialog1->FileName); } __finally { delete jp; } }
void __fastcall TMainFrm::lvMessagePartsClick(TObject *Sender) { AnsiString LaunchFileName; //{display message parts we selected} if (lvMessageParts->Selected!=NULL) { LaunchFileName=lvMessageParts->Selected->Caption; LaunchFileName=UpperCase(LaunchFileName); if (LaunchFileName.AnsiPos(".EXE")>0) { WinExec(LaunchFileName.c_str(),SW_NORMAL); } else { char * associatedfilename=new char[MAX_PATH];//buffer for filename of associated executable HINSTANCE hinstassociation=FindExecutable(LaunchFileName.c_str(),ExcludeTrailingBackslash(ExtractFilePath(LaunchFileName)).c_str(), associatedfilename); if (hinstassociation>(HINSTANCE)32)//successful association found { AnsiString combinedfilenames=associatedfilename; combinedfilenames = combinedfilenames + " \"" + LaunchFileName + "\""; WinExec(combinedfilenames.c_str(),SW_NORMAL); } delete []associatedfilename;//free the memory } } }
//--------------------------------------------------------------------------- AnsiString __fastcall GetMatlab6Root(void) { AnsiString S = ""; __TRY TRegistry *RR = new TRegistry(); try { // Для Matlab 6.5 RR->RootKey = HKEY_CLASSES_ROOT; if (RR->OpenKey("\\Matlab.Application.Single.6\\CLSID",false)) S = RR->ReadString(""); if (RR->OpenKey("\\CLSID\\"+S+"\\LocalServer32",false)) S = RR->ReadString(""); int ps = S.AnsiPos("matlab.exe"); if (ps) { S = S.SubString( 1, ps-2); // S содержит размещение matlab.exe (полный путь) S = ExtractFileDir(S); S = ExtractFileDir(S); } } __finally { delete RR; } if (!DirectoryExists(S)) { S = ""; } __CATCH return S; }
void GetTCPClientConfigFromStr(const AnsiString& configure, AnsiString& ip, int& port) { int splitpos = configure.AnsiPos(","); if (splitpos > 0) { ip = configure.SubString(1, splitpos - 1); port = StrToInt(configure.SubString(splitpos+1, configure.Length())); } }
//---------------------------------------------------------------------------- //class TMemIniFile : public TCustomIniFile //---------------------------------------------------------------------------- // TIniFileのバグ回避版らしい・・・が、TIniFileと同じことをやる。ドン TMemIniFile::TMemIniFile(const AnsiString& str) : m_pStream(NULL), m_pConfig(NULL) { if ( str.AnsiPos("\\\\?\\") ) m_strIniFile = str.SubString( 4, str.Length() - 4).c_str(); else m_strIniFile = str.c_str(); // m_pStream = new wxFileInputStream( m_strIniFile ); // m_pConfig = new wxFileConfig(*m_pStream); // m_pConfig = new wxFileConfig(wxEmptyString, wxEmptyString, m_strIniFile, wxEmptyString, wxCONFIG_USE_LOCAL_FILE); m_pConfig = new wxFileConfig(wxT("krkr"), wxT("ym"), m_strIniFile, wxEmptyString, wxCONFIG_USE_LOCAL_FILE); }
//--------------------------------------------------------------------------- void StringToTokiensA( AnsiString Words, AnsiString Dlmtr, TStrings *Making ) { AnsiString Work = Words.Trim(); int spos; while ((spos = Work.AnsiPos(Dlmtr)) != 0) { Making->Add(Work.SubString( 1, spos-1)); Work = Work.SubString( spos+1, Work.Length() - spos); Work = Work.Trim(); } // while if (Work != "") Making->Add(Work); }
void __fastcall TCreateProjectDatabase::RexecSocketRead(TObject *Sender, TCustomWinSocket *Socket) { String answer = rob->OnRead_handler( Socket ); // READ INCOMING DATA // add one line at at time to memo // instead of entire answer // ACC, 11/04/03 AnsiString buffer = answer; AnsiString line; int poscr = buffer.AnsiPos( "\n" ); while ( poscr != 0 ) { line = buffer.SubString( 1, poscr-1 ); ReplyMemo->Lines->Add( line ); buffer = buffer.SubString( poscr + 1, buffer.Length() ); poscr = buffer.AnsiPos( "\n" ); } if ( buffer != NULL ) { ReplyMemo->Lines->Add( buffer ); } }
//--------------------------------------------------------------------------- static void TVPPushFilterPair(std::vector<AnsiString> &filters, AnsiString filter) { int vpos = filter.AnsiPos("|"); if(vpos) { AnsiString name = filter.SubString(1, vpos - 1); AnsiString wild = filter.c_str() + vpos; filters.push_back(name); filters.push_back(wild); } else { filters.push_back(filter); filters.push_back(filter); } }
//--------------------------------------------------------------------------- TStringList* StringToTokiens( AnsiString Words, AnsiString Dlmtr ) { AnsiString Work = Words.Trim(); int spos; TStringList *Making = new TStringList; while ((spos = Work.AnsiPos(Dlmtr)) != 0) { Making->Add(Work.SubString( 1, spos-1)); Work = Work.SubString( spos+1, Work.Length() - spos); Work = Work.Trim(); } // while if (Work != "") Making->Add(Work); return Making; }
inline int GetPos(const AnsiString& s, const AnsiString& p) { return s.AnsiPos(p); }