Exemple #1
0
void TFileVersionInfo::SplitVersionNumber()
{
	String version = Values[fviFileVersion];
	if (version.IsEmpty()) return;

	version = AnsiReplaceStr(version, ",", "."); // Seperator can be ',' or '.'.

	int pos1 = 1;
	int pos2 = version.Pos(".");
	if (!pos2) return;
	FMajor = version.SubString(pos1, pos2-pos1);
	version = version.Delete(pos1, (pos2-pos1 +1));

	pos2 = version.Pos(".");
	if (!pos2) return;
	FMinor = version.SubString(pos1, pos2-pos1);
	version = version.Delete(pos1, (pos2-pos1 +1));

	pos2 = version.Pos(".");
	if (!pos2) return;
	FRelease = version.SubString(pos1, pos2-pos1);
	version = version.Delete(pos1, (pos2-pos1 +1));

	FBuild = version;
}
/**
*  @brief
*    Checks and corrects names
*/
void PLSceneContainer::CheckAndCorrectName(String &sName, const TCHAR szMaxNode[], const char szType[]) const
{
	// Check for empty name
	if (!sName.GetLength()) {
		g_pLog->LogFLine(PLLog::Warning, "'%s': There's no %s name!", szMaxNode, szType);

		// Set a dummy name
		sName = "?";

	// Check for spaces/tabs within the name
	} else if (sName.IndexOf(" ") >= 0 || sName.IndexOf("	") >= 0) {
		if (g_SEOptions.bRemoveSpaces) {
			const String sOldName = sName;

			// Remove all spaces
			int i = sName.IndexOf(" ");
			while (i >= 0) {
				sName.Delete(i, 1);
				i = sName.IndexOf(" ");
			}

			// Remove all tabs
			i = sName.IndexOf("	");
			while (i >= 0) {
				sName.Delete(i, 1);
				i = sName.IndexOf("	");
			}

			// Log message
			g_pLog->LogFLine(PLLog::Warning, "'%s': There are spaces/tabs within the %s name '%s', this is NOT recommended! Changed name into '%s' automatically.", szMaxNode, szType, sOldName.GetASCII(), sName.GetASCII());
		} else {
			g_pLog->LogFLine(PLLog::Warning, "'%s': There are spaces/tabs within the %s name '%s', this is NOT recommended!", szMaxNode, szType, sName.GetASCII());
		}
	}
}
Exemple #3
0
void PixInsightX11Installer::CopyFiles( const String& targetDir, const String& sourceDir )
{
   if ( !targetDir.BeginsWith( '/' ) )
      throw Error( "CopyFiles(): Relative target directory." );
   if ( !sourceDir.BeginsWith( '/' ) )
      throw Error( "CopyFiles(): Relative source directory." );
   if ( targetDir.EndsWith( '/' ) || sourceDir.EndsWith( '/' ) )
      throw Error( "CopyFiles(): Incorrectly terminated directories." );
   if ( !File::DirectoryExists( targetDir ) )
      throw Error( "CopyFiles(): Nonexistent target directory." );
   if ( !File::DirectoryExists( sourceDir ) )
      throw Error( "CopyFiles(): Nonexistent source directory." );

   StringList sourceItems = SearchDirectory( sourceDir );

   size_type sourceDirLen = sourceDir.Length();
   for ( StringList::const_iterator i = sourceItems.Begin(); i != sourceItems.End(); ++i )
   {
      String relSourcePath = *i;
      relSourcePath.DeleteLeft( sourceDirLen );

      String targetPath = targetDir + relSourcePath;
      if ( targetPath.EndsWith( '/' ) )
      {
         /*
          * Create a subdirectory
          */
         targetPath.Delete( targetPath.UpperBound() );
         if ( !File::DirectoryExists( targetPath ) )
         {
            File::CreateDirectory( targetPath );
            String sourcePath = *i;
            sourcePath.Delete( sourcePath.UpperBound() );
            File::CopyTimesAndPermissions( targetPath, sourcePath );
         }
      }
      else
      {
         /*
          * Copy a file
          */
         /*
          * ### N.B. We don't have to create subdirectories here becase they
          * have been reported by SearchDirectory(), and we are creating them
          * before copying files. SearchDirectory() promises that all
          * subdirectories are reported before their contained files.
          */
         /*
         String targetSubdir = File::ExtractDirectory( targetPath );
         if ( targetSubdir.EndsWith( '/' ) )
            targetSubdir.Delete( targetSubdir.UpperBound() );
         if ( !File::DirectoryExists( targetSubdir ) )
            File::CreateDirectory( targetSubdir );
         */
         File::CopyFile( targetPath, *i );
      }
   }
}
Exemple #4
0
String TrimChars(const String Source, Char ALeadingChar, Char ATrailingChar)
{
  String Result = Source;
  if ((Result != "") && (ALeadingChar != 0))
    while (Result[1] == ALeadingChar)
      Result.Delete(1, 1);

  if ((Result != "") && (ATrailingChar != 0))
    while (Result[Result.Length()] == ATrailingChar)
      Result.Delete(Result.Length(), 1);
  return Result;
}
Exemple #5
0
void __fastcall TMainForm::SchoolCodeMaskEditChange(TObject *Sender)
{
	String chars = "0123456789";
	TMaskEdit *me = (TMaskEdit*)Sender;
	char *c;
	int i, carPos;
	String s = me->Text;

	carPos = me->SelStart;
	for (i = 1; i <= s.Length(); i++) {
		if (!chars.Pos(s[i]))	{
			s.Delete(i, 1);
			carPos--;
			Beep();
		}
	}

	if (s.Length() > 6)	{
		s = s.SubString(1, 6);
		Beep();
	}
	me->Text = s;
	me->SelStart = carPos;

//	c =

}
Exemple #6
0
void TLevWrt::Change_State(TPanel *obj, String s, TColor col)
{
 if (obj->Caption.Pos(compPanelLab) != NULL)
 {
  String s = obj->Caption;
  String dest;
  for (int i = s.Length(); i > 0; i--)
  {
   if (s[i] != 'p') dest.Insert(s[i], 0);
   else break;
  }
   TComponent* comp = Application->FindComponent(compObjType + IntToStr(StrToInt(dest) + cm));
   comp->Free();
   comp = Application->FindComponent(compFilePath + IntToStr(StrToInt(dest) + cm));
   comp->Free();
   comp = Application->FindComponent("OpnDlg" + IntToStr(StrToInt(dest) + cm));
   comp->Free();
 }
 String line = s.Delete(s.Pos("&"), 1);
 obj->Caption = line;
 obj->Hint = line;
 obj->Color = col;
 obj->Font->Color = clBlack;
 modified = true;
}
Exemple #7
0
 bool LocalizeMenuItem(TMenuItem* sControl,int Mode,IDCMapLocalStrings* Strs)
 {
	if(!Strs)Strs = g_pLocalStrings;

	dcmapWCSTR wstr;

	String Name = sControl->Name;

	if(Mode==0)
	{
		 Strs->SelectSection("Menues");
		 int len = Name.Length();
		 Name.Delete(len-3,len);
	}

	if(!sControl->SubMenuImages)
		sControl->SubMenuImages = InterfaceModule->MenuImageList;

	wstr = Strs->GetSectionStringW(WideToString(Name).c_str());
	if(wstr[0])sControl->Caption = wstr;

	wstr = Strs->GetSectionStringW(WideToString(Name+".Hint").c_str());
	if(wstr[0])sControl->Hint = wstr;

	wstr = Strs->GetSectionStringW(WideToString(Name+".Shortcut").c_str());
	if(wstr[0])sControl->ShortCut = TextToShortCut(wstr);
	wstr = Strs->GetSectionStringW(WideToString(Name+".Glyph").c_str());
	if(wstr[0])
	{
		sControl->ImageIndex = InterfaceModule->GetMenuImage(wstr);
	}
	return true;

 }
Exemple #8
0
/**
*  @brief
*    Gets a AngelScript function declaration
*/
String Script::GetAngelScriptFunctionDeclaration(const String &sFunctionName, const String &sFunctionSignature, bool bCppToAngelScript) const
{
	// Start with the PixelLight function signature (e.g. "void(int,float)")
	String sFunctionDeclaration = sFunctionSignature;

	// Find the index of the "("
	int nIndex = sFunctionDeclaration.IndexOf("(");
	if (nIndex > -1) {

		// [HACK] AngelScript really don't like something like "string MyFunction(string)", it want's "string @MyFunction(const string &)"!
		// I assume that "@" means "AngelScript, take over the control of the given memory". I wasn't able to find the documentation about
		// the AngelScript function declaration syntax, just "scriptstring.cpp" as example.
		if (bCppToAngelScript && sFunctionDeclaration.IndexOf("string") > -1) {
			String sParameters = sFunctionDeclaration.GetSubstring(nIndex);	// Find the parameters part in the string
			sParameters.Replace("string", "const string &");				// Change parameters
			sFunctionDeclaration.Delete(nIndex);							// Remove parameters from original function declaration
			sFunctionDeclaration.Replace("string", "string @");				// Change return
			sFunctionDeclaration += sParameters;							// Construct new function declaration
			nIndex = sFunctionDeclaration.IndexOf("(");						// Update the "(" index
		}

		// Create the AngelScript function declaration (e.g. "void MyFunction(int,float)")
		sFunctionDeclaration.Insert(' ' + sFunctionName, nIndex);
	}

	// Return the AngelScript function declaration (e.g. "void MyFunction(int,float)")
	return sFunctionDeclaration;
}
Exemple #9
0
/*********************************************************************\
	Function name    : CLanguageList::Init
	Description      :
	Created at       : 26.09.01, @ 16:11:23
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
void CLanguageList::Init()
{
	Filename resourcepath = GeGetStartupPath() + Filename("resource");

	if (GetC4DVersion() >= 16000) {
		// R16 has a new resource directory structure. The c4d_language.str
		// files we are searching for are in resource/modules/c4dplugin/strings_xx.
		// Fix for https://github.com/nr-plugins/resedit/issues/4
		resourcepath = resourcepath + "modules" + "c4dplugin";
	}

	AutoAlloc <BrowseFiles> pBrowse;
	pBrowse->Init(resourcepath, false);

	while (pBrowse->GetNext())
	{
		if (pBrowse->IsDir())
		{
			Filename fn = pBrowse->GetFilename();
			if (fn.GetString().SubStr(0, 8).ToLower() == "strings_")
			{
				String idx = fn.GetString();
				idx.Delete(0, 8);

				Filename stringname = resourcepath + fn+Filename("c4d_language.str");
				AutoAlloc <BaseFile> pFile;
				if (!pFile)
					return;
				if (!GeFExist(stringname))
				{
					GeOutString("Missing c4d_language.str to identify the string directory!!!", GEMB_ICONEXCLAMATION);
				}
				else if (pFile->Open(stringname))
				{
					Int32 len = pFile->GetLength();
					Char *buffer = NewMemClear(Char,len + 2);
					if (buffer)
					{
						pFile->ReadBytes(buffer,len);
						buffer[len]=0;

						Int32 i;

						for (i = 0; i < len && buffer[i] >= ' '; i++) { }
						buffer[i] = 0;

						for (i--; i > 0 && buffer[i]== ' '; i--) { }
						buffer[i + 1] = 0;

						AddLanguage(buffer, idx);
						DeleteMem(buffer);
					}
				}
			}
		}
	}

	CriticalAssert(GetNumLanguages() > 0);
}
Exemple #10
0
String TPropertyHandler::GetClassNamesValues(TComponent* comp, String prName)
{
	TObject *subObj = (TObject *)GetOrdProp(comp, prName);
	if (subObj == NULL) return ""; // In case the prop-value is empty (like Action).

/*  TObject* subObj is needed to find out if the subprop points to
	another Component (like ActiveControl).
	If it is only the value of that property is returned (ie.: "CheckBox1").
	If it is a class like Font all of the props+values of
	comp->Font are returned. */

	if (dynamic_cast<TComponent*>(subObj))
	{   // Find out if subObj points to another Component by casting.
		return prName + "=" + GetValue((TComponent*)subObj,"Name");
	}

/*  subObj does not point to another Component, but we can convert
	it to a TComponent* subComp so it can be used te get the subProps+values.
	This sounds weird but don't forget that a TFont encapsulated in a TForm
	becomes a descendant of TForm, which is a descendant of TComponent!! */

	TComponent* subComp = (TComponent*)subObj;

	TStringList *tempList = new TStringList;
	String temp;
	try
	{
		PTypeInfo TypeInfo = (PTypeInfo)subComp->ClassInfo();
		PPropInfo* PropList = new TPropList;
		GetPropInfos(TypeInfo, (PPropList)PropList);

		tempList->Sorted = true;
		for (int i=0; i < PropertyCount(subComp); i++)
		{
			String subProp = String(PropList[i]->Name);
			tempList->Add(
				prName + "." + subProp
				+ "=" + GetPropValue(subComp, subProp, true) );
		}

		delete[] PropList;

		temp = tempList->Text;
		// Remove trailing carriage-returns:
		int cr = temp.LastDelimiter("\r");
		if (cr) temp.Delete(cr, 2);
	}
	__finally
	{
		delete tempList;
	}

	return temp;
}
Exemple #11
0
String& __stdcall ReplaceString ( String& text, const char* replaceme, const char* newword )
{
	if ( !text.IsEmpty() && replaceme != NULL) {
		int i = 0;
		while (( i = text.Find(replaceme, i)) != -1 ) {
			text.Delete(i,lstrlenA(replaceme));
			text.Insert(i, newword);
			i = i + lstrlenA(newword);
	}	}

	return text;
}
Exemple #12
0
String UpdateComponentName(String name) {
	int pos = PosEx("_", name, 1);

	name[1] = UpperCase(name[1])[1];
	while (pos != 0) {
		name[pos + 1] = UpperCase(name[pos + 1])[1];
        name.Delete(pos, 1);
		pos = PosEx("_", name, pos);
	}

	return name;
}
Exemple #13
0
//---------------------------------------------------------------------------
String TMYIniFile::ReadString(String Section, String Ident, char * def)
{
  int i = Find(Section.c_str(), Ident.c_str());
  if( i<0 )
		return String(def);

  String s = list->Strings[i];
  i = s.Pos("=");
  if( i==0 ) // = not found
		return String(def);
	// found
	return s.Delete(1, i).TrimLeft();
}
Exemple #14
0
/*********************************************************************\
	Function name    : CLanguageList::Init
	Description      :
	Created at       : 26.09.01, @ 16:11:23
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
void CLanguageList::Init()
{
	Filename resourcepath = GeGetStartupPath() + Filename("resource");
	AutoAlloc <BrowseFiles> pBrowse;
	pBrowse->Init(resourcepath, false);

	while (pBrowse->GetNext())
	{
		if (pBrowse->IsDir())
		{
			Filename fn = pBrowse->GetFilename();
			if (fn.GetString().SubStr(0, 8).ToLower() == "strings_")
			{
				String idx = fn.GetString();
				idx.Delete(0, 8);

				Filename stringname = resourcepath + fn+Filename("c4d_language.str");
				AutoAlloc <BaseFile> pFile;
				if (!pFile)
					return;
				if (!GeFExist(stringname))
				{
					GeOutString("Missing c4d_language.str to identify the string directory!!!", GEMB_ICONEXCLAMATION);
				}
				else if (pFile->Open(stringname))
				{
					Int32 len = pFile->GetLength();
					Char *buffer = NewMemClear(Char,len + 2);
					if (buffer)
					{
						pFile->ReadBytes(buffer,len);
						buffer[len]=0;

						Int32 i;

						for (i = 0; i < len && buffer[i] >= ' '; i++) { }
						buffer[i] = 0;

						for (i--; i > 0 && buffer[i]== ' '; i--) { }
						buffer[i + 1] = 0;

						AddLanguage(buffer, idx);
						DeleteMem(buffer);
					}
				}
			}
		}
	}
}
Exemple #15
0
//----------------------------------------------------------------------
int __fastcall TCotTest::QryStock(String Capital,String SecuID,int &YE,int &KYS,int &MRDJS,int &MCDJS)
{
  TBourse bourse;

  if(SecuID[1]=='H') { bourse = bsSH; }
  else { bourse = bsSZ; }

  TStockRec *stockRec = FindStock(Capital,bourse,SecuID.Delete(1,1));
  if(stockRec) {
    YE    = stockRec->Balance;
    KYS   = stockRec->Available;
    MRDJS = stockRec->BuyFreeze;
    MCDJS = stockRec->SellFreeze;
  }
  else { return -1; }

  return 0;
}
Exemple #16
0
/** Return a string reprecentation of the VCL method.
 *  \return New reference
 */
static PyObject *VclMethod_Repr(TVclMethod* self)
{
	String Str = L'<';
	int VirtualIndex = MaxInt;
	for(int I = 0; I < self->Methods.get_length(); I++)
	{
		TRttiMethod *Method = self->Methods[I];
		if(Method->VirtualIndex != VirtualIndex)
			Str += Method->ToString() + ", ";
		VirtualIndex = Method->VirtualIndex;
	}
	Str.Delete(Str.Length()-1, 2); //Remove last ", "
	TComponent *Component = dynamic_cast<TComponent*>(self->Instance);
	if(Component != NULL)
		Str += " of <object '" + Component->Name + "' of type '" + Component->ClassName() + "'>>";
	else
		Str += " of <object of type '" + self->Instance->ClassName() + "'>>";
	return PyUnicode_FromUnicode(Str.c_str(), Str.Length());
}
Exemple #17
0
//----------------------------------------------------------------------
int __fastcall TCotTest::Buy(String Capital,String SecuID,double Price,int Num,String &HTXH)
{
  //IsCan(float Rate)

  String  contractID;
  TBourse bourse;
  
  if(SecuID[1]=='H') {
    contractID = ++SHContractID;
    bourse     = bsSH;
  }
  else {
    contractID = ++SZContractID;
    bourse     = bsSZ;
  }

  SecuID.Delete(1,1);

  //增加委托记录
  TCmsRec *cmsRec = new TCmsRec();
  memset(cmsRec,0,sizeof(TCmsRec));

  strcpy(cmsRec->Capital,Capital.c_str()); 
  cmsRec->Bourse = bourse;
  strcpy(cmsRec->ContractID,contractID.c_str());
  strcpy(cmsRec->SecuID,SecuID.c_str());
  strcpy(cmsRec->Time,TRjlFunc::TimeShortToSimp(Now()).c_str());
  strcpy(cmsRec->Date,TRjlFunc::DateShortToSimp(Now()).c_str());
  cmsRec->Type      = 'B';
  cmsRec->State     = '0';
  cmsRec->CsnVol    = Num;
  cmsRec->TrdVol    = 0;                //成交数量
  cmsRec->CancelVol = 0;             //撤单数量
  cmsRec->CsnPrice  = Price;              //委托价格
  cmsRec->TrdPrice  = Price;              //成交价格

  FCmsRec->Add(cmsRec);

  HTXH = contractID;
  Beep();
  return 0;
}
Exemple #18
0
void        TDesignFrm::RefreshCurClickHead()
{
    vleSubHeadDef->Strings->BeginUpdate();
    vleSubHeadDef->Strings->Clear();
    int ARow = vleHeadDef->Row;
    gbSubPack->Caption = FormatStr("封包子定义    <%s>", vleHeadDef->Keys[ARow]);
    WorkPackHead * curWorkPackHead = m_WorkSpaceManager->GetWorkSpacePacks()->FindWorkPack(vleHeadDef->Keys[ARow]);
    m_LastMovePackHead = curWorkPackHead;

    if(curWorkPackHead == NULL)
        return;
    String comment;
    for(int i=0; i<curWorkPackHead->m_Files.Count(); i++)
    {
        comment = curWorkPackHead->m_Files[i]->GetComment();
        comment.Delete(1, 2);
        comment = comment.TrimLeft();
        vleSubHeadDef->InsertRow(curWorkPackHead->m_Files[i]->GetFileName(),
                    comment, true);
    }
    vleSubHeadDef->Strings->EndUpdate();
}
Exemple #19
0
//---------------------------------------------------------------------------
// {time} {ip} {host} {facility} {priority} {tag} {message}
String TSyslogMessage::Format(String fmt)
{
  int i;
  if( (i = fmt.Pos("{time}")) > 0 )
  {
    fmt.Delete(i, 6);
    fmt.Insert(DateStr, i);
  }
  if( (i = fmt.Pos("{ip}")) > 0 )
  {
    fmt.Delete(i, 4);
    fmt.Insert(SourceAddr, i);
  }
  if( (i = fmt.Pos("{host}")) > 0 )
  {
    fmt.Delete(i, 6);
    fmt.Insert(HostName, i);
  }
  if( (i = fmt.Pos("{facility}")) > 0 )
  {
    fmt.Delete(i, 10);
    fmt.Insert(Facility, i);
  }
  if( (i = fmt.Pos("{priority}")) > 0 )
  {
    fmt.Delete(i, 10);
    fmt.Insert(Priority, i);
  }
  if( (i = fmt.Pos("{tag}")) > 0 )
  {
    fmt.Delete(i, 5);
    fmt.Insert(Tag, i);
  }
  if( (i = fmt.Pos("{message}")) > 0 )
  {
    fmt.Delete(i, 9);
    fmt.Insert(Msg, i);
  }
  return fmt;
}
/**
*  @brief
*    Constructor
*/
PLSceneTexture::PLSceneTexture(PLScene &cScene, const String &sName, bool bNormalMap_xGxR) :
	m_pScene(&cScene),
	m_sName(sName),
	m_nReferenceCount(0)
{
	// Cut of the path of the map name - if there's one
	String sAbsBitmapFilename = m_sName;

	// Get the texture name
	m_sName = sName;

	// Check options
	if (g_SEOptions.bCopyTextures) {
		// Can we use the given absolute filename?
		HANDLE hFile = CreateFileW(sAbsBitmapFilename.GetUnicode(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
		if (hFile == INVALID_HANDLE_VALUE) {
			// Get the current path of the loaded 3ds Max scene
			String sCurFilePath = Url(GetCOREInterface()->GetCurFilePath().data()).CutFilename();
			if (sCurFilePath.GetLength()) {
				// Compose absolute filename by just concatenating the two filenames (for relative filenames)
				String sBitmapFilename = sCurFilePath + sAbsBitmapFilename;
				hFile = CreateFileW(sBitmapFilename.GetUnicode(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
				if (hFile == INVALID_HANDLE_VALUE) {
					// Get the filename without any path information
					String sFilenameOnly  = Url(sName).GetFilename().GetASCII();

					// Compose absolute filename
					if (sFilenameOnly.GetLength()) {
						char nLastCharacter = sCurFilePath[sCurFilePath.GetLength()-1];
						if (nLastCharacter == '\\' || nLastCharacter == '/')
							sBitmapFilename = sCurFilePath + sFilenameOnly;
						else
							sBitmapFilename = sCurFilePath + "\\" + sFilenameOnly;
						hFile = CreateFileW(sBitmapFilename.GetUnicode(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
						if (hFile == INVALID_HANDLE_VALUE) {
							// Check map directories
							int nMapDirCount = TheManager->GetMapDirCount();
							for (int nMapDir=0; nMapDir<nMapDirCount; nMapDir++) {
								const String sMapDir = TheManager->GetMapDir(nMapDir);
								const uint32 nLength = sMapDir.GetLength();
								if (nLength) {
									nLastCharacter = sMapDir[nLength-1];
									if (nLastCharacter == '\\' || nLastCharacter == '/')
										sBitmapFilename = sMapDir + sFilenameOnly;
									else
										sBitmapFilename = sMapDir + '\\' + sFilenameOnly;
									hFile = CreateFileW(sBitmapFilename.GetUnicode(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
									if (hFile != INVALID_HANDLE_VALUE)
										break;
									else
										sAbsBitmapFilename = sBitmapFilename;
								}
							}
						} else {
							sAbsBitmapFilename = sBitmapFilename;
						}
					}
				} else {
					sAbsBitmapFilename = sBitmapFilename;
				}
			}
		}
		if (hFile != INVALID_HANDLE_VALUE) {
			// Get source file time and close it
			FILETIME sSourceCreationTime;
			FILETIME sSourceLastAccessTime;
			FILETIME sSourceLastWriteTime;
			GetFileTime(hFile, &sSourceCreationTime, &sSourceLastAccessTime, &sSourceLastWriteTime);
			CloseHandle(hFile);

			// Cut of the filename
			String sFilename = Url(g_SEOptions.sFilename).CutFilename();

			// Construct the absolute target filename
			uint32 nLength = sFilename.GetLength();
			if (nLength) {
				sFilename = sFilename + m_sName;

				// Is there already such a file? If yes, check the file times...
				hFile = CreateFileW(sFilename.GetUnicode(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
				if (hFile != INVALID_HANDLE_VALUE) {
					// Get target file time and close it
					FILETIME sTargetCreationTime;
					FILETIME sTargetLastAccessTime;
					FILETIME sTargetLastWriteTime;
					GetFileTime(hFile, &sTargetCreationTime, &sTargetLastAccessTime, &sTargetLastWriteTime);
					CloseHandle(hFile);

					// Compare file time
					long nResult = CompareFileTime(&sTargetLastWriteTime, &sSourceLastWriteTime);
					if (nResult >= 0)
						return; // Nothing to do :)
				}

				{ // Before we copy, we need to ensure that the target directory is there, else 'CopyFile()' will fail!
					Directory cDirectory(Url(sFilename).CutFilename());
					cDirectory.CreateRecursive();
				}

				// Copy the texture (bitmap)
				CopyFileW(sAbsBitmapFilename.GetUnicode(), sFilename.GetUnicode(), false);

				// If there's a 'plt'-file for the texture, copy it, too
				int nIndex = sFilename.LastIndexOf(".");
				if (nIndex >= 0) {
					sFilename.Delete(nIndex);
					sFilename += ".plt";
					nIndex = sAbsBitmapFilename.LastIndexOf(".");
					if (nIndex >= 0) {
						sAbsBitmapFilename.Delete(nIndex);
						sAbsBitmapFilename += ".plt";
						if (!CopyFileW(sAbsBitmapFilename.GetUnicode(), sFilename.GetUnicode(), false)) {
							// Failed to copy the 'plt'-file...
							if (bNormalMap_xGxR) {
								// Create an automatic 'plt'-file...
								// Create XML document
								XmlDocument cDocument;

								// Add declaration
								XmlDeclaration *pDeclaration = new XmlDeclaration("1.0", "ISO-8859-1", "");
								cDocument.LinkEndChild(*pDeclaration);

								// Add texture
								XmlElement *pTextureElement = new XmlElement("Texture");

								// Setup attribute
								pTextureElement->SetAttribute("Version", "1");

								// Add general
								XmlElement *pGeneralElement = new XmlElement("Node");
								pGeneralElement->SetAttribute("Compression", "DXT5_xGxR");

								// Link general element
								pTextureElement->LinkEndChild(*pGeneralElement);

								// Link material element
								cDocument.LinkEndChild(*pTextureElement);

								// Save settings
								if (cDocument.Save(sFilename))
									g_pLog->LogFLine(PLLog::Hint, "Created '%s'", sFilename.GetASCII());
								else
									g_pLog->LogFLine(PLLog::Error, "Can't create '%s'!", sFilename.GetASCII());
							}
						}
					}
				}
			}
		} else {
			g_pLog->LogFLine(PLLog::Error, "Can't find texture (bitmap) '%s'!", m_sName.GetASCII());
		}
	}
}
Exemple #21
0
FARAPI(HANDLE) OpenPlugin(int OpenFrom,int Item)
{
  UpdateConfig();
  if(OpenFrom==OPEN_EDITOR)
  {
    //DebugBreak();
    EditorInfo ei;
    I.EditorControl(ECTL_GETINFO,&ei);
    Autoload(ei.FileName);
    if(Count()==0)
    {
      Msg(MENotLoaded);
      return INVALID_HANDLE_VALUE;
    }
    MenuList ml;
    enum{
      miFindSymbol,miUndo,miResetUndo,
      miComplete,miBrowseFile,miBrowseClass,
    };
    ml<<MI(MFindSymbol,miFindSymbol)
      <<MI(MCompleteSymbol,miComplete)
      <<MI(MUndoNavigation,miUndo)
      <<MI(MResetUndo,miResetUndo)
      <<MI(MBrowseSymbolsInFile,miBrowseFile)
      <<MI(MBrowseClass,miBrowseClass);
    int res=Menu(GetMsg(MPlugin),ml,0);
    if(res==-1)return INVALID_HANDLE_VALUE;
    switch(res)
    {
      case miFindSymbol:
      {
        String word=GetWord();
        if(word.Length()==0)return INVALID_HANDLE_VALUE;
        //Msg(word);
        PTagArray ta=Find(word,ei.FileName);
        if(!ta)
        {
          Msg(GetMsg(MNotFound));
          return INVALID_HANDLE_VALUE;
        }
        TagInfo *ti;
        if(ta->Count()==1)
        {
          ti=(*ta)[0];
        }else
        {
          ti=TagsMenu(ta);
        }
        if(ti)NavigateTo(ti);
        FreeTagsArray(ta);
      }break;
      case miUndo:
      {
        if(UndoArray.Count()==0)return INVALID_HANDLE_VALUE;
        /*char b[32];
        sprintf(b,"%d",ei.CurState);
        Msg(b);*/
        if(ei.CurState==ECSTATE_SAVED)
        {
          I.EditorControl(ECTL_QUIT,NULL);
          I.AdvControl(I.ModuleNumber,ACTL_COMMIT,(void*)-1);
        }
        SUndoInfo ui;
        UndoArray.Pop(ui);
        SetPos(ui.file,ui.line,ui.pos,ui.top,ui.left);
      }break;
      case miResetUndo:
      {
        UndoArray.Clean();
      }break;
      case miComplete:
      {
        EditorInfo ei;
        I.EditorControl(ECTL_GETINFO,&ei);
        String word=GetWord(1);
        if(word.Length()==0)return INVALID_HANDLE_VALUE;
        StrList lst;
        FindParts(ei.FileName,word,lst);
        if(lst.Count()==0)
        {
          Msg(MNothingFound);
          return INVALID_HANDLE_VALUE;
        }
        int res;
        if(lst.Count()>1)
        {
          MenuList ml;
          for(int i=0;i<lst.Count();i++)
          {
            ml<<MI(lst[i],i);
          }
          res=Menu(GetMsg(MSelectSymbol),ml,0,MF_FILTER|MF_SHOWCOUNT,(void*)word.Str());
          if(res==-1)return INVALID_HANDLE_VALUE;
        }else
        {
          res=0;
        }
        EditorGetString egs;
        egs.StringNumber=-1;
        I.EditorControl(ECTL_GETSTRING,&egs);
        while(isident(egs.StringText[ei.CurPos]))ei.CurPos++;
        EditorSetPosition esp;
        esp.CurLine=-1;
        esp.CurPos=ei.CurPos;
        esp.CurTabPos=-1;
        esp.TopScreenLine=-1;
        esp.LeftPos=-1;
        esp.Overtype=-1;
        I.EditorControl(ECTL_SETPOSITION,&esp);
        I.EditorControl(ECTL_INSERTTEXT,(void*)lst[res].Substr(word.Length()).Str());
      }break;
      case miBrowseFile:
      {
        EditorInfo ei;
        I.EditorControl(ECTL_GETINFO,&ei);
        PTagArray ta=FindFileSymbols(ei.FileName);
        if(!ta)
        {
          Msg(MNothingFound);
          return INVALID_HANDLE_VALUE;
        }
        TagInfo *ti=TagsMenu(ta);
        if(ti)NavigateTo(ti);
        FreeTagsArray(ta);
      }break;
      case miBrowseClass:
      {
#ifdef DEBUG
        //DebugBreak();
#endif
        String word=GetWord();
        if(word.Length()==0)
        {
          char buf[256];
          if(!I.InputBox(GetMsg(MBrowseClassTitle),GetMsg(MInputClassToBrowse),NULL,
                      "",buf,sizeof(buf),NULL,0))return INVALID_HANDLE_VALUE;
          word=buf;
        }
        EditorInfo ei;
        I.EditorControl(ECTL_GETINFO,&ei);
        PTagArray ta=FindClassSymbols(ei.FileName,word);
        if(!ta)
        {
          Msg(MNothingFound);
          return INVALID_HANDLE_VALUE;
        }
        TagInfo *ti=TagsMenu(ta);
        if(ti)NavigateTo(ti);
        FreeTagsArray(ta);
      }break;
    }
  }
  else
  {
    int load=OpenFrom==OPEN_COMMANDLINE;
    if(OpenFrom==OPEN_PLUGINSMENU)
    {
      MenuList ml;
      enum {miLoadTagsFile,miUnloadTagsFile,
            miUpdateTagsFile,miCreateTagsFile};
      ml<<MI(MLoadTagsFile,miLoadTagsFile)
        <<MI(MUnloadTagsFile,miUnloadTagsFile)
        <<MI(MCreateTagsFile,miCreateTagsFile)
        <<MI(MUpdateTagsFile,miUpdateTagsFile);
      int rc=Menu(GetMsg(MPlugin),ml,0);
      switch(rc)
      {
        case miLoadTagsFile:
        {
          load=1;
        }break;
        case miUnloadTagsFile:
        {
          ml.Clean();
          ml<<MI(MAll,0);
          StrList l;
          GetFiles(l);
          for(int i=0;i<l.Count();i++)
          {
            ml<<MI(l[i],i+1);
          }
          int rc=Menu(GetMsg(MUnloadTagsFile),ml,0);
          if(rc==-1)return INVALID_HANDLE_VALUE;
          UnloadTags(rc-1);
        }break;
        case miCreateTagsFile:
        {
          HANDLE hScreen=I.SaveScreen(0,0,-1,-1);
          const char *msg[]={GetMsg(MPlugin),GetMsg(MTagingCurrentDirectory)};
          I.Message(I.ModuleNumber,0,NULL,msg,2,0);
          int rc=TagCurrentDir();
          I.RestoreScreen(hScreen);
        }break;
        case miUpdateTagsFile:
        {
          HANDLE hScreen=I.SaveScreen(0,0,-1,-1);
          const char *msg[]={GetMsg(MPlugin),GetMsg(MUpdatingTagsFile)};
          StrList changed;
          PanelInfo pi;
          String file;
          I.Control(INVALID_HANDLE_VALUE,FCTL_GETPANELINFO,&pi);
          file=pi.CurDir;
          if(file[-1]!='\\')file+="\\";
          file+=pi.PanelItems[pi.CurrentItem].FindData.cFileName;
          I.Message(I.ModuleNumber,0,NULL,msg,2,0);
          if(!UpdateTagsFile(file))
          {
            I.RestoreScreen(hScreen);
            Msg(MUnableToUpdate);
            return INVALID_HANDLE_VALUE;
          }
          I.RestoreScreen(hScreen);
        }break;
      }
    }
    if(load)
    {
      //DebugBreak();
      PanelInfo pi;
      I.Control(INVALID_HANDLE_VALUE,FCTL_GETPANELINFO,&pi);
      tagfile=pi.CurDir;
      if(tagfile[-1]!='\\')tagfile+="\\";
      if(OpenFrom==OPEN_PLUGINSMENU)
      {
        tagfile+=pi.PanelItems[pi.CurrentItem].FindData.cFileName;
      }else
      if(OpenFrom==OPEN_COMMANDLINE)
      {
        char *cmd=(char*)Item;
        if(cmd[1]==':')
        {
          tagfile=cmd;
        }else
        {
          if(cmd[0]=='\\')
          {
            tagfile.Delete(2);
            tagfile+=cmd;
          }else
          {
            tagfile+=cmd;
          }
        }
      }
      int rc=Load(tagfile,"",true);
      if(rc>1)
      {
        Msg(GetMsg(rc));
        return INVALID_HANDLE_VALUE;
      }
      String msg;
      msg.Sprintf("%s:%d",GetMsg(MLoadOk),Count());
      Msg(msg);
    }
  }
  return INVALID_HANDLE_VALUE;
}
Exemple #22
0
ArgumentList ExtractArguments( const StringList& argv, argument_item_mode mode, ArgumentOptions options )
{
   bool noItems             = mode == ArgumentItemMode::NoItems;
   bool itemsAsFiles        = mode == ArgumentItemMode::AsFiles;
   bool itemsAsViews        = mode == ArgumentItemMode::AsViews;
   bool allowWildcards      = !noItems && options.IsFlagSet( ArgumentOption::AllowWildcards );
   bool noPreviews          = itemsAsViews && options.IsFlagSet( ArgumentOption::NoPreviews );
   bool recursiveDirSearch  = itemsAsFiles && allowWildcards && options.IsFlagSet( ArgumentOption::RecursiveDirSearch );
   bool recursiveSearchArgs = recursiveDirSearch && options.IsFlagSet( ArgumentOption::RecursiveSearchArgs );

   // This is the recursive search mode flag, controlled by --r[+|-]
   bool recursiveSearch = false;

   // The list of existing view identifiers, in case itemsAsViews = true.
   SortedStringList imageIds;

   // The list of extracted arguments
   ArgumentList arguments;

   for ( StringList::const_iterator i = argv.Begin(); i != argv.End(); ++i )
   {
      if ( i->StartsWith( '-' ) )
      {
         Argument arg( i->At( 1 ) );

         if ( recursiveSearchArgs && arg.Id() == s_recursiveSearchArg )
         {
            if ( arg.IsSwitch() )
               recursiveSearch = arg.SwitchState();
            else if ( arg.IsLiteral() )
               recursiveSearch = true;
            else
               arguments.Add( arg );
         }
         else
            arguments.Add( arg );
      }
      else
      {
         if ( noItems )
            throw ParseError( "Non-parametric arguments are not allowed", *i  );

         StringList items;

         if ( itemsAsFiles )
         {
            String fileName = *i;
            if ( fileName.StartsWith( '\"' ) )
               fileName.Delete( 0 );
            if ( fileName.EndsWith( '\"' ) )
               fileName.Delete( fileName.UpperBound() );

            fileName.Trim();
            if ( fileName.IsEmpty() )
               throw ParseError( "Empty path specification", *i );

            fileName = File::FullPath( fileName );

            if ( fileName.HasWildcards() )
            {
               if ( !allowWildcards )
                  throw ParseError( "Wildcards not allowed", fileName );

               items = SearchDirectory( fileName, recursiveSearch );
            }
            else
               items.Add( fileName );
         }
         else if ( itemsAsViews )
         {
            String viewId = *i;

            if ( !allowWildcards )
               if ( viewId.HasWildcards() )
                  throw ParseError( "Wildcards not allowed", viewId );

            size_type p = viewId.Find( "->" );

            if ( p != String::notFound )
            {
               if ( noPreviews )
                  throw ParseError( "Preview identifiers not allowed", viewId );

               String imageId = viewId.Left( p );
               if ( imageId.IsEmpty() )
                  throw ParseError( "Missing image identifier", viewId );

               String previewId = viewId.Substring( p+2 );
               if ( previewId.IsEmpty() )
                  throw ParseError( "Missing preview identifier", viewId );

               FindPreviews( items, imageId, previewId );
            }
            else
            {
               if ( viewId.HasWildcards() )
               {
                  Array<ImageWindow> W = ImageWindow::AllWindows();
                  for ( size_type i = 0; i < W.Length(); ++i )
                  {
                     View v = W[i].MainView();
                     if ( String( v.Id() ).WildMatch( viewId ) )
                        AddView( items, v );
                  }
               }
               else
               {
                  ImageWindow w = ImageWindow::WindowById( IsoString( viewId ) );
                  if ( w.IsNull() )
                     throw ParseError( "Image not found", viewId );
                  AddView( items, w.MainView() );
               }
            }
         }
         else
            items.Add( *i );

         Argument arg( *i, items );
         arguments.Add( arg );
      }
   }

   return arguments;
}
Exemple #23
0
void Autoload(const char* fn)
{
  String dir;
  if(fn)
  {
    dir=fn;
    int bs=dir.RIndex("\\");
    dir.Delete(bs);
  }
  else
  {
    char buf[512];
    GetCurrentDirectory(sizeof(buf),buf);
    dir=buf;
  }
  dir+="\\.tags-autoload";
  dir.ToLower();
  //DebugBreak();
  StrList sl;
  int isenv=0;
  bool mainaload=false;
  for(;;)
  {
    if(GetFileAttributes(dir)!=0xFFFFFFFF)
    {
      sl.LoadFromFile(dir);
      for(int i=0;i<sl.Count();i++)
      {
        String fn=sl[i];
        if(fn.Length()==0)continue;
        if(!(fn[0]=='\\' || fn[1]==':'))
        {
          int i=dir.RIndex("\\");
          if(i!=-1)
          {
            fn.Insert(0,dir.Substr(0,i+1));
          }
        }
        int z=dir.RIndex("\\");
        if(z==-1)z=dir.RIndex(":");
        Load(fn,isenv && z!=-1?"":dir.Substr(0,z+1),mainaload);
      }
    }
    if(!isenv)
    {
      int bs=dir.RIndex("\\");
      if(bs!=-1)
      {
        dir.Delete(bs);
        bs=dir.RIndex("\\");
        if(bs!=-1)
        {
          dir.Delete(bs+1);
          dir+=".tags-autoload";
        }else
        {
          isenv=1;
        }
      }else
      {
        isenv=1;
      }
      if(isenv==1)
      {
        if(config.autoload.Length()!=0)
        {
          dir=config.autoload;
          mainaload=true;
        }else
        {
          break;
        }
      }
    }else
    {
      break;
    }
  }
}
Exemple #24
0
//---------------------------------------------------------------------------
void __fastcall TfrmSignsReports::btnMakeClick(TObject *Sender)
{
    __int32 MinL = txtStartPosition->Text.ToInt();
    __int32 MaxL = txtEndPosition->Text.ToInt();

//*** создадм объекты и подключимся к DBF-ным файлкам
    TADOConnection *DbfConnection;
    TADOCommand *DbfCommand;
    AnsiString DBFFolderPath = ExtractFilePath(Application->ExeName) + "DBFFiles";
    ChDir(DBFFolderPath);

    try
    {
        DbfConnection = new TADOConnection(NULL);
        DbfCommand = new TADOCommand(NULL);
        DbfConnection->ConnectionString = "Driver={Microsoft Visual FoxPro Driver};UID=;SourceDB=" + DBFFolderPath + ";SourceType=DBF;Exclusive=No;Collate=MACHINE;OLE DB Services = 0";
        DbfConnection->LoginPrompt = false;
        DbfConnection->Connected = true;
        DbfCommand->Connection = DbfConnection;
    }
    catch(EOleException &OleError)
    {
        ShowMessage("Возникла ошибка при открытии DBF файлов. Код ошибки: " + AnsiString(OleError.ErrorCode) + ". Сообщение: " + OleError.Message + ".");
        return;
    }

    DeleteTempDBFFiles(DbfCommand, DBFFolderPath);

    String TemplateFile;
    String ReportFile;
    String OutFile;
    FDesignSource=NULL;
    if (DesignSourceList->ItemIndex>=0)
        FDesignSource=dynamic_cast<TDtaSource*>(DesignSourceList->Items->Objects[DesignSourceList->ItemIndex]);
    FExistSource=NULL;
    if (ExistSourceList->ItemIndex>=0)
        FExistSource=dynamic_cast<TDtaSource*>(ExistSourceList->Items->Objects[ExistSourceList->ItemIndex]);
    MakeHeaderFile(DbfCommand,MinL*100,MaxL*100);
    try
        {
        String DllName;
        String RepExt;
        if (groupFormat->ItemIndex==0)
            {
            DllName="GenRep.dll";
            RepExt=".rtf";
            }
        else
            {
            DllName="HTMLGenRep.dll";
            RepExt=".htm";
            }

        AnsiString DllPath = ExtractFilePath(Application->ExeName) + DllName;
        HINSTANCE RepDll=LoadLibrary(DllPath.c_str());
        if (RepDll)
            {
            ReportFunction GenRep=(ReportFunction)GetProcAddress(RepDll,"GenRep");
            for (int i=0;i<ReportsList->Items->Count;i++)
                if (ReportsList->Checked[i])
                    {
                    switch (i)
                        {
                        case 0: MakeRoadSignRegister(DbfCommand,MinL,MaxL);break;
                        case 1: MakeNewRoadSignRegister(DbfCommand, MinL, MaxL);break;
                        case 2: MakeRoadSignSpecification(DbfCommand, MinL, MaxL);break;
                        case 3: MakeRoadSignPlacement(DbfCommand, MinL, MaxL);break;
                        case 4: MakeRoadMarkRegister(DbfCommand,MinL,MaxL);break;
                        }
                    TemplateFile="\\ReportTemplate"+String(i+1)+RepExt;
                    ReportFile="\\Report"+String(i+1)+".dbf";
                    OutFile=txtFileName->Text;
                    int pos=OutFile.Pos(".");
                    if (pos)
                        OutFile.Delete(pos,1000);
                    OutFile+=String(i+1)+RepExt;
                    if (DeleteFileDialog(txtFilePath->Text,OutFile))
                        {
                        try
                            {
                            String WorkPath=ExtractFilePath(Application->ExeName) + "DBFFiles";
                            DbfConnection->Connected = false;
                            GenRep(String(WorkPath+TemplateFile).c_str(), WorkPath.c_str(), String(txtFilePath->Text+OutFile).c_str(), true , 1);
                            DbfConnection->Connected = true;
                            }
                        catch (...)
                            {
                            ShowMessage("Во время формирования произошла ошибка. Обратитесь к разработчикам.");
                            }
                        }
                    DeleteFile(DBFFolderPath + ReportFile);
                    }
            for (int i=0;i<TitulList->Items->Count;i++)
                {
                if (TitulList->Checked[i])
                    {
                    TemplateFile="\\TitulTemplate"+String(i+1)+RepExt;
                    OutFile=txtFileName->Text;
                    int pos=OutFile.Pos(".");
                    if (pos)
                        OutFile.Delete(pos,1000);
                    OutFile+=String(i+1)+"_t"+RepExt;
                    try
                        {
                        String WorkPath=ExtractFilePath(Application->ExeName) + "DBFFiles";
                        DbfConnection->Connected = false;
                        GenRep(String(WorkPath+TemplateFile).c_str(), WorkPath.c_str(), String(txtFilePath->Text+OutFile).c_str(), true , 1);
                        DbfConnection->Connected = true;
                        }
                    catch (...)
                        {
                        ShowMessage("Во время формирования произошла ошибка. Обратитесь к разработчикам.");
                        }
                    }
                }
            FreeLibrary(RepDll);
            }
        else
            ShowMessage("Не найдена библиотека"+DllName);
        }
    catch(...)
        {
        ShowMessage("Ошибка при формировании отчета");
        }
    DbfConnection->Connected = false;
    delete DbfCommand;
    delete DbfConnection;
}
Exemple #25
0
//----------------------------------------------------------------------
int __fastcall TCotTest::Sell(String Capital,String SecuID,double Price,int Num,String &HTXH)
{
  TBourse bourse;
  String  contractID;

  if(SecuID[1]=='H') { //上交所
    bourse     = bsSH;
    contractID = ++SHContractID;
  }
  else { //深交所
    bourse     = bsSZ;
    contractID = ++SZContractID;
  }

  SecuID.Delete(1,1);

/*  //修改库存
  TStockRec *stockRec = FindStock(Capital,bourse,SecuID);
  if(stockRec) {
    //if(stockRec->Available<Num) { return -1; } //不允许卖空

    stockRec->Available  = stockRec->Available - Num;
    stockRec->SellFreeze = stockRec->SellFreeze + Num;
  }
  else { //允许卖空
    stockRec = new TStockRec();
    memset(stockRec,0,sizeof(TStockRec));

    strcpy(stockRec->Capital,Capital.c_str());
    stockRec->Bourse = bourse;
    strcpy(stockRec->SecuID,SecuID.c_str());

    //T+0
    stockRec->Balance    = 0;         //余额
    stockRec->Available  = stockRec->Available - Num;  //可用数
    stockRec->BuyFreeze  = 0;       //买入冻结
    stockRec->SellFreeze = stockRec->SellFreeze + Num; //卖出冻结

    FStockRec->Add(stockRec);
  }           */

  //增加委托记录
  TCmsRec *cmsRec = new TCmsRec();
  memset(cmsRec,0,sizeof(TCmsRec));

  strcpy(cmsRec->Capital,Capital.c_str());
  cmsRec->Bourse = bourse; 
  strcpy(cmsRec->ContractID,contractID.c_str());
  strcpy(cmsRec->SecuID,SecuID.c_str());
  strcpy(cmsRec->Time,TRjlFunc::TimeShortToSimp(Now()).c_str());
  strcpy(cmsRec->Date,TRjlFunc::DateShortToSimp(Now()).c_str());
  cmsRec->Type      = 'S';
  cmsRec->State     = '0';
  cmsRec->CsnVol    = Num;
  cmsRec->TrdVol    = 0;                //成交数量
  cmsRec->CancelVol = 0;             //撤单数量
  cmsRec->CsnPrice  = Price;              //委托价格
  cmsRec->TrdPrice  = Price;              //成交价格

  FCmsRec->Add(cmsRec);

/*  //增加交易记录
  TBargainRec *bargainRec = new TBargainRec();
  memset(bargainRec,0,sizeof(TBargainRec));

  strcpy(bargainRec->Capital,Capital.c_str());
  bargainRec->Bourse = bourse;
  strcpy(bargainRec->ContractID,contractID.c_str());
  strcpy(bargainRec->SecuID,SecuID.c_str());
  strcpy(bargainRec->Time,TimeShortToSimp(Now()).c_str());               //成交时间
  strcpy(bargainRec->Date,DateShortToSimp(Now()).c_str());               //委托日期
  bargainRec->Type  = 'S';                  //买卖类别
  bargainRec->Vol   = Num;                   //成交数量
  bargainRec->Price = Price;                 //成交价格

  FBargainRec->Add(bargainRec);        */

  HTXH = contractID;
  Beep();
  return 0;
}