Beispiel #1
0
// Convert an integer into binary string format
void CIni::__ToBinaryString(UINT nNumber, LPTSTR lpBuffer, DWORD dwBufSize)
{
	if (dwBufSize == 0)
		return;
	
	DWORD dwIndex = 0;	
	do
	{
		lpBuffer[dwIndex++] = (nNumber % 2) ? _T('1') : _T('0');
		nNumber /= 2;
	} while (nNumber > 0 && dwIndex < dwBufSize);

	lpBuffer[dwIndex] = _T('\0');
	_tcsrev(lpBuffer);
}
Beispiel #2
0
//ÕûÐÔ±ä×Ö·û
LPCTSTR CGoldView::GetGlodString(LONG lGold, TCHAR szString[])
{
	LONG lTemp=(LONG)lGold; 
	if(lGold<0L) return szString;

	//´¦ÀíСÊýµã
	DWORD dwCharBit=0L;
	//lGold+=0.001;
	//if(lGold-lTemp>0)
	//{
	//	lTemp = (LONG)((lGold-lTemp)*100);

	//	bool bZero=(lTemp<10)?true:false;

	//	//ת»»×Ö·û
	//	do
	//	{
	//		szString[dwCharBit++]=(TCHAR)(lTemp%10+TEXT('0'));
	//		lTemp/=10;
	//	} while (lTemp>0L);

	//	//¼Ó0λ
	//	if(bZero)szString[dwCharBit++]=TEXT('0');

	//	szString[dwCharBit++]=TEXT('.');
	//}

	//ת»»×Ö·û
	lTemp = (LONG)lGold; 
	DWORD dwNumBit=0L;
	do
	{
		dwNumBit++;
		szString[dwCharBit++]=(TCHAR)(lTemp%10+TEXT('0'));
		if (dwNumBit%3==0) szString[dwCharBit++]=TEXT(',');
		lTemp/=10;
	} while (lTemp>0L);

	//µ÷Õû×Ö·û
	if (szString[dwCharBit-1]==TEXT(',')) szString[dwCharBit-1]=0;
	szString[dwCharBit]=0;

	//βͷ½»»»
	_tcsrev(szString);

	return szString;
}
Beispiel #3
0
//整性变字符
LPCTSTR CGameClientView::GetGlodString(LONG lGold, TCHAR szString[])
{
	LONG lTemp=(LONG)lGold; 
	if(lGold<0L) return szString;

	//处理小数点
	DWORD dwCharBit=0L;
	//lGold+=0.001;
	//if(lGold-lTemp>0)
	//{
	//	lTemp = (LONG)((lGold-lTemp)*100);

	//	bool bZero=(lTemp<10)?true:false;

	//	//转换字符
	//	do
	//	{
	//		szString[dwCharBit++]=(TCHAR)(lTemp%10+TEXT('0'));
	//		lTemp/=10;
	//	} while (lTemp>0L);

	//	//加0位
	//	if(bZero)szString[dwCharBit++]=TEXT('0');

	//	szString[dwCharBit++]=TEXT('.');
	//}

	//转换字符
	lTemp = (LONG)lGold; 
	DWORD dwNumBit=0L;
	do
	{
		dwNumBit++;
		szString[dwCharBit++]=(TCHAR)(lTemp%10+TEXT('0'));
		if (dwNumBit%3==0) szString[dwCharBit++]=TEXT(',');
		lTemp/=10;
	} while (lTemp>0L);

	//调整字符
	if (szString[dwCharBit-1]==TEXT(',')) szString[dwCharBit-1]=0;
	szString[dwCharBit]=0;

	//尾头交换
	_tcsrev(szString);

	return szString;
}
Beispiel #4
0
//ÕûÐÔ±ä×Ö·û
LPCTSTR CGoldView::GetGlodString(LONG lGold, TCHAR szString[])
{
	//ת»»×Ö·û
	DWORD dwNumBit=0L,dwCharBit=0L;
	do
	{
		dwNumBit++;
		szString[dwCharBit++]=(TCHAR)(lGold%10+TEXT('0'));
		//if (dwNumBit%3==0) szString[dwCharBit++]=TEXT(',');
		lGold/=10;
	} while (lGold!=0L);

	//µ÷Õû×Ö·û
	if (szString[dwCharBit-1]==TEXT(',')) szString[dwCharBit-1]=0;
	szString[dwCharBit]=0;
	_tcsrev(szString);

	return szString;
}
Beispiel #5
0
//--------------------------------------------------------------------
// Format a number according to a pattern [xxSEPARATORxxxSEPARATORxxxSEPARATORxxx]:
//    1000000, '.', 3  --> "1.000.000"                 ^-- GroupLength=3
//    1000000, '-', 2  --> "1-00-00-00"
// 
// Build the string from the end and reverse it when it is finished
// Here is the state of the two variables at the end of each iteration
//    dwNumber    szBuffer
//      1000000           
//      100000           0
//       10000          00
//        1000        000.
//         100       000.0
//          10      000.00
//           1    000.000.
//           0   000.000.1
//
void FormatNumber(DWORD dwNumber, LPTSTR szNumber, TCHAR cSeparator, DWORD GroupLength)
{
   LPTSTR   pFirst      = szNumber;
   LPTSTR   pChar       = pFirst;
   DWORD    DigitCount  = 0;
   //DWORD    wNumChars   = 0;

   while (dwNumber > 0)
   {
   // extract the last digit
      wsprintf(pChar, _T("%u"), dwNumber % 10);

   // next character in the buffer
      pChar++;

   // next digit in the current group
      DigitCount++;

   // eat the last digit
      dwNumber = dwNumber / 10;

   // add the separator if needed
      if ((DigitCount == GroupLength) && (dwNumber > 0))
      {
         *pChar = cSeparator;

      // begin a new digit group after the separator
         DigitCount = 0;
         pChar++;
      }
   };

// close the string
   *pChar = _T('\0');

// reverse it
   _tcsrev(pFirst);
}
Beispiel #6
0
//+----------------------------------------------------------------------
//
//  Function:   AlphaNumber( n, szBuffer, chBase )
//
//              A helper function for NumberToRoman(Upper|Lower).
//              Pass in either 'a' or 'A' in chBase to get an
//              'alphabetic' number of n.
//
//              Zero are represented as @. (a hack.)
//              Negative numbers are represented as would decimal
//              numbers, ie with a preceeding minus sign (another hack.)
//
//  Returns:    Returns an 'alphabetic' number in szBuffer.
//
//-----------------------------------------------------------------------
static void AlphaNumber(LONG n, TCHAR* szBuffer, TCHAR chBase)
{
    TCHAR* p = szBuffer;

    if(n)
    {
        LONG m = abs(n);

        // It is easier to compute from the least-significant 'digit',
        // so we generate the string backwards, and then reverse it
        // at the end.
        *p++ = '.';

        while(m)
        {
            m--;
            *p++ = (TCHAR)(chBase + (m%26));
            m /= 26;        
        }

        if(n < 0)
        {
            // A nerdly hack to represent negative numbers.
            *p++ = _T('-');
        }

        *p = _T('\0');

        _tcsrev(szBuffer);
    }
    else
    {
        // A nerdly hack to represent zero.
        *p++ = _T('@');
        *p++ = _T('.');
        *p++ = _T('\0');
    }
}
//取得列的名称,比如27->AA
TCHAR *Illusion_ExcelFile::column_name(long column_no)
{
    static TCHAR column_name[64];
    size_t str_len = 0;

    while (column_no > 0)
    {
        int num_data = column_no % 26;
        column_no /= 26;
        if (num_data == 0)
        {
            num_data = 26;
            column_no--;
        }
        //不知道这个对不,
        column_name[str_len] = (TCHAR)((num_data - 1) + _T('A') );
        str_len ++;
    }
    column_name[str_len] = '\0';
    //反转
    _tcsrev(column_name);

    return column_name;
}
Beispiel #8
0
void CString::MakeReverse()
{
	CopyBeforeWrite();
	_tcsrev(m_pchData);
}
void CCOMString::MakeReverse()
{
	_tcsrev(m_pszString);
}
Beispiel #10
0
int32 CBrainMemory::RetrieveText(int64 MeaningID,tstring& Text,bool Nest){

	int64 CurrentRoomValue,RoomType; 
    int64  CurrentID = MeaningID;

	//首先得到意义空间的信息
	if(!GetRoomInfo(MeaningID,CurrentRoomValue,RoomType))return 0;

	if(!Nest){
		//首次外部调用时检查MeaningID代表记忆是否为可读的文字信息,嵌套调用则忽略
		if(UnReadable(CurrentRoomValue))return 0;
	}

	//向上漫游,找到父空间空间的ID和逻辑明文,得记忆的形ID
    CppSQLite3Query Result = LBrainQuery("*",CurrentRoomValue,LB_CHILD_ID,CurrentID);
	if(Result.eof())return 0;
    
	CurrentID = Result.getInt64Field(0);
  	if(CurrentID == ROOT_SPACE)return 0;
	CurrentRoomValue = Result.getInt64Field(1);  //总是其他空间的空间识别ID
	
    
	//如果是字符,则可以确定所取文本应该是token
	int ch = IDToChar(CurrentRoomValue);
    if(isascii(ch)){
		TCHAR buf[100]; //暂存token,一个单词99字符应该足够了
		int p = 0;
		buf[p++] = ch;
        
		//继续向上漫游,应该全部都是字符
		for(;;){
			//根据本空间的ID和逻辑明文,找到父空间空间的ID和逻辑明文,
			CppSQLite3Query Result = LBrainQuery("*",CurrentRoomValue,LB_CHILD_ID,CurrentID);
			if(Result.eof())return 0;
			
			CurrentID = Result.getInt64Field(0);
			//如果得到的空间ID为根空间,则表示找到顶了。
			if(CurrentID == ROOT_SPACE){
				buf[p]='\0';
				_tcsrev(buf);
				
				Text = buf;
				//如果是形容词则加上引号
				if(RoomType == MEMORY_REFERENCE){
					Text.insert(Text.begin(),1,_T('\"'));
					Text+=_T('\"');
				}
				return 1;  //表示得到一个token
			}
			CurrentRoomValue = Result.getInt64Field(1);   
			
			if(p<100) buf[p++]  = IDToChar(CurrentRoomValue);
		}
	}
		
    //不是字符,则需要嵌套处理,然后根据返回值添加标点符号
	int32 n = 0;

	vector<tstring> StrList;
	for(;;){
		
		tstring s;
		n = RetrieveText(CurrentRoomValue,s,false);
		
		StrList.push_back(s);
		
		//继续向上漫游,根据本空间的ID和逻辑明文,找到父空间空间的ID和逻辑明文,
		CppSQLite3Query Result = LBrainQuery("*",CurrentRoomValue,LB_CHILD_ID,CurrentID);
		if(Result.eof())return 0;
		
		CurrentID = Result.getInt64Field(0);
		//如果得到的空间ID为根空间,则表示找到顶了。
		if(CurrentID == ROOT_SPACE)break;
		
		CurrentRoomValue = Result.getInt64Field(1);   		
	}

	TCHAR flag=_T(' ');
	if(n==1){ //子句,token之间应该有空格
			flag  = _T(' ');
	}
	else if(n==2){ //句子,子句之间有逗号
			flag = _T(',');
	}
	else if(n ==3){ //段落,句子之间有句号
			flag = _T('.');
	} 
    else if(n== 4){//文本,段落之间要分行
            flag = _T('\n');			
	}
	assert(n<5);
	

	vector<tstring>::reverse_iterator It = StrList.rbegin();
	while(It != StrList.rend()){
		Text += *It;
		if(Text.size()){ 
			TCHAR& ch =  Text[Text.size()-1];
            if(!ispunct(ch)){
				Text += flag;
			}else if(Text.size()>2) {
				ch = Text[Text.size()-2];
				if (isspace(ch))
				{
					Text.erase(Text.size()-2,1);
				}
			}
		}
		It++;
	}	     
	
	if(RoomType == MEMORY_REFERENCE)
	{
		Text.insert(Text.begin(),1,_T('\"'));
		Text+='\"';
		assert(n==1 || n==0); //引用被看作是一个token,应该只出现在子句里
	    return 1;
	}
	return  ++n;
} 
Beispiel #11
0
BOOL SGThumbs::LoadThumbnailIntoSlot(UINT32 Slot, UINT32 ID, PathName *ActualFile)
{
/*	String_256 P(ActualFile->GetPath());
	ERROR3_PF(("Actual file: %s", (TCHAR *)P));*/

	PORTNOTETRACE("dialog","SGThumbs::LoadThumbnailIntoSlot - do nothing");
#ifndef EXCLUDE_FROM_XARALX
	if(Directory == NULL || ActualFile == NULL)
	{
		ERROR3("SGThumbs::LoadThumbnailIntoSlot Directory == NULL || ActualFile == NULL");
		return FALSE;
	}

	// Return any memory that would otherwise go down the toilet, and block the drains
	if(Thumbnails[Slot].Valid && Thumbnails[Slot].buffer)
	{
		delete Thumbnails[Slot].buffer;
		Thumbnails[Slot].buffer=NULL;
	}

	// Just in case we jump out in a state of unhappy rampantness
	Thumbnails[Slot].Valid = FALSE;

	BOOL CheckFilenameBmp = TRUE;
	BOOL CheckFilenamePng = TRUE;
	BOOL CheckFilenameReversed = TRUE;
	BOOL CheckFilenameTif = TRUE;
	BOOL CheckEncodedBmp = TRUE;
	BOOL CheckEncodedPng = TRUE;
	BOOL CheckEncodedTif = TRUE;

	BOOL UseActualFile = FALSE;

	BOOL IsRIFFTypeFile = FALSE;
	BOOL IsPCDTypeFile = FALSE;

	// Get lowercase filetype
	String_256 Type(ActualFile->GetType());
	Type.toLower();

	// Bodge to speed galleries up for art files - doesn't check or use external previews
	if( (Type.Sub((String_8)"art") != -1) ||
		(Type.Sub((String_8)"xar") != -1) )
	{
		UseActualFile = TRUE;
		CheckFilenameReversed = FALSE;
	}
	else if ( (Type.Sub((String_8)"web") != -1) ||
			  (Type.Sub((String_8)"cxw") != -1) ||
			  (Type.Sub((String_8)"cxn") != -1) )
	{
		// Check for our new version 2 native and web files
		//WEBSTER-Martin-23/01/97
		//force us to look for previews
		UseActualFile = TRUE;
		CheckFilenameReversed = FALSE;
	}
	else if ( (Type.Sub((String_8)"cdr") != -1) ||
			  (Type.Sub((String_8)"cmx") != -1) )
	{
		IsRIFFTypeFile = TRUE;
		UseActualFile = TRUE;
		CheckFilenameReversed = FALSE;
	}
	else if( Type.Sub((String_8)"ttf") != -1 ||
			 Type.Sub((String_8)"pfb") != -1)
	{
		// Bodge to speed font gallery up a bit - only checks encoded bmp file thumbnails
		CheckFilenamePng = 
			CheckFilenameBmp = 
			CheckFilenameReversed = 
			CheckFilenameTif = 
			CheckEncodedTif = FALSE;

		CheckEncodedBmp = TRUE;
		CheckEncodedPng = TRUE;

		UseActualFile = FALSE;
	}
	else if( Type.Sub((String_8)"pcd") != -1 )
	{
		IsPCDTypeFile = TRUE;
		UseActualFile = TRUE;
	}

	// Read the file into the bm yet ?
	BOOL Found = FALSE;
	CWxBitmap *pCWxBitmap = NULL;
	BOOL ReadOK = FALSE;

	// Don't error, just set exceptions... (changed 2/10/2000 by Jonathan to use
	// errors rather than exceptions to avoid a pile of messy first-change exceptions
	// when fills were not being found)
    CCDiskFile File(1024, FALSE, FALSE);

	// internal preview
	if(UseActualFile)
	{
		// Open file and check if it exists at the same time
		Found = OpenThumbnailFile( &File, *ActualFile );

		if(Found)
		{

			// Create an OILy bitmap object
			pCWxBitmap = new CWxBitmap;
			if (pCWxBitmap == NULL)
			{
				ERROR3("Problem creating thumbnail bitmap");
				return FALSE;
			}
		
			// files with internal preveiws
			// WEBSTER-Martin-08/01/97
			if(IsRIFFTypeFile)
			{
#ifndef WEBSTER //WEBSTER-Martin-21/01/97
				if ( AccusoftFilters::GetVersionNumber() > 0)
				{
					// search to see if we can find a thumbnail in this file
					if ( CMXImportFilter::SkipToPreviewBitmap(&File) )
					{
						TRACEUSER( "Martin", _T("Accusoft read RIFF preview\n"));
						ReadOK = AccusoftFilters::ReadFromFile( &File, &pCWxBitmap->BMInfo, &pCWxBitmap->BMBytes, TRUE, NULL, NULL, TRUE );
					}
				}
				else
				{
					TRACEUSER( "Martin", _T("Accusoft filter not loaded\n"));
					ReadOK = FALSE;
				}
#endif //WEBSTER
			}
			else if(IsPCDTypeFile)
			{
#ifndef WEBSTER //WEBSTER-Martin-21/01/97
				if ( AccusoftFilters::GetVersionNumber() > 0)
				{
					TRACEUSER( "Martin", _T("Accusoft read PCD preview\n"));
					// Use the tiny preview... (we're a friend of AccusoftFilters by the way)
					AccusoftFilters::ImagePageToRead = 2;
					ReadOK = AccusoftFilters::ReadFromFile( &File, &pCWxBitmap->BMInfo, &pCWxBitmap->BMBytes, TRUE, NULL, NULL, TRUE );
				}
				else
				{
					TRACEUSER( "Martin", _T("Accusoft filter not loaded\n"));
					ReadOK = FALSE;
				}
#endif //WEBSTER
			}
			else // new native file
			{
				// First, check that we have a CX2/XaraX format file, and
				// try to extract its preview bitmap at the same time.
				BOOL IsNewFormat = FALSE;
				UINT32 FilterId = FILTERID_NONE;
				if (BaseCamelotFilter::SkipToPreviewBitmap(&File, &IsNewFormat, &FilterId))
				{
					// Get the preview!
					if (FilterId != FILTERID_NONE)
					{
						Filter* pFilter = Filter::FindFilterFromID(FilterId);
						if (pFilter != NULL)
						{
							ERROR3IF( !pFilter->IS_KIND_OF(BaseBitmapFilter), "Preview filter is not a BaseBitmapFilter\n" );
							ReadOK = ((BaseBitmapFilter *)pFilter)->ReadFromFile( pCWxBitmap, NULL, &File, FALSE );
						}
					}
					
					// Couldn't find a preview bitmap, so we'll make a note to
					// check for an external preview file instead.
					else
					{
						UseActualFile	= FALSE;
						Found			= FALSE;
						File.close();

						delete pCWxBitmap;
						pCWxBitmap = NULL;
					}
				}

				// SkipToPreviewBitmap failed, so we'll assume that it's an old-format file.
				// In that case, we must try to load in its TIFF preview.
				else
				{
					if (AccusoftFilters::GetVersionNumber() > 0)
						ReadOK = AccusoftFilters::ReadFromFile( &File, &pCWxBitmap->BMInfo, &pCWxBitmap->BMBytes, TRUE );
					else
						ReadOK = FALSE;
				}
			}
		}
		else
		{
			TRACEUSER( "Martin", _T("Failed to find original file %s\n"), (const TCHAR *)ActualFile->GetFileName(TRUE));
		 	Error::ClearError();
			// didn't find original so look for external preview
			UseActualFile = FALSE;
		}
	}

	//we test this again cos we can change our mind about UseActualFile
	if(!UseActualFile)
	{

#ifdef THUMB_CHECK_FILENAME_WITH_PNG
		if(CheckFilenamePng && !Found)
		{
			// Check for c:\clipart\sublib\xarainfo\picture.png files (from picture.tif or whatever)
			String_256 FAP;
		
			FAP = Directory->GetPath(TRUE);
			FAP += ActualFile->GetFileName(FALSE);
			FAP += TEXT(".png");

// 			ERROR3_PF(("Looking for: %s", (TCHAR *)FAP));

			PathName ThumbPath(FAP);

			// <Filename>.png
			Found = OpenThumbnailFile( &File, ThumbPath );

			if(Found)
			{
				// Create an OILy bitmap object
				pCWxBitmap = new CWxBitmap;
				if (pCWxBitmap == NULL)
				{
					ERROR3("Problem creating bitmap");
					return FALSE;
				}

				// PNGs
				INT32 TransColour;	// ignore value returned into this
				ReadOK = PNGUtil::ReadFromFile( &File, &pCWxBitmap->BMInfo, &pCWxBitmap->BMBytes, &TransColour );
			}
		}
#endif

#ifdef THUMB_CHECK_FILENAME_WITH_BMP
		if(CheckFilenameBmp && !Found)
		{
			// Check for c:\clipart\sublib\xarainfo\picture.bmp files (from picture.tif or whatever)
			String_256 FAP;
		
			FAP = Directory->GetPath(TRUE);
			FAP += ActualFile->GetFileName(FALSE);
			FAP += TEXT(".bmp");

			PathName ThumbPath(FAP);

			// <Filename>.bmp
			Found = OpenThumbnailFile( &File, ThumbPath );

			if(Found)
			{
				// Create an OILy bitmap object
				pCWxBitmap = new CWxBitmap;
				if (pCWxBitmap == NULL)
				{
					ERROR3("Problem creating bitmap");
					return FALSE;
				}

				// BMPs
				ReadOK = DIBUtil::ReadFromFile( &File, &pCWxBitmap->BMInfo, &pCWxBitmap->BMBytes, TRUE );

				if ( !ReadOK )
				{
					delete pCWxBitmap;
					pCWxBitmap = NULL;
					Found = FALSE;
					Error::ClearError();
		
					// Er, well, it might be monochrome, so use accusoft then...
					// <Filename>.bmp
					File.close();
					Found = OpenThumbnailFile( &File, ThumbPath );
				}
			}
		}
#endif

#ifdef THUMB_CHECK_REVERSED_FILENAME
		if( CheckFilenameReversed && !Found )
		{
			// Check for c:\clipart\sublib\xarainfo\picture.fit file from picture.tif, etc...
			String_256 FAP;
		
			FAP = Directory->GetPath(TRUE);
			FAP += ActualFile->GetFileName(FALSE);
			String_256 Ending(ActualFile->GetType());
			_tcsrev((TCHAR *)Ending);		// reverse the bmp to pmb
			FAP += TEXT(".");
			FAP += (TCHAR *)Ending;

			//ERROR3_PF(("Looking for: %s", (TCHAR *)FAP));

			PathName ThumbPath(FAP);

			// <Filename>.fit <Filename>.pmb etc.
			Found = OpenThumbnailFile( &File, ThumbPath );

			if(Found)
			{
				// Create an OILy bitmap object
				pCWxBitmap = new CWxBitmap;
				if (pCWxBitmap == NULL)
				{
					return FALSE;
				}

				// BMPs
				ReadOK = DIBUtil::ReadFromFile( &File, &pCWxBitmap->BMInfo, &pCWxBitmap->BMBytes, TRUE );

				if ( ReadOK )
				{
					// Set the name to the filename (without the .bmp)	
					String_256 Name(ActualFile->GetFileName(FALSE));
					pCWxBitmap->SetName(Name);
				}
				else
				{
					delete pCWxBitmap;
					pCWxBitmap = NULL;
					Found = FALSE;
					Error::ClearError();

					// Er, well, it might be monochrome, so use accusoft then...
					// <Filename>.pmb
					File.close();
					Found = OpenThumbnailFile( &File, ThumbPath );
				}
			}
		}

#endif

#ifdef THUMB_CHECK_FILENAME_WITH_TIF
		if( CheckFilenameTif && !Found )
		{
			// Check for normal tiff thumbnail file of the form <Filename>.TIF
			// Construct a full pathname for actual filename with a tif extension
			String_256 FullThumbnailPath(Directory->GetPath(TRUE));
			FullThumbnailPath += ActualFile->GetFileName(FALSE);
			FullThumbnailPath += TEXT(".tif");

			TRACEUSER( "Richard", _T("Filename: %s\n"), (TCHAR *)FullThumbnailPath);

			PathName FileAndPath(FullThumbnailPath);

			// <Filename>.tif
			Found = OpenThumbnailFile( &File, FileAndPath );
		}
#endif

		// Work out the encoded thumbnail name for use in multiple places below
		String_256 FullThumbnailPathWithoutExtension;
		if(!Found)
		{
			String_8 EncodedThumbnail;
	
			// Find encoded thumbnail path
			if(!GetThumbnailName(ID, &EncodedThumbnail))
				return FALSE;

			// Construct a full pathname for the encoded thumbnail file
			FullThumbnailPathWithoutExtension =  Directory->GetPath(TRUE);
			FullThumbnailPathWithoutExtension += EncodedThumbnail;
		}


#ifdef THUMB_CHECKBMPS
		if(CheckEncodedBmp && !Found)
		{
			// Check for standard bitmap thumbnail file of the form X00000X.BMP
			// And load it using internal Xara code rather than Accusoft

			// Construct a full pathname for the encoded thumbnail file
			String_256 FullThumbnailPath(FullThumbnailPathWithoutExtension);
			FullThumbnailPath += TEXT(".bmp");
			TRACEUSER( "Richard", _T("Filename: %s\n"), (TCHAR *)FullThumbnailPath);

			PathName FileAndPath(FullThumbnailPath);

			// <Filename>.bmp
			Found = OpenThumbnailFile( &File, FileAndPath );

			if(Found)
			{
				// Create an OILy bitmap object
				pCWxBitmap = new CWxBitmap;
				if (pCWxBitmap == NULL)
				{
					ERROR3("Problem creating bitmap");
					return FALSE;
				}

				// Set the name to the thumbID name (without the .bmp)	
				String_256 Name(FileAndPath.GetFileName(FALSE));
				pCWxBitmap->SetName(Name);

				// BMPs
				ReadOK = DIBUtil::ReadFromFile( &File, &pCWxBitmap->BMInfo, &pCWxBitmap->BMBytes, TRUE );

				if(!ReadOK)
				{
					delete pCWxBitmap;
					pCWxBitmap = NULL;
					Found = FALSE;
					Error::ClearError();

					// Er, well, it might be monochrome, so use accusoft then...
					// <Filename>.bmp
					File.close();
					Found = OpenThumbnailFile( &File, FileAndPath );
				}
			}
		}
#endif

#ifdef THUMB_CHECKPNGS
		if(CheckEncodedPng && !Found)
		{
			// Check for downloaded thumbnail file of the form X00000X.PNG
			// And load it using internal Xara code rather than Accusoft

			// Construct a full pathname for the encoded thumbnail file
			String_256 FullThumbnailPath(FullThumbnailPathWithoutExtension);
			FullThumbnailPath += TEXT(".png");
			TRACEUSER( "Richard", _T("Filename: %s\n"), (TCHAR *)FullThumbnailPath);

			PathName FileAndPath(FullThumbnailPath);

			// <Filename>.png
			Found = OpenThumbnailFile( &File, FileAndPath );

			if(Found)
			{
				// Create an OILy bitmap object
				pCWxBitmap = new CWxBitmap;
				if (pCWxBitmap == NULL)
				{
					ERROR3("Problem creating bitmap");
					return FALSE;
				}

				// Set the name to the thumbID name (without the .png)	
				String_256 Name(FileAndPath.GetFileName(FALSE));
				pCWxBitmap->SetName(Name);

				// PNGs
				INT32 TransColour;	// ignore value returned into this
				ReadOK = PNGUtil::ReadFromFile( &File, &pCWxBitmap->BMInfo, &pCWxBitmap->BMBytes, &TransColour );
			}
		}
#endif

#ifdef THUMB_CHECKTIFS
		if(CheckEncodedTif && !Found)
		{
			// Check for encoded tiff thumbnail file of the form X00000X.TIF

			// Construct a full pathname for the encoded thumbnail file
			String_256 FullThumbnailPath(FullThumbnailPathWithoutExtension);
			FullThumbnailPath += TEXT(".tif");
			TRACEUSER( "Richard", _T("Filename: %s\n"), (TCHAR *)FullThumbnailPath);

			PathName FileAndPath(FullThumbnailPath);

			// X00000X.tif
			Found = OpenThumbnailFile( &File, FileAndPath );
		}
#endif

#ifndef WEBSTER //WEBSTER-Martin-21/01/97
		if ( Found && !ReadOK )
		{
			// this is Accusoft's last chance
			if ( AccusoftFilters::GetVersionNumber() > 0)
			{
				ReadOK = AccusoftFilters::ReadFromFile( &File, &pCWxBitmap->BMInfo, &pCWxBitmap->BMBytes, TRUE, NULL, NULL, TRUE );
			}
			else
			{
				TRACEUSER( "Martin", _T("Accusoft filter not loaded\n"));
				ReadOK = FALSE;
			}
		}
#endif //WEBSTER
	}

	if(!ReadOK || pCWxBitmap == NULL)
	{
		// Problems somewhere above
		TRACEUSER( "Richard", _T("Can't find/load thumbnail"));

		// We don't want error boxes popping up every time we can't find a thumbnail
		Error::ClearError();

		if(pCWxBitmap != NULL)
		{
			delete pCWxBitmap;
			pCWxBitmap = NULL;
		}
		return FALSE;
	}

	// Set the name to the file's name (without the .art .xar etc)	
	String_256 Name(ActualFile->GetFileName(FALSE));
	pCWxBitmap->SetName(Name);

	// create the kernel bitmap, attaching the OILy bitmap to it
	Thumbnails[Slot].buffer = new KernelBitmap(pCWxBitmap, TRUE);
	if (Thumbnails[Slot].buffer == NULL)
	{
		ERROR3("Problem creating kernel bitmap for thumbnail");
		delete pCWxBitmap;
		pCWxBitmap = NULL;
		return FALSE;
	}

	// Set the rest of the entries to sensible values
	Thumbnails[Slot].Valid = TRUE;
	Thumbnails[Slot].ID = ID;
	Thumbnails[Slot].Usage = 0;
	Thumbnails[Slot].Size = ThumbnailsSize;

	Error::ClearError();
#endif
	// Well, looks like we got ourselves a thumbnail...
	return TRUE;
}