Click here to Skip to main content
15,892,480 members
Articles / Mobile Apps / Windows Mobile

CHM Reader for Pocket PC 2003

Rate me:
Please Sign up or sign in to vote.
4.91/5 (65 votes)
29 Feb 2004CPOL3 min read 477.2K   960   87  
Allows the reading of CHM files on a Pocket PC2003.
//-------------------------------------------------------------------------------------------------
//
//	IBSL Technologies (c) 2000
//	BrainTree Development Ltd(c) 2000
//
//	Rennie Bowe
//	P J Tewkesbury
//
//-------------------------------------------------------------------------------------------------
//
//////////////////////////////////////////////////////////////////////
// StringEx.h
//

#ifndef __STRINGEX_H_
#define __STRINGEX_H_

#include "atlconv.h"

// To be added
// FormatSystemErrorMessage :- Takes Error code & converts it into a string.

class CStringEx : public CString
{
public:
	friend CString;

	CStringEx() : CString() {};
	CStringEx( const CString& stringSrc) : CString( stringSrc ){};
	CStringEx( const CStringEx& stringSrc) : CString( stringSrc ){};
	CStringEx( TCHAR ch, int nRepeat = 1 ) : CString( ch, nRepeat ){};
	CStringEx( LPCTSTR lpch, int nLength ) : CString( lpch, nLength ){};
	CStringEx( const unsigned char* psz ) : CString( psz ){};
	CStringEx( LPCWSTR lpsz ) : CString( lpsz ){};
	CStringEx( LPWSTR lpsz ) : CString( lpsz ){};

	CStringEx(DWORD SystemErrorCode);
	CStringEx(TCHAR *szFormat, ... );
	CStringEx(UINT nResID);				// Load string with Resource String

	void operator () (UINT nResID);		// CString Name; Name(nID);

#if 0
	CStringEx( STRRET strRet ) : CString()
	{			
		USES_CONVERSION;
		switch(strRet.uType)
		{
		case STRRET_CSTR:
			{				
				Format(_T("%s"),A2W(strRet.cStr));
			}
			break;

		case STRRET_WSTR:
			{	
				Format(_T("%s"),OLE2W(strRet.pOleStr));				
			}
			break;
		}	
	};d

#endif

	CStringEx(int Size) : CString()
	{			
		GetBufferSetLength(Size);		
	};	

public:
	CStringEx&	Append(CString Fmt,...);

	CStringEx&	Insert(int pos, LPCTSTR s);
	CStringEx&	Insert(int pos, TCHAR c);

	CStringEx&	Delete(int pos, int len);
	CStringEx&	Replace(int pos, int len, LPCTSTR s);
	CStringEx&	ReplaceAll(LPCTSTR s1, LPCTSTR s2);

	int			Find( TCHAR ch, int startpos = 0 ) const;
	int			Find( LPCTSTR lpszSub, int startpos = 0 ) const;
	int			FindNoCase( TCHAR ch, int startpos = 0 ) const;
	int			FindNoCase( LPCTSTR lpszSub, int startpos = 0 ) const;

	int			FindReplace( LPCTSTR lpszSub, LPCTSTR lpszReplaceWith, BOOL bGlobal = TRUE );
	int			FindReplaceNoCase( LPCTSTR lpszSub, LPCTSTR lpszReplaceWith, BOOL bGlobal = TRUE );

	int			ReverseFind( TCHAR ch ) { return CString::ReverseFind(ch);};
	int			ReverseFind( LPCTSTR lpszSub, int startpos = -1 );
	int			ReverseFindNoCase( TCHAR ch, int startpos = -1  );
	int			ReverseFindNoCase( LPCTSTR lpszSub, int startpos = -1 );

	CStringEx	GetField( LPCTSTR delim, int fieldnum);
	CStringEx	GetField( TCHAR delim, int fieldnum);
	int			GetFieldCount( LPCTSTR delim );
	int			GetFieldCount( TCHAR delim );

	CStringEx	GetDelimitedField( LPCTSTR delimStart, LPCTSTR delimEnd, int fieldnum = 0);	
	void		StripFormatChars();
	CStringEx	RemoveAll(TCHAR c) const;
	CStringEx	RemoveAll(const CStringEx& s) const;
	CStringEx	Remove(TCHAR c) const;
	CStringEx	Remove(const CStringEx& s) const;
	int			CountChar(TCHAR ch);
	void		RemoveExtraSpaces();

	CStringEx&	operator<<(int Value)
	{		
		Append(_T("%d"),Value);		
		return *this;
	};

	CStringEx&	operator<<(LPCTSTR Text)
	{		
		Append(_T("%s"),Text);
		return *this;
	};

	CStringEx&	operator<<(LPTSTR Text)
	{		
		Append(_T("%s"),Text);
		return *this;
	};

	CStringEx&	operator<<(DWORD Value)
	{		
		Append(_T("%d"),Value);
		return *this;
	};
	
#ifdef _UNICODE
	CStringEx&	operator<<(LPCSTR Text)
	{		
		USES_CONVERSION;
		Append(_T("%s"),A2T(Text));
		return *this;
	};

	CStringEx&	operator<<(LPSTR Text)
	{		
		USES_CONVERSION;
		Append(_T("%s"),A2T(Text));
		return *this;
	};
#endif
};

#endif
/////////////////////////////////////////////////////////////////////

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions