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

📄 systemsoundsview2.cpp

📁 symbian for c++ 系统声音调用例子
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CSystemSoundsView2 from SystemSoundsView2.h
*  Part of  : SystemSounds
*  Created  : 06/12/2003 by Forum Nokia
*  Implementation notes:
*     Initial content was generated by Nokia Series 60 AppWizard.
*  Version  : 1.0
*  Copyright: Nokia
* ============================================================================
*/

// INCLUDE FILES
#include  <aknviewappui.h>
#include  <avkon.hrh>
#include  <SystemSounds.rsg>
#include  "SystemSoundsView2.h"
#include  "SystemSoundsContainer2.h" 
#include  "SystemSounds.hrh"

// MACROS
_LIT(KRingToneFileName, "z:\\System\\Sounds\\Simple\\alarm.rng");


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

// ---------------------------------------------------------
// CSystemSoundsView2::ConstructL(const TRect& aRect)
// EPOC two-phased constructor
// ---------------------------------------------------------
//
void CSystemSoundsView2::ConstructL()
    {
    BaseConstructL( R_SYSTEMSOUNDS_VIEW2 );
    }

// ---------------------------------------------------------
// CSystemSoundsView2::~CSystemSoundsView2()
// ?implementation_description
// ---------------------------------------------------------
//
CSystemSoundsView2::~CSystemSoundsView2()
    {
    if ( iContainer )
        {
        AppUi()->RemoveFromViewStack( *this, iContainer );
        }

    delete iContainer;
    }

// ---------------------------------------------------------
// TUid CSystemSoundsView2::Id()
// ?implementation_description
// ---------------------------------------------------------
//
TUid CSystemSoundsView2::Id() const
    {
    return KView2Id;
    }

// ---------------------------------------------------------
// CSystemSoundsView2::HandleCommandL(TInt aCommand)
// ?implementation_description
// ---------------------------------------------------------
//
void CSystemSoundsView2::HandleCommandL(TInt aCommand)
    {   
    switch ( aCommand )
        {
        case EAknSoftkeyBack:
            {
            AppUi()->HandleCommandL(EEikCmdExit);
            break;
            }
        case ESystemSoundsView2Cmd1:
            {
            
            // Major sound types :
            // TBaSystemSoundUid KSystemSoundRingUID	= {0x100048AB};

            // Minor type is optional. 

            // Set Sound Info, which is type and location for the sound

            TBaSystemSoundType soundType(KSystemSoundRingUID);
            TBaSystemSoundName soundName(KRingToneFileName);
            TBaSystemSoundInfo soundInfo(soundType, soundName);

            BaSystemSound::SetSoundL(CCoeEnv::Static()->FsSession(), soundInfo);
            // Play sound if profile is not "Silent" or on "Meeting"
            CoeSoundPlayer::PlaySoundNow (soundType);
            }

            

        default:
            {
            AppUi()->HandleCommandL( aCommand );
            break;
            }
        }
    }

// ---------------------------------------------------------
// CSystemSoundsView2::HandleClientRectChange()
// ---------------------------------------------------------
//
void CSystemSoundsView2::HandleClientRectChange()
    {
    if ( iContainer )
        {
        iContainer->SetRect( ClientRect() );
        }
    }

// ---------------------------------------------------------
// CSystemSoundsView2::DoActivateL(...)
// ---------------------------------------------------------
//
void CSystemSoundsView2::DoActivateL(
   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
   const TDesC8& /*aCustomMessage*/)
    {
    if (!iContainer)
        {
        iContainer = new (ELeave) CSystemSoundsContainer2;
        iContainer->SetMopParent(this);
        iContainer->ConstructL( ClientRect() );
        AppUi()->AddToStackL( *this, iContainer );
        }
   }

// ---------------------------------------------------------
// CSystemSoundsView2::HandleCommandL(TInt aCommand)
// ---------------------------------------------------------
//
void CSystemSoundsView2::DoDeactivate()
    {
    if ( iContainer )
        {
        AppUi()->RemoveFromViewStack( *this, iContainer );
        }
    
    delete iContainer;
    iContainer = NULL;
    }

// End of File

⌨️ 快捷键说明

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