⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bookoperationview.cpp

📁 一个比较完整的有关移动开发的例子 vc++6.0下编译通过
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CBookOperationView from CAknView
*  Part of  : BookOperation
*  Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/

// INCLUDE FILES
#include <aknviewappui.h>
#include <avkon.hrh>

#include <FairyLand.rsg>
#include <FairyLand.mbg>	//for mbm
#include "FairyLand.hrh"
#include "FairyLandAppUi.h"
#include "BookOperationView.h"
#include "BookOperationContainer.h" 
#include "BookListView.h"

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

#include <aknnotewrappers.h> 
#include <eikmenup.h>		//for CEikMenuPane
#include <eikmenub.h>	// for CEikMenuBar

// ================= MEMBER BookOperationS =======================

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

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

CBookOperationView::CBookOperationView(MObserve* pObserve)
{
	m_pObserve = pObserve;    
}

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

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

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

// ---------------------------------------------------------
// CBookOperationView::HandleCommandL(TInt aCommand)
// Handles commands
// ---------------------------------------------------------
void CBookOperationView::HandleCommandL(TInt aCommand)
{  
	switch(aCommand)
	{
	case EFairyLandCmdConfirm:
		{
            TBuf<32>  strFamily;
			TBuf<32>  strGiven;
			TBuf<32>  strMobile;
			
			iContainer->GetLoginName(strFamily,strGiven,strMobile);
			if(strFamily.Length()==0)
			{
				
				TBuf<32> LogonUserWarn;
				CEikonEnv::Static()->ReadResource(LogonUserWarn, R_QTN_MH_FAMILY_NAME_EMPTY);
				//显示读取的文件内容
				CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
				informationNote->ExecuteLD(LogonUserWarn);
				
			}
			else if(strGiven.Length()==0)
			{
				TBuf<32> LogonUserWarn;
				CEikonEnv::Static()->ReadResource(LogonUserWarn, R_QTN_MH_GIVE_NAME_EMPTY);
				//显示读取的文件内容
				CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
				informationNote->ExecuteLD(LogonUserWarn);
			}
			else if(strMobile.Length()==0)
			{
				TBuf<32> LogonUserWarn;
				CEikonEnv::Static()->ReadResource(LogonUserWarn, R_QTN_MH_MOBLILE_EMPTY);
				//显示读取的文件内容
				CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
				informationNote->ExecuteLD(LogonUserWarn);
			}
			else
			{
                m_pObserve->SendData(strFamily,strGiven,strMobile);
				AppUi()->ActivateLocalViewL(KViewId10);
			}	
		}
		break;
	case EFairyLandCmdBack:
		{
			AppUi()->ActivateLocalViewL(KViewId10); 
		}  
		break;
	default:
		{		
			break;
		}
		
	} 
}

// ---------------------------------------------------------
// CBookOperationView::HandleClientRectChange()
// Handles client rect change.
// ---------------------------------------------------------
void CBookOperationView::HandleClientRectChange()
{
    if (iContainer)
	{
        iContainer->SetRect(ClientRect());
	}
}

// ---------------------------------------------------------
// CBookOperationView::DoActivateL(...)
// Creates the Container class object.
// ---------------------------------------------------------
void CBookOperationView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
									 TUid /*aCustomMessageId*/,
									 const TDesC8& aCustomMessage)
{
	
	   iContainer = new (ELeave) CBookOperationContainer;
       TRect rc;
       rc.SetRect(ClientRect().iTl, TSize(176, 144));
       iContainer->ConstructL(rc);
       AppUi()->AddToStackL(*this, iContainer);
       if(m_pObserve->GetStutus())
		   iContainer->SetEditChange();
	   // 	   if(/*aCustomMessage.Length()*/m_pObserve->GetDataFamily()->Length()>0 && m_pObserve->GetDataGiven()->Length()>0 && m_pObserve->GetDataMobile()->Length()>0 )
	   // 	{
	   
	   // 		TViewPara info;
	   // 		TPckgBuf<TViewPara> package(info);
	   // 		package.Copy(aCustomMessage);
	   // 	
	   // 		info = package();     
	   // 	  
	   // 	
	   
	   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, EMbmFairylandBookoperation);
	   CFbsBitmap* bitmapMask = iEikonEnv->CreateBitmapL(pathMbm, EMbmFairylandBookoperation_mask);
	   contextPane->SetPicture(bitmap, bitmapMask);
	   
	   
	   //load chinese words
	   TBuf<32> BookoperationTitle;
	   CEikonEnv::Static()->ReadResource(BookoperationTitle, R_QTN_MH_BOOKOPERATION_NEW);
	   
	   CAknTitlePane* titlePane = (CAknTitlePane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
       titlePane->SetTextL(BookoperationTitle);
	   
	   HBufC* p1 = m_pObserve->GetDataFamily().Alloc();	   
	   
	   HBufC* p2 = m_pObserve->GetDataGiven().Alloc();
	   
	   HBufC* p3 = m_pObserve->GetDataMobile().Alloc();
	   
       
	   
	   iContainer->SetLoginName(p1,p2,p3);
	   
	   if(NULL!=p1)
	   {
		   delete p1;
		   p1 = NULL;
	   }
	   
	   if(NULL!=p2)
	   {
		   delete p2;
		   p2 = NULL;
	   }
	   
	   if(NULL!=p3)
	   {
		   delete p3;
		   p3 = NULL;
	   }   
	   
	   //	}
}

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

// End of File

⌨️ 快捷键说明

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