memohelpview.cpp

来自「一个比较完整的有关移动开发的例子 vc++6.0下编译通过」· C++ 代码 · 共 176 行

CPP
176
字号
/*
* ============================================================================
*  Name     : CMemoHelpView from CAknView
*  Part of  : MemoHelp
*  Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/

// INCLUDE FILES
#include <aknviewappui.h>
#include <avkon.hrh>
#include <FairyLand.rsg>
#include "FairyLand.hrh"
#include "MemoHelpView.h"
#include "MemoView.h"
#include "MemoHelpContainer.h" 
#include "FairyLandAppUi.h"

#include <FairyLand.mbg>	//for mbm
#include <akncontext.h>	//for CAknContextPane
#include <akntitle.h>	//for CAknTitlePane

#include <aknnotewrappers.h> 
// ================= MEMBER FUNCTIONS =======================

// C++ default constructor can NOT contain any code, that
// might leave.
//
CMemoHelpView* CMemoHelpView::NewL()
{
    CMemoHelpView* self = NewLC();
    CleanupStack::Pop(self);
    return self;
}

CMemoHelpView* CMemoHelpView::NewLC()
{
    CMemoHelpView* self = new (ELeave) CMemoHelpView;
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
}

CMemoHelpView::CMemoHelpView()
{
}

// EPOC default constructor can leave.
void CMemoHelpView::ConstructL()
{
    BaseConstructL(R_MEMO_HELP_VIEW);
	//BaseConstructL();
}

// Destructor
CMemoHelpView::~CMemoHelpView()
{
	
}

// ---------------------------------------------------------
// TUid CMemoHelpView::Id()
// Returns Id of the view.
// ---------------------------------------------------------
TUid CMemoHelpView::Id() const
{
    return KViewId8;
}


// ---------------------------------------------------------
// CMemoHelpView::HandleCommandL(TInt aCommand)
// Handles commands
// ---------------------------------------------------------
void CMemoHelpView::HandleCommandL(TInt aCommand)
{   
	switch(aCommand)
	{
		case EFairyLandCmdModifySave:
		{
			break;				
		}
		case EFairyLandBack:
		{ 
			AppUi()->ActivateLocalViewL(KViewId4);
			break;
		}
	default:
		{
			AppUi()->HandleCommandL(aCommand);
			break;
		}
	}
}
// ---------------------------------------------------------
// CMemoHelpView::HandleClientRectChange()
// Handles client rect change.
// ---------------------------------------------------------
void CMemoHelpView::HandleClientRectChange()
{
    if (iContainer)
	{
        iContainer->SetRect(ClientRect());
	}
}

// ---------------------------------------------------------
// CMemoHelpView::DoActivateL(...)
// Creates the Container class object.
// ---------------------------------------------------------
void CMemoHelpView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
							   TUid /*aCustomMessageId*/,
							   const TDesC8& /*aCustomMessage*/)
{
    iContainer = new (ELeave) CMemoHelpContainer;
    iContainer->SetMopParent(this);
	
	TRect rc;
	rc.SetRect(ClientRect().iTl, TSize(176, 144));
    iContainer->ConstructL(rc);
    AppUi()->AddToStackL(*this, iContainer);
	
	
	TBuf<KMaxPath> pathMbm;
#ifdef __WINS__
	pathMbm.Copy(_L("z:\\system\\apps\\FairyLand\\FairyLand.mbm"));
#else
	CFairyLandAppUi* pApp = (CFairyLandAppUi*)CEikonEnv::Static()->AppUi();
	pApp->GetAppPath(pathMbm);
	pathMbm.Append(_L("FairyLand.mbm"));
#endif
	
	CEikStatusPane* statusPane = StatusPane();
	
	//set icon
	CAknContextPane* contextPane = (CAknContextPane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidContext));
	CFbsBitmap* bitmap = iEikonEnv->CreateBitmapL(pathMbm, EMbmFairylandMemohelp);
	CFbsBitmap* bitmapMask = iEikonEnv->CreateBitmapL(pathMbm, EMbmFairylandMemohelp_mask);
	
	//contextPane->SetPicture(bitmap);
	contextPane->SetPicture(bitmap, bitmapMask);
	
	//set title
	// CAknTitlePane* titlePane = (CAknTitlePane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
	// titlePane->SetTextL(_L("Hello view!"));
	
	//load chinese words
	TBuf<32> sTmpTitle;
	CEikonEnv::Static()->ReadResource(sTmpTitle, R_QTN_MH_HELP);
	
	CAknTitlePane* titlePane = (CAknTitlePane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
	titlePane->SetTextL(sTmpTitle);
	
	//show
	// 	CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
	// 	informationNote->ExecuteLD(sTmpTitle);
}

// ---------------------------------------------------------
// CMemoHelpView::DoDeactivate()
// Deletes the Container class object.
// ---------------------------------------------------------
void CMemoHelpView::DoDeactivate()
{
    if (iContainer)
	{
        AppUi()->RemoveFromStack(iContainer);
		
		delete iContainer;
		iContainer = NULL;
	}
}

// End of File

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?