LRESULT MainWindow::OnReceiveMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;

	HRESULT hr;

	switch (message)
	{

	case WM_CREATE:
		hr = OnCreate();
		if (FAILED(hr))
		{
			// Fail and quit.
			NotifyError(m_hwnd, TEXT("Cannot initialize the application."), hr);
			return -1;
		}
		break;
		
	case WM_SIZE:
		OnSize();
		break;

	case WM_PAINT:
		OnPaint();
		break;

	case WM_MOVE:
		OnPaint();
		break;

	case WM_DISPLAYCHANGE:
		m_pPlayer->DisplayModeChanged();
		break;

	case WM_ERASEBKGND:
		return 1;

	case WM_DESTROY:
		PostQuitMessage(0);
		break;

	case WM_TIMER:
		OnTimer();
		break;

	case WM_NOTIFY:
        OnWmNotify((NMHDR*)lParam);
		break;

	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		switch (wmId)
		{
		case IDM_EXIT:
			DestroyWindow(m_hwnd);
			break;

		case ID_FILE_OPENFILE:
			OnFileOpen();
			break;

		case IDC_BUTTON_PLAY:
			OnPlay();
			break;

		case IDC_BUTTON_STOP:
			OnStop();
			break;

		case IDC_BUTTON_PAUSE:
			OnPause();
			break;
	
		case IDC_BUTTON_MUTE:
			OnMute();
			break;
		}
		break;

    // Private filter graph message.
	case WM_GRAPH_EVENT:
		hr = m_pPlayer->HandleGraphEvent(this);
		break;

	default:
		return BaseWindow::OnReceiveMessage(message, wParam, lParam);
	}
	return 0;
}
示例#2
0
//-----------------------------------------------------------------------------
//! Create all the menu actions.
//-----------------------------------------------------------------------------
void tNASBar::CreateActions()
{
    TRACE_FUNCTION;
    if ( m_FusionClientAgent.IsPowerButtonAllowed() )
    {
        // Some audio servers support a power button
        m_pPowerAction = new tAction( tr("Power"), this );
        m_pPowerAction->setCheckable(true);
        m_pPowerAction->setChecked( m_FusionClientAgent.GetPowerState() != tFusionClient::ePS_Off );
        Connect( m_pPowerAction , SIGNAL( triggered() ), this, SLOT( PowerClicked() ));
    }
    else
    {
        if (m_pPowerAction != NULL)
        {
            delete m_pPowerAction;
            m_pPowerAction = 0;
        }
    }
    if ( m_FusionClientAgent.IsOnAndInitialized() )
    {
        // Connect firmware progress message
        Connect( &m_FusionClientAgent, SIGNAL(UpdateFirmwareProgress( quint8 )), this, SLOT(OnUpdateFirmwareProgress( quint8 )));

        // Volume action
        m_pVolumeAction = new tSliderAction(
            tr( "Volume", "sound level for SonicHub/FUSION-Link" ),
            m_FusionClientAgent.MinVolumeLevel(),
            m_FusionClientAgent.MaxVolumeLevel(),
            0,  // current volume is set when the Audio zone or Sonic hub Fader actions are created
            true,
            "%v",
            this
            );

        // Mute action
        m_pMuteAction = new tAction( tr("Mute"), this );
        m_pMuteAction->setCheckable( true );
        m_pMuteAction->setChecked( m_FusionClientAgent.IsMuted() );
        Connect( m_pMuteAction, SIGNAL( toggled( bool ) ), this, SLOT( SetMute( bool ) ) );
        Connect( &m_FusionClientAgent, SIGNAL( Mute( tFusionClient::eState ) ), this, SLOT( OnMute( tFusionClient::eState ) ) );
        Connect( &m_FusionClientAgent, SIGNAL( Mute( tFusionClient::eState ) ), m_pVolumeWidget, SLOT( OnMute( tFusionClient::eState ) ) );

        // Audio sources.
        m_pAudioSourceAction = new tAudioSourceAction( m_FusionClientAgent, m_MySourceId, this );

        // Virtual head - giving an empty string as the text, the device bars themselves will fill it it.
        // if you don't give it an empty string, it comes up as a dummy action and doesn't draw correctly on the softkey bar
        // it is also disabled in the menus.  Less work by just setting as empty string now.
        m_pVirtualHeadAction = new tAction( "", this );
        Connect( m_pVirtualHeadAction , SIGNAL( triggered() ), this, SLOT( ActivateVirtualHead() ), Qt::QueuedConnection );

        m_pBluetoothDevicesAction = new tAction( tr( "Bluetooth devices" ), this );
        Connect( m_pBluetoothDevicesAction , SIGNAL( triggered() ), this, SLOT( ShowBluetoothDialog() ), Qt::QueuedConnection );

        m_pMixerActions = tMixerActions::Create( m_FusionClientAgent, this );
        m_pZoneSetupAction = m_pMixerActions->MixerAction();
        Connect( m_pMixerActions, SIGNAL( MasterVolumeChanged( int ) ), m_pVolumeWidget, SLOT( SetValue( int ) ) );
        Connect( m_pMixerActions, SIGNAL( MasterVolumeChanged( int ) ), m_pVolumeAction, SLOT( SetValue( int ) ) );
        Connect( m_pVolumeAction, SIGNAL( ValueChanged( int ) ), m_pMixerActions, SLOT( RequestVolumeLevel( int ) ) );
        m_pMixerActions->UpdateMasterVolume();
    }