Пример #1
0
BOOL CBCGPOptionsPage::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	m_wndShowShortcutKeys.EnableWindow (m_bShowTooltips);
	m_wndShowAllMenusDelay.EnableWindow (m_bRecentlyUsedMenus);

	if (CBCGPToolBar::m_lstBasicCommands.IsEmpty () || !m_bIsMenuBarExist)
	{
		m_wndRUMenus.ShowWindow (SW_HIDE);
		m_wndRUMenus.EnableWindow (FALSE);

		m_wndResetUsageBtn.ShowWindow (SW_HIDE);
		m_wndResetUsageBtn.EnableWindow (FALSE);

		m_wndRuMenusLine.ShowWindow (SW_HIDE);
		m_wndRuMenusLine.EnableWindow (FALSE);

		m_wndRuMenusTitle.ShowWindow (SW_HIDE);
		m_wndRuMenusTitle.EnableWindow (FALSE);

		m_wndShowAllMenusDelay.ShowWindow (SW_HIDE);
		m_wndShowAllMenusDelay.EnableWindow (FALSE);
	}

	CBCGPToolbarCustomize* pWndParent = DYNAMIC_DOWNCAST (CBCGPToolbarCustomize, GetParent ());
	ASSERT (pWndParent != NULL);

	if ((pWndParent->GetFlags () & BCGCUSTOMIZE_LOOK_2000) == 0)
	{
		m_wndLook2000.ShowWindow (SW_HIDE);
		m_wndLook2000.EnableWindow (FALSE);
	}

	if (pWndParent->GetFlags () & BCGCUSTOMIZE_NO_LARGE_ICONS)
	{
		m_wndLargeIcons.ShowWindow (SW_HIDE);
		m_wndLargeIcons.EnableWindow (FALSE);
		m_bLargeIcons = FALSE;
	}

#if defined _AFXDLL && !defined _BCGCBPRO_STATIC_	// Skins manager can not be used in the static version
	if ((pWndParent->GetFlags () & BCGCUSTOMIZE_SELECT_SKINS) == 0)
	{
		m_wndSkinsBtn.ShowWindow (SW_HIDE);
		m_wndSkinsBtn.EnableWindow (FALSE);
	}
	else
	{
		ASSERT (g_pSkinManager != NULL);
	}
#else
	m_wndSkinsBtn.ShowWindow (SW_HIDE);
	m_wndSkinsBtn.EnableWindow (FALSE);
#endif

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Пример #2
0
BOOL CBCGPMenuPage::OnInitDialog() 
{
	{
		CBCGPLocalResource locaRes;
		CPropertyPage::OnInitDialog();
	}

	if (m_iMenuAnimationType == (int) CBCGPPopupMenu::SYSTEM_DEFAULT_ANIMATION)
	{
		m_iMenuAnimationType = m_wndMenuAnimations.GetCount () - 1;
		UpdateData (FALSE);
	}

	POSITION pos = NULL;

	//----------------------------------------------------------
	// Find application Menu Bar object (assume that only one):
	//---------------------------------------------------------
	for (pos = gAllToolbars.GetHeadPosition (); 
		m_pMenuBar == NULL && pos != NULL;)
	{
		CBCGPToolBar* pToolBar = (CBCGPToolBar*) gAllToolbars.GetNext (pos);
		ASSERT (pToolBar != NULL);

		if (CWnd::FromHandlePermanent (pToolBar->m_hWnd) != NULL)
		{
			ASSERT_VALID(pToolBar);
			m_pMenuBar = DYNAMIC_DOWNCAST (CBCGPMenuBar, pToolBar);
		}
	}

	if (m_pMenuBar != NULL)
	{
		m_pMenuBar->m_pMenuPage = this;

		int iCurrMenu = -1;

		//---------------------------
		// Save MenuBar current menu:
		//---------------------------
		m_hmenuCurr = m_pMenuBar->GetHMenu ();

		m_pMenuBar->OnChangeHot (-1);
		g_menuHash.SaveMenuBar (m_hmenuCurr, m_pMenuBar);

		//-------------------------------------------------------------------
		// Find all application document templates and fill menues combobox
		// by document template data:
		//------------------------------------------------------------------
		CDocManager* pDocManager = AfxGetApp ()->m_pDocManager;
		if (m_bAutoSet && pDocManager != NULL)
		{
			POSITION pos = NULL;

			//---------------------------------------
			// Walk all templates in the application:
			//---------------------------------------
			for (pos = pDocManager->GetFirstDocTemplatePosition (); pos != NULL;)
			{
				CBCGPMultiDocTemplate* pTemplate = 
					(CBCGPMultiDocTemplate*) pDocManager->GetNextDocTemplate (pos);
				ASSERT_VALID (pTemplate);
				ASSERT_KINDOF (CDocTemplate, pTemplate);

				//-----------------------------------------------------
				// We are interessing CMultiDocTemplate objects with
				// the shared menu only....
				//-----------------------------------------------------
				if (!pTemplate->IsKindOf (RUNTIME_CLASS (CMultiDocTemplate)) ||
					pTemplate->m_hMenuShared == NULL)
				{
					continue;
				}

				//----------------------------------------------------
				// Maybe, the template with same ID is already exist?
				//----------------------------------------------------
				BOOL bIsAlreadyExist = FALSE;
				for (int i = 0; !bIsAlreadyExist && i < m_wndMenuesList.GetCount (); i++)
				{
					CBCGPMultiDocTemplate* pListTemplate = 
						(CBCGPMultiDocTemplate*) m_wndMenuesList.GetItemData (i);
					bIsAlreadyExist = pListTemplate != NULL &&
						pListTemplate->GetResId () == pTemplate->GetResId ();
				}

				if (!bIsAlreadyExist)
				{
					CString strName;
					pTemplate->GetDocString (strName, CDocTemplate::fileNewName);

					int iIndex = m_wndMenuesList.AddString (strName);
					m_wndMenuesList.SetItemData (iIndex, (DWORD_PTR) pTemplate);

					if (pTemplate->m_hMenuShared == m_hmenuCurr)
					{
						iCurrMenu = iIndex;
					}
				}
			}
		}

		//--------------------------
		// Add a default frame menu:
		//--------------------------
		CString strName;
		{
			CBCGPLocalResource locaRes;
			strName.LoadString (IDS_BCGBARRES_DEFUALT_MENU);
		}

		int iIndex = m_wndMenuesList.AddString (strName);
		m_wndMenuesList.SetItemData (iIndex, (DWORD_PTR) NULL);

		if (iCurrMenu == -1)
		{
			m_bIsDefaultMDIMenu = TRUE;
			iCurrMenu = iIndex;
		}

		m_hmenuSelected = m_hmenuCurr;
		m_wndMenuesList.SetCurSel (iCurrMenu);

		UpdateData (FALSE);
		OnSelchangeMenuList ();
	}
	else
	{
		//-------------------------------------------------
		// No menubar found, disable menu selecting engine:
		//-------------------------------------------------
		m_wndMenuesList.EnableWindow (FALSE);
		GetDlgItem(IDC_BCGBARRES_RESET_FRAME_MENU)->EnableWindow(FALSE);

		CBCGPLocalResource locaRes;
		m_strMenuDescr.LoadString (IDS_BCGBARRES_NO_MENUBAR);

		UpdateData (FALSE);
	}

	//--------------------------
	// Initialize context menus:
	//--------------------------
	{
		CBCGPLocalResource locaRes;

		CString strNoContextMenu;
		strNoContextMenu.LoadString (IDS_BCGBARRES_NO_CONTEXT);

		m_wndContextMenus.AddString (strNoContextMenu);
		m_wndContextMenus.SetCurSel (0);
	}

	if (g_pContextMenuManager != NULL)
	{
		CStringList listOfNames;
		g_pContextMenuManager->GetMenuNames (listOfNames);

		for (pos = listOfNames.GetHeadPosition (); pos != NULL;)
		{
			CString strName = listOfNames.GetNext (pos);
			m_wndContextMenus.AddString (strName);
		}

		m_wndContextMenuCaption.EnableWindow (m_wndContextMenus.GetCount () > 1);
		m_wndContextMenus.EnableWindow (m_wndContextMenus.GetCount () > 1);
	}
	else
	{
		//-------------------------------
		// Hide all context menus fields:
		//-------------------------------
		m_wndContextMenuCaption.ShowWindow (SW_HIDE);
		m_wndContextMenus.ShowWindow (SW_HIDE);
		m_wndContextHint.ShowWindow (SW_HIDE);
		m_wndContextFrame.ShowWindow (SW_HIDE);
		m_wndResetMenuButton.ShowWindow (SW_HIDE);
	}

	CBCGPToolbarCustomize* pWndParent = DYNAMIC_DOWNCAST (CBCGPToolbarCustomize, GetParent ());
	ASSERT (pWndParent != NULL);

	if ((pWndParent->GetFlags () & BCGCUSTOMIZE_MENU_SHADOWS) == 0)
	{
		m_wndMenuShadows.ShowWindow (SW_HIDE);
	}

	if ((pWndParent->GetFlags () & BCGCUSTOMIZE_MENU_ANIMATIONS) == 0)
	{
		m_wndMenuAnimationsLabel.ShowWindow (SW_HIDE);
		m_wndMenuAnimations.ShowWindow (SW_HIDE);
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}