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 }
void CMainFrame::OnViewCustomize() { //------------------------------------ // Create a customize toolbars dialog: //------------------------------------ CBCGPToolbarCustomize* pDlgCust = new CBCGPToolbarCustomize (this, TRUE /* Automatic menus scaning */); pDlgCust->Create (); }
void CMainFrame::OnViewCustomize() { //------------------------------------ // Create a customize toolbars dialog: //------------------------------------ CBCGPToolbarCustomize* pDlgCust = new CBCGPToolbarCustomize (this, TRUE /* Automatic menus scaning */ , ( BCGCUSTOMIZE_MENU_SHADOWS | BCGCUSTOMIZE_TEXT_LABELS | BCGCUSTOMIZE_LOOK_2000 | BCGCUSTOMIZE_MENU_ANIMATIONS) ); pDlgCust->Create (); }
//****************************************************************** void CBCGPKeyboardPage::OnUpdateNewShortcutKey() { ACCEL* pAccel = (ACCEL*) m_wndNewKey.GetAccel (); ASSERT (pAccel != NULL); m_strAssignedTo.Empty (); m_wndAssignedToTitle.ShowWindow (SW_HIDE); m_wndAssignButton.EnableWindow (FALSE); m_bIsAlreadyDefined = FALSE; BOOL bDefinedToCurrent = FALSE; if (m_wndNewKey.IsKeyDefined ()) { ASSERT (m_lpAccel != NULL); for (int i = 0; !m_bIsAlreadyDefined && i < m_nAccelSize; i ++) { const BYTE fRelFlags = FCONTROL | FALT | FSHIFT | FVIRTKEY; if (pAccel->key == m_lpAccel [i].key && (pAccel->fVirt & fRelFlags) == (m_lpAccel [i].fVirt & fRelFlags)) { CBCGPToolbarCustomize* pWndParent = DYNAMIC_DOWNCAST (CBCGPToolbarCustomize, GetParent ()); ASSERT (pWndParent != NULL); LPCTSTR lpszName = pWndParent->GetCommandName (m_lpAccel [i].cmd); if (lpszName != NULL) { m_strAssignedTo = lpszName; } else { m_strAssignedTo = _T("????"); } m_bIsAlreadyDefined = TRUE; if (m_pSelButton != NULL && m_pSelButton->m_nID == m_lpAccel[i].cmd) { bDefinedToCurrent = TRUE; } } } if (!m_bIsAlreadyDefined) { CBCGPLocalResource locaRes; m_strAssignedTo.LoadString (IDP_BCGBARRES_UNASSIGNED); m_wndAssignButton.EnableWindow (); } else if (g_pKeyboardManager != NULL && g_pKeyboardManager->IsReassignAllowed() && !bDefinedToCurrent) { m_wndAssignButton.EnableWindow (); } m_wndAssignedToTitle.ShowWindow (SW_SHOW); } UpdateData (FALSE); }
//****************************************************************** void CBCGPKeyboardPage::OnSelchangeCategory() { UpdateData (); int iIndex = m_wndCategoryList.GetCurSel (); if (iIndex == LB_ERR) { ASSERT (FALSE); return; } m_wndCommandsList.ResetContent (); m_wndCurrentKeysList.ResetContent (); CObList* pCategoryButtonsList = (CObList*) m_wndCategoryList.GetItemData (iIndex); ASSERT_VALID (pCategoryButtonsList); CString strCategory; m_wndCategoryList.GetLBText (iIndex, strCategory); BOOL bAllCommands = (strCategory == m_strAllCategory); CClientDC dcCommands (&m_wndCommandsList); CFont* pOldFont = dcCommands.SelectObject (m_wndCommandsList.GetFont ()); ASSERT (pOldFont != NULL); CBCGPToolbarCustomize* pWndParent = DYNAMIC_DOWNCAST (CBCGPToolbarCustomize, GetParent ()); ASSERT (pWndParent != NULL); int cxCommandsExtentMax = 0; for (POSITION pos = pCategoryButtonsList->GetHeadPosition (); pos != NULL;) { CBCGPToolbarButton* pButton = (CBCGPToolbarButton*) pCategoryButtonsList->GetNext (pos); ASSERT (pButton != NULL); if (pButton->m_nID > 0 && pButton->m_nID != (UINT) -1) { CString strText = pButton->m_strText; if (!pButton->m_strTextCustom.IsEmpty () && (bAllCommands || pWndParent->GetCountInCategory (strText, *pCategoryButtonsList) > 1)) { strText = pButton->m_strTextCustom; } int iIndex = m_wndCommandsList.AddString (strText); m_wndCommandsList.SetItemData (iIndex, (DWORD_PTR) pButton); cxCommandsExtentMax = max (cxCommandsExtentMax, dcCommands.GetTextExtent (strText).cx); } } m_wndCommandsList.SetHorizontalExtent (cxCommandsExtentMax + ::GetSystemMetrics (SM_CXHSCROLL)); dcCommands.SelectObject (pOldFont); m_wndNewKey.EnableWindow (FALSE); m_wndCommandsList.SetCurSel (0); OnSelchangeCommandsList (); }
//****************************************************************** void CBCGPKeyboardPage::OnAssign() { ASSERT (m_lpAccel != NULL); ASSERT (m_pSelButton != NULL); //----------------------------------------------------------- // Obtain a new acceleration entry from the keyboard control: //----------------------------------------------------------- ASSERT (m_wndNewKey.IsKeyDefined ()); ACCEL* pAccel = (ACCEL*) m_wndNewKey.GetAccel (); ASSERT (pAccel != NULL); pAccel->cmd = (USHORT) m_pSelButton->m_nID; CBCGPToolbarCustomize* pWndParent = DYNAMIC_DOWNCAST (CBCGPToolbarCustomize, GetParent ()); ASSERT_VALID (pWndParent); if (!pWndParent->OnAssignKey (pAccel)) { return; } if (m_bIsAlreadyDefined) { //--------------------- // Replace current key: //--------------------- for (int i = 0; i < m_nAccelSize; i ++) { const BYTE fRelFlags = FCONTROL | FALT | FSHIFT | FVIRTKEY; if (pAccel->key == m_lpAccel [i].key && (pAccel->fVirt & fRelFlags) == (m_lpAccel [i].fVirt & fRelFlags)) { m_lpAccel [i].cmd = pAccel->cmd; AddKeyEntry (&m_lpAccel [i]); break; } } } else { //---------------------------- // Create a new entries array: //---------------------------- LPACCEL lpAccelOld = m_lpAccel; m_lpAccel = new ACCEL [m_nAccelSize + 1]; ASSERT (m_lpAccel != NULL); memcpy (m_lpAccel, lpAccelOld, sizeof (ACCEL) * m_nAccelSize); int listcount = m_wndCurrentKeysList.GetCount(); for (int i = 0; i < m_nAccelSize; i ++) { for (int idx=0; idx<listcount; idx++) { if ( m_wndCurrentKeysList.GetItemData(idx) == (DWORD_PTR) &lpAccelOld [i] ) { m_wndCurrentKeysList.SetItemData(idx, (DWORD_PTR) &m_lpAccel [i]); break; } } } m_lpAccel [m_nAccelSize ++] = *pAccel; delete [] lpAccelOld; } g_pKeyboardManager->UpdateAcellTable(m_pSelTemplate, m_lpAccel, m_nAccelSize); if (!m_bIsAlreadyDefined) { AddKeyEntry (&m_lpAccel [m_nAccelSize - 1]); } m_wndNewKey.ResetKey (); OnUpdateNewShortcutKey (); m_wndCommandsList.SetFocus (); m_bIsAlreadyDefined = FALSE; }
BOOL CBCGPKeyboardPage::OnInitDialog() { CPropertyPage::OnInitDialog(); ASSERT (g_pKeyboardManager != NULL); //--------------------------------- // Initialize commands by category: //--------------------------------- CBCGPToolbarCustomize* pWndParent = DYNAMIC_DOWNCAST (CBCGPToolbarCustomize, GetParent ()); ASSERT_VALID (pWndParent); pWndParent->FillCategoriesComboBox (m_wndCategoryList, FALSE); m_wndCategoryList.SetCurSel (0); //------------------------------------------------------------------- // Find all application document templates and fill menues combobox // by document template data: //------------------------------------------------------------------ CDocManager* pDocManager = AfxGetApp ()->m_pDocManager; if (m_bAutoSet && pDocManager != NULL) { //--------------------------------------- // Walk all templates in the application: //--------------------------------------- for (POSITION pos = pDocManager->GetFirstDocTemplatePosition (); pos != NULL;) { CBCGPMultiDocTemplate* pTemplate = (CBCGPMultiDocTemplate*) pDocManager->GetNextDocTemplate (pos); ASSERT_VALID (pTemplate); ASSERT_KINDOF (CDocTemplate, pTemplate); //----------------------------------------------------- // We are interessing CBCGPMultiDocTemplate objects with // the shared menu only.... //----------------------------------------------------- if (!pTemplate->IsKindOf (RUNTIME_CLASS (CMultiDocTemplate)) || pTemplate->m_hAccelTable == NULL) { continue; } //---------------------------------------------------- // Maybe, the template with same ID is already exist? //---------------------------------------------------- BOOL bIsAlreadyExist = FALSE; for (int i = 0; !bIsAlreadyExist && i < m_wndViewTypeList.GetCount (); i++) { CBCGPMultiDocTemplate* pListTemplate = (CBCGPMultiDocTemplate*) m_wndViewTypeList.GetItemData (i); bIsAlreadyExist = pListTemplate != NULL && pListTemplate->GetResId () == pTemplate->GetResId (); } if (!bIsAlreadyExist) { CString strName; pTemplate->GetDocString (strName, CDocTemplate::fileNewName); int iIndex = m_wndViewTypeList.AddString (strName); m_wndViewTypeList.SetItemData (iIndex, (DWORD_PTR) pTemplate); } } } //-------------------------- // Add a default application: //-------------------------- CFrameWnd* pWndMain = DYNAMIC_DOWNCAST (CFrameWnd, m_pParentFrame); if (pWndMain != NULL && pWndMain->m_hAccelTable != NULL) { CBCGPLocalResource locaRes; CString strName; strName.LoadString (IDS_BCGBARRES_DEFAULT_VIEW); int iIndex = m_wndViewTypeList.AddString (strName); m_wndViewTypeList.SetItemData (iIndex, (DWORD_PTR) NULL); m_wndViewTypeList.SetCurSel (iIndex); OnSelchangeViewType(); } if (m_wndViewTypeList.GetCurSel () == CB_ERR) { m_wndViewTypeList.SetCurSel (0); OnSelchangeViewType(); } { CBCGPLocalResource locaRes; } OnSelchangeCategory (); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
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 }
//************************************************************************************************* BOOL CBCGPMousePage::OnInitDialog() { ASSERT (g_pMouseManager != NULL); CPropertyPage::OnInitDialog(); CStringList listOfViewNames; g_pMouseManager->GetViewNames (listOfViewNames); //------------------- // Create image list: //------------------- if (!m_ViewsImages.Create ( globalData.m_sizeSmallIcon.cx, globalData.m_sizeSmallIcon.cy, ILC_COLOR | ILC_MASK, (int) listOfViewNames.GetCount (), 1)) { ASSERT (FALSE); } m_wndListOfViews.SetImageList (&m_ViewsImages, LVSIL_SMALL); POSITION pos; //----------------- // Fill views list: //----------------- CRect rect; m_wndListOfViews.GetClientRect (&rect); m_wndListOfViews.InsertColumn (0, _T(""), LVCFMT_LEFT, rect.Width () - 1); ASSERT (!listOfViewNames.IsEmpty ()); int iMaxWidth = 0; for (pos = listOfViewNames.GetHeadPosition (); pos != NULL;) { CString strViewName = listOfViewNames.GetNext (pos); int iImageIndex = -1; //--------------- // Add view icon: //--------------- UINT uiViewIconId = g_pMouseManager->GetViewIconId ( g_pMouseManager->GetViewIdByName (strViewName)); HICON hViewIcon; if (uiViewIconId != 0 && (hViewIcon = AfxGetApp ()->LoadIcon (uiViewIconId)) != NULL) { iImageIndex = m_ViewsImages.Add (hViewIcon); ::DestroyIcon (hViewIcon); } int iIndex = m_wndListOfViews.GetItemCount (); for (int i = 0; i < m_wndListOfViews.GetItemCount (); i ++) { CString strText = m_wndListOfViews.GetItemText (i, 0); if (strText > strViewName) { iIndex = i; break; } } m_wndListOfViews.InsertItem (iIndex, strViewName, iImageIndex); m_wndListOfViews.SetItemData (iIndex, (DWORD) g_pMouseManager->GetViewIdByName (strViewName)); int iStrWidth = m_wndListOfViews.GetStringWidth (strViewName); iMaxWidth = max (iStrWidth, iMaxWidth); } //---------------------------------- // Add icon width pluse some pixels: //---------------------------------- IMAGEINFO info; m_ViewsImages.GetImageInfo (0, &info); CRect rectImage = info.rcImage; iMaxWidth += rectImage.Width () + 10; m_wndListOfViews.SetColumnWidth (0, iMaxWidth); //-------------------- // Fill commands list: //-------------------- CBCGPToolbarCustomize* pWndParent = DYNAMIC_DOWNCAST (CBCGPToolbarCustomize, GetParent ()); ASSERT (pWndParent != NULL); pWndParent->FillAllCommandsList (m_wndListOfCommands); //----------------------- // Select the first view: //----------------------- m_wndListOfViews.SetItemState (0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); m_wndListOfViews.EnsureVisible (0, FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }