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

📄 senddataview.cpp

📁 symbian中讲述的一个有关M类使用的例子
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CSendDataView from CAknView
*  Part of  : SendData
*  Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/

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

#include <MClassExample.rsg>
#include "MClassExample.hrh"
#include "SendDataView.h"
#include "SendDataContainer.h" 

// ================= MEMBER FUNCTIONS =======================

// C++ default constructor can NOT contain any code, that
// might leave.
//
CSendDataView::CSendDataView(MNotify* aNotify)
{
	m_Notify = aNotify;
}

CSendDataView* CSendDataView::NewL(MNotify* aNotify)
{
	CSendDataView* self = NewLC(aNotify);
	CleanupStack::Pop(self);
	return self;
}

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

// EPOC default constructor can leave.
void CSendDataView::ConstructL()
{
    BaseConstructL(R_SD_VIEW/*R_SendData_View*/);
}

// Destructor
CSendDataView::~CSendDataView()
{
    if (iContainer)
	{
        AppUi()->RemoveFromStack(iContainer);
		delete iContainer;
		iContainer = NULL;
	}
}

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

// ---------------------------------------------------------
// CSendDataView::HandleCommandL(TInt aCommand)
// Handles commands
// ---------------------------------------------------------
void CSendDataView::HandleCommandL(TInt aCommand)
{   
    switch (aCommand)
	{
	case EsdCommandsend:
		{
			
			//use MNotify class.
			TBuf<KMaxName> strTemp;
			iContainer->GetInput(strTemp);
			m_Notify->SendData(strTemp);
			AppUi()->ActivateLocalViewL(TUid::Uid(2));
			
			//use ActivateLocalViewL()
			//在激活某个View时把简单对象(T类)做为参数进行传递
// 			_LIT( KCode, "123456789" );
// 			_LIT( KStatus, "Send");
// 
// 			TViewPara info;
// 			info.iId = 300125;
// 			info.iCode.Copy( KCode );
// 			info.iStatus.Copy( KStatus );
// 			info.iDate.HomeTime();
// 
// 			TPckgBuf< TViewPara > package(info);
// 			TBuf8<128> para;       //要根据TViewPara所占的内存空间准备足够的buffer
// 			para.Copy( package );
// 
// 			AppUi()->ActivateLocalViewL( TUid::Uid(2), TUid::Uid( 0 ), para );
// 						
			break;
		}
	default:
		{
			AppUi()->HandleCommandL(aCommand);
			break;
		}
	}
}

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

// ---------------------------------------------------------
// CSendDataView::DoActivateL(...)
// Creates the Container class object.
// ---------------------------------------------------------
void CSendDataView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
								TUid /*aCustomMessageId*/,
								const TDesC8& /*aCustomMessage*/)
{
    iContainer = new (ELeave) CSendDataContainer;
    iContainer->SetMopParent(this);
	TRect rc;
	rc.SetRect(ClientRect().iTl,TSize(176,144));
    iContainer->ConstructL(rc);//ClientRect());
    AppUi()->AddToStackL(*this, iContainer);
}

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

// End of File

⌨️ 快捷键说明

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