Esempio n. 1
0
BOOL CPopupFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
{
	if (m_pMenu != NULL && pHandlerInfo == NULL)
	{
		if (nCode == CN_COMMAND)
		{
			if (m_pMenu->SelectItem(nID) == S_OK)
				return TRUE;			
		}
		else if (nCode == CN_UPDATE_COMMAND_UI)
		{
			CCmdUI* pCmdUI = (CCmdUI*)pExtra;

			long lState;
			if (m_pMenu->GetItemState(pCmdUI->m_nID, &lState) == S_OK)
			{
				pCmdUI->Enable((lState & MenuStateDisable) == 0);
				pCmdUI->SetCheck((lState & MenuStateCheck) != 0);
				
				return TRUE;
			}
		}	
	}
	
	return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
Esempio n. 2
0
LRESULT CPIMDIFrameWndEx::OnUIEnableEvent(WPARAM wParam, LPARAM lParam)
{
	CCmdUI* pCmdUI = (CCmdUI*)wParam;
	ASSERT(pCmdUI != NULL);

	BOOL bEnable = (BOOL)lParam;
	pCmdUI->Enable(bEnable);

	return 0;
}
Esempio n. 3
0
BOOL CPageToolbars::OnCmdMsg(UINT nID, INT nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
{
	if( !m_bInitComplete ){
		return CPageBase::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
	}
	
	if(		nCode == CN_UPDATE_COMMAND_UI
		||	nCode == CN_COMMAND
		)
	{
		if( nID == ID_MYEXTBTN_SLIDER || nID == ID_MYEXTBTN_SCROLLER ) {
			if( nCode == CN_UPDATE_COMMAND_UI ){
				CCmdUI * pCmdUI = (CCmdUI *)pExtra;
				ASSERT( pCmdUI != NULL );
				pCmdUI->Enable();
			}
			return TRUE;
		}
		
		if(		nID == ID_COMBOBOX_IN_TOOLBAR 
			||	nID == ID_COMBOBOX_IN_MENUBAR 
			||	nID == ID_EDIT_IN_TOOLBAR 
			||	nID == ID_EDIT_IN_MENUBAR 
			||	nID == ID_CHECKBOX_IN_TOOLBAR 
			||	nID == ID_CHECKBOX_IN_MENUBAR 
			||	nID == ID_LINE_WIDTH_0
			||	nID == ID_LINE_WIDTH_1
			||	nID == ID_LINE_WIDTH_2
			||	nID == ID_LINE_WIDTH_3
			||	nID == ID_LINE_WIDTH_4
			||	nID == ID_LINE_WIDTH_5
			||	nID == ID_LINE_WIDTH_6
			||	nID == ID_LINE_WIDTH_7
			||	nID == ID_LINE_WIDTH_8
			||	nID == ID_LINE_WIDTH_9
			||	nID == ID_LINE_WIDTH_10
			||	nID == ID_LINE_WIDTH_OTHER
			)
		{
			if( nCode == CN_UPDATE_COMMAND_UI ){
				CCmdUI * pCmdUI = (CCmdUI *)pExtra;
				ASSERT( pCmdUI != NULL );
				pCmdUI->Enable();
			}
			return TRUE;
		}

		if( nID == IDC_CHECK_SHOW_GRIPPER ) {
			if( nCode == CN_COMMAND ){
				bool bDlgButtonChecked = ( IsDlgButtonChecked( nID ) == BST_CHECKED );
				m_wndToolBarColor.SetBarStyle( 
					bDlgButtonChecked
					? m_wndToolBarColor.GetBarStyle() |  CBRS_GRIPPER 
					: m_wndToolBarColor.GetBarStyle() & ~CBRS_GRIPPER 
					);
				m_wndToolBarPalette.SetBarStyle( 
					bDlgButtonChecked
					? m_wndToolBarPalette.GetBarStyle() |  CBRS_GRIPPER 
					: m_wndToolBarPalette.GetBarStyle() & ~CBRS_GRIPPER 
					);
				m_wndToolBar.SetBarStyle( 
					bDlgButtonChecked
					? m_wndToolBar.GetBarStyle() |  CBRS_GRIPPER 
					: m_wndToolBar.GetBarStyle() & ~CBRS_GRIPPER 
					);
				m_wndMenuBar.SetBarStyle( 
					bDlgButtonChecked
					? m_wndMenuBar.GetBarStyle() |  CBRS_GRIPPER 
					: m_wndMenuBar.GetBarStyle() & ~CBRS_GRIPPER 
					);
				m_wndToolBarControls1.SetBarStyle( 
					bDlgButtonChecked
					? m_wndToolBarControls1.GetBarStyle() |  CBRS_GRIPPER 
					: m_wndToolBarControls1.GetBarStyle() & ~CBRS_GRIPPER 
					);
				m_wndToolBarControls2.SetBarStyle( 
					bDlgButtonChecked
					? m_wndToolBarControls2.GetBarStyle() |  CBRS_GRIPPER 
					: m_wndToolBarControls2.GetBarStyle() & ~CBRS_GRIPPER 
					);
				_Update();
			}
		}

		if( m_wndToolBarColor.GetSafeHwnd() != NULL )
		{
			INT nBtnHeight = 0;
			switch( nID )
			{
			case ID_HEIGHT_8PX: nBtnHeight = 8; break;
			case ID_HEIGHT_10PX: nBtnHeight = 10; break;
			case ID_HEIGHT_12PX: nBtnHeight = 12; break;
			case ID_HEIGHT_14PX: nBtnHeight = 14; break;
			case ID_HEIGHT_16PX: nBtnHeight = 16; break;
			case ID_HEIGHT_18PX: nBtnHeight = 18; break;
			case ID_HEIGHT_20PX: nBtnHeight = 20; break;
			case ID_HEIGHT_22PX: nBtnHeight = 22; break;
			case ID_HEIGHT_24PX: nBtnHeight = 24; break;
			case ID_HEIGHT_26PX: nBtnHeight = 26; break;
			case ID_HEIGHT_28PX: nBtnHeight = 28; break;
			case ID_HEIGHT_30PX: nBtnHeight = 30; break;
			} // switch( nID )

			if( nBtnHeight != 0 )
			{
				if( nCode == CN_UPDATE_COMMAND_UI )
				{
					CCmdUI * pCmdUI = (CCmdUI *)pExtra;
					ASSERT( pCmdUI != NULL );
					pCmdUI->Enable();
					pCmdUI->SetRadio(
						(m_nThinColorBtnHeight == nBtnHeight) ? TRUE : FALSE
						);
				}
				else
				{
					if( m_nThinColorBtnHeight != nBtnHeight  )
					{
						m_nThinColorBtnHeight = nBtnHeight;
						CWnd::RepositionBars(0,0xFFFF,0);
						m_wndToolBarColor.RedrawWindow();
					}
				}
				return TRUE;
			}

			INT nColorCmdIndex =
				m_wndToolBarColor.CommandToIndex( nID );
			if( nColorCmdIndex >= 0 )
			{
				if( nCode == CN_UPDATE_COMMAND_UI )
				{
					CCmdUI * pCmdUI = (CCmdUI *)pExtra;
					ASSERT( pCmdUI != NULL );
					pCmdUI->Enable();
				}
				else
				{
					CWinApp * pApp = ::AfxGetApp();
					ASSERT( pApp != NULL );
					CExtCmdItem * pCmdItem =
						g_CmdManager->CmdGetPtr(
							_T("PageToolbars"),
							nID
							);
					ASSERT( pCmdItem != NULL );
					CString sMsg;
					sMsg.Format(
						_T("Command from the color toolbar:\n\n%s"),
						pCmdItem->m_sMenuText
						);
					::AfxMessageBox( LPCTSTR(sMsg) );
				}
				return TRUE;
			}
		}
	}
	return CPageBase::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}