www.pudn.com > ChineseDisplay.rar > ChineseDisplay1Container.cpp


/* 
============================================================================ 
 Name        : CChineseDisplay1Container from ChineseDisplay1Container.h 
 Author      :  
 Version     : 
 Copyright   : Your copyright notice 
 Description : Container control implementation 
============================================================================ 
*/ 
 
// INCLUDE FILES 
#include "ChineseDisplay1Container.h" 
 
#include   // for example label control 
#include  
#include  
#include  
 
 
// ================= MEMBER FUNCTIONS ======================= 
 
// --------------------------------------------------------- 
// CChineseDisplay1Container::ConstructL(const TRect& aRect) 
// EPOC two phased constructor 
// --------------------------------------------------------- 
// 
void CChineseDisplay1Container::ConstructL(const TRect& aRect) 
    { 
    CreateWindowL(); 
 
	CCnvCharacterSetConverter* converter = CCnvCharacterSetConverter::NewLC(); 
	TBool chineseLanguageSupported = EFalse; 
	 
	if( converter->PrepareToConvertToOrFromL( KCharacterSetIdentifierGbk, 
		CEikonEnv::Static()->FsSession()) == CCnvCharacterSetConverter::EAvailable ) 
	{ 
		chineseLanguageSupported = ETrue; 
	} 
	else if ( converter->PrepareToConvertToOrFromL( KCharacterSetIdentifierGb2312, 
		CEikonEnv::Static()->FsSession() ) == CCnvCharacterSetConverter::EAvailable ) 
	{ 
		chineseLanguageSupported = ETrue; 
	} 
 
	//TText8  *str = (TText8*)"ŵ»ùÑÇ"; 
	TText8  *str = (TText8*)"c:\\ÎâÎÄÌÎ.txt"; 
	TInt state=CCnvCharacterSetConverter::KStateDefault; 
 
	TPtrC8 source( str ); 
	iInfoText = HBufC::NewL( source.Length() ); 
	TPtr16 ptr = iInfoText->Des(); 
 
	if( chineseLanguageSupported ) 
	{ 
		TRAP_IGNORE( converter->ConvertToUnicode( ptr, source, state ) ) 
		CAknInformationNote* note = new (ELeave) CAknInformationNote; 
		note->ExecuteLD(ptr); 
	} 
 
	CleanupStack::PopAndDestroy();  // converter 
 
	iFs.Connect(); 
	iFile.Open(iFs,ptr,EFileRead); 
	TInt aFileLength = 0; 
	iFile.Size(aFileLength); 
	if(aFileLength > 0) 
	{ 
		CAknInformationNote* note = new (ELeave) CAknInformationNote; 
		note->ExecuteLD(_L("Open OK")); 
	} 
 
    SetRect(aRect); 
    ActivateL(); 
    } 
 
// Destructor 
CChineseDisplay1Container::~CChineseDisplay1Container() 
    { 
 
    } 
 
// --------------------------------------------------------- 
// CChineseDisplay1Container::SizeChanged() 
// Called by framework when the view size is changed 
// --------------------------------------------------------- 
// 
void CChineseDisplay1Container::SizeChanged() 
    { 
    // TODO: Add here control resize code etc. 
 
    } 
 
// --------------------------------------------------------- 
// CChineseDisplay1Container::CountComponentControls() const 
// --------------------------------------------------------- 
// 
TInt CChineseDisplay1Container::CountComponentControls() const 
    { 
    return 0; // return nbr of controls inside this container 
    } 
 
// --------------------------------------------------------- 
// CChineseDisplay1Container::ComponentControl(TInt aIndex) const 
// --------------------------------------------------------- 
// 
CCoeControl* CChineseDisplay1Container::ComponentControl(TInt aIndex) const 
    { 
    return NULL; 
    } 
 
// --------------------------------------------------------- 
// CChineseDisplay1Container::Draw(const TRect& aRect) const 
// --------------------------------------------------------- 
// 
void CChineseDisplay1Container::Draw(const TRect& aRect) const 
    { 
    CWindowGc& gc = SystemGc(); 
    // TODO: Add your drawing code here 
    // example code... 
 
    } 
 
// --------------------------------------------------------- 
// CChineseDisplay1Container::HandleControlEventL( 
//     CCoeControl* aControl,TCoeEvent aEventType) 
// --------------------------------------------------------- 
// 
void CChineseDisplay1Container::HandleControlEventL( 
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/) 
    { 
    // TODO: Add your control event handler code here 
    }