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

📄 logoncontainer.cpp.bak

📁 个人手机助理套件:包含1、记事本(备忘录)、名片夹、名片夹的上传下载(异地备份)、短消息模块
💻 BAK
字号:
/*
* ============================================================================
*  Name     : CLogonContainer from CCoeControl, MCoeControlObserver
*  Part of  : Logon
*  Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/

// INCLUDE FILES
#include <HelperGenius.rsg>
#include "HelperGenius.hrh"
#include "LogonContainer.h"
#include <fbs.h>
#include <AknUtils.h>
#include <eiklabel.h>
#include <eikedwin.h>
#include <barsread.h>
#include <eikenv.h>
#include "file.h"
#include <Helpergenius.mbg>
#include "UserInfo.h"
#include <AknNumSecEd.h>
#define  DELPTR(p) if(p!=NULL){ delete p;p=NULL;}
// ================= MEMBER FUNCTIONS =======================

// C++ default constructor can NOT contain any code, that
// might leave.
//
CLogonContainer::CLogonContainer()
    {
        m_plabelName = NULL;
	   m_pBitmap = NULL;
	m_plabelPassword = NULL;
	m_peditName = NULL;
	m_peditPassword = NULL;
    }

// EPOC default constructor can leave.
void CLogonContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();
	m_pBitmap = new (ELeave) CFbsBitmap;
	TBuf<KMaxPath> pathMbm;
#ifdef __WINS__
	pathMbm.Copy(_L("z:\\system\\apps\\HelperGenius\\HelperGenius.mbm"));
#else
	CHelperGeniusAppUi* pApp = (CHelperGeniusAppUi*)CEikonEnv::Static()->AppUi();
	pApp->GetAppPath(pathMbm);
	
	pathMbm.Append(_L("HelperGenius.mbm"));
#endif
    User::LeaveIfError(CompleteWithAppPath(pathMbm));
    User::LeaveIfError(m_pBitmap->Load(pathMbm,EMbmHelpergeniusHelpergenius_icon_17));
   /********姓名标签***********************************************/
    m_plabelName = new (ELeave) CEikLabel;
    CleanupStack::PushL(m_plabelName);
    m_plabelName->SetContainerWindowL(*this);
    
    TBuf<32> sTmplabelName;
    CEikonEnv::Static()->ReadResource(sTmplabelName,R_QTN_MH_REGISTER_USERNAME);
    m_plabelName->SetTextL(sTmplabelName);
    m_plabelName->SetExtent(TPoint(10,40),m_plabelName->MinimumSize( ) );
    CleanupStack::Pop( m_plabelName );
    /********密码标签********************************************************/
    m_plabelPassword = new (ELeave) CEikLabel;
    CleanupStack::PushL(m_plabelPassword);
    m_plabelPassword->SetContainerWindowL(*this);
    
    TBuf<32> sTmplabelPass;
    CEikonEnv::Static()->ReadResource(sTmplabelPass,R_QTN_MH_REGISTER_USERPASS);
    m_plabelPassword->SetTextL(sTmplabelPass);
    m_plabelPassword->SetExtent(TPoint(10,90),m_plabelPassword->MinimumSize( ) );
    CleanupStack::Pop( m_plabelPassword );
    /***********设置编辑框***********
     ***********姓名编辑框******************************************/
    TResourceReader reader;
    iCoeEnv->CreateResourceReaderLC(reader,R_AKNEXEDITOR_ONE_EDWIN);
    m_peditName = new(ELeave) CEikEdwin;
    m_peditName->SetContainerWindowL(*this);
    m_peditName->ConstructFromResourceL(reader);
    CleanupStack::PopAndDestroy( );
    m_peditName->SetAknEditorCurrentInputMode(EAknEditorTextInputMode);
    m_peditName->SetExtent(TPoint(90,40),TSize(80,20));

	TBuf<32> bufName, bufPassword;
	CUserInfo aUserInfo;
	CFile  aFile;
	aFile.ReadUserInfoFromFileByStream( aUserInfo );
	aUserInfo.GetName( bufName );
	aUserInfo.GetPassword( bufPassword );

	if( bufName.Length( ) > 0 )
	{
		m_peditName->SetTextL( &bufName );
	}

	else
	{
		m_peditName->SetTextL(&_L(""));
	}
	
    
    m_peditName->SetFocus(EFalse);
	
    /*************密码编辑框*************************************************************/
	m_peditPassword = new(ELeave) CAknNumericSecretEditor; 
	m_peditPassword->SetContainerWindowL(*this);
	TResourceReader reader1;
	CEikonEnv::Static()->CreateResourceReaderLC(reader1,R_MY_SECRETED); 
	m_peditPassword->ConstructFromResourceL(reader1);
	CleanupStack::PopAndDestroy();
	m_peditPassword->SetExtent(TPoint(90,90),TSize(80,20));
	m_peditPassword->SetFocus(ETrue);


    SetRect(aRect);
    ActivateL();
    }

// Destructor
CLogonContainer::~CLogonContainer()
    {
        DELPTR(m_plabelName);
	  DELPTR(m_pBitmap);
	DELPTR(m_plabelPassword);
	DELPTR(m_peditName);
	DELPTR(m_peditPassword);
    }

// ---------------------------------------------------------
// CLogonContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//

void CLogonContainer::FocusTo(TInt aCommand)
    {
    }

// ---------------------------------------------------------
// CLogonContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CLogonContainer::SizeChanged()
    {
    }

// ---------------------------------------------------------
// CLogonContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CLogonContainer::CountComponentControls() const
    {
    return 4; // return nbr of controls inside this container
    }

// ---------------------------------------------------------
// CLogonContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CLogonContainer::ComponentControl(TInt aIndex) const
    {
       switch(aIndex)
	{
	case 0:
		{
			return m_plabelName;
			break;
		}
	case 1:
		{
			return m_plabelPassword;
			break;
		}
	case 2:
		{
			return m_peditName;
			break;
		}
	case 3:
		{
			return m_peditPassword;
			break;
		}
	default:
		{
			return NULL;
			break;
		}
	}  
    }

// ---------------------------------------------------------
// CLogonContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CLogonContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
	/******添加背景图片*******************************************/
    gc.Clear(aRect);
    TPoint topLeft(0,0);
	//    gc.DrawBitmap(TRect(topLeft,TSize(176,208)),m_pBitmap);
    gc.BitBlt(topLeft,m_pBitmap,TRect(topLeft,TSize(176,208)));
    }

// ---------------------------------------------------------
// CLogonContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CLogonContainer::OfferKeyEventL(
    const TKeyEvent& aKeyEvent, TEventCode aType)
    {
      if (m_peditName)
	{
		if (m_peditName->IsFocused())
		{
			if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
			{
				m_peditName->SetFocus(EFalse);
				m_peditPassword->SetFocus(ETrue);
				return EKeyWasConsumed;
			}
			else if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
			{
				
				m_peditName->SetFocus(EFalse);
				m_peditPassword->SetFocus(ETrue);
				return EKeyWasConsumed;
			}
			return m_peditName->OfferKeyEventL(aKeyEvent, aType);
		}
	}
	
	if (m_peditPassword)
	{
		if (m_peditPassword->IsFocused())
		{
			if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
			{
				
				m_peditPassword->SetFocus(EFalse);
				m_peditName->SetFocus(ETrue);
				return EKeyWasConsumed;
			}
			else if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
			{
				
				m_peditPassword->SetFocus(EFalse);
				m_peditName->SetFocus(ETrue);
				return EKeyWasConsumed;
			}
			return m_peditPassword->OfferKeyEventL(aKeyEvent, aType);
		}
	}
    return EKeyWasNotConsumed;
    }


// ---------------------------------------------------------
// CLogonContainer::HandleControlEventL(
//     CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CLogonContainer::HandleControlEventL(
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
    {
    }

void CLogonContainer::GetPassword(TDes &aPassword)
{
     m_peditPassword->GetText(aPassword);
}
void CLogonContainer::GetName(TDes &aName)
{
	m_peditName->GetText(aName);
}
// End of File  

⌨️ 快捷键说明

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