📄 customizepropsheet.cpp
字号:
// change both or nothing
m_strCategoriesList.SetAt(pos, lpszCategoryNew);
m_ButtonsByCategory.RemoveKey(lpszCategoryOld);
m_ButtonsByCategory.SetAt(lpszCategoryNew, pCategoryButtonsList);
*/
return TRUE;
}
//**************************************************************************************
void CCustomizePropSheet::ReplaceButton (UINT uiCmd, const CBCGToolbarButton& button)
{
/*CRuntimeClass* pClass = button.GetRuntimeClass ();
ASSERT (pClass != NULL);
BOOL bFinish = FALSE;
for (POSITION posCategory = m_strCategoriesList.GetHeadPosition();
!bFinish;)
{
CString strCategory;
if (posCategory == NULL)
{
strCategory = m_strAllCommands;
bFinish = TRUE;
}
else
{
strCategory = m_strCategoriesList.GetNext (posCategory);
}
CObList* pCategoryButtonsList;
if (!m_ButtonsByCategory.Lookup (strCategory, pCategoryButtonsList))
{
ASSERT (FALSE);
}
ASSERT_VALID (pCategoryButtonsList);
for (POSITION pos = pCategoryButtonsList->GetHeadPosition (); pos != NULL;)
{
POSITION posSave = pos;
CBCGToolbarButton* pButton = (CBCGToolbarButton*) pCategoryButtonsList->GetNext (pos);
ASSERT (pButton != NULL);
if (pButton->m_nID == uiCmd) // Found!
{
CBCGToolbarButton* pNewButton = (CBCGToolbarButton*) pClass->CreateObject ();
ASSERT_VALID (pNewButton);
pNewButton->CopyFrom (button);
if (pNewButton->m_strText.IsEmpty ())
{
pNewButton->m_strText = pButton->m_strText;
}
pCategoryButtonsList->SetAt (posSave, pNewButton);
delete pButton;
}
}
}*/
}
//**************************************************************************************
BOOL CCustomizePropSheet::SetUserCategory (LPCTSTR lpszCategory)
{
/*ASSERT (lpszCategory != NULL);
CObList* pCategoryButtonsList;
if (!m_ButtonsByCategory.Lookup (lpszCategory, pCategoryButtonsList))
{
TRACE(_T("CBCGToolbarCustomize::SetUserCategory: Can't find category '%s'\n"),
lpszCategory);
return FALSE;
}
m_pCustomizePage->SetUserCategory (lpszCategory);*/
return TRUE;
}
//**************************************************************************************
void CCustomizePropSheet::SetFrameCustMode (BOOL bCustMode)
{
/*ASSERT_VALID (m_pParentFrame);
//-------------------------------------------------------------------
// Enable/disable all parent frame child windows (except docking bars
// and our toolbars):
//-------------------------------------------------------------------
CWnd* pWndChild = m_pParentFrame->GetWindow (GW_CHILD);
while (pWndChild != NULL)
{
CRuntimeClass* pChildClass = pWndChild->GetRuntimeClass ();
if (pChildClass == NULL ||
(!pChildClass->IsDerivedFrom (RUNTIME_CLASS (CDockBar)) &&
#if _MSC_VER >= 1200
!pChildClass->IsDerivedFrom (RUNTIME_CLASS (CReBar)) &&
#endif // _MSC_VER
!pChildClass->IsDerivedFrom (RUNTIME_CLASS (CBCGToolBar))))
{
pWndChild->EnableWindow (!bCustMode);
}
CBCGDockBar* pWndDockBar = (CBCGDockBar*) DYNAMIC_DOWNCAST (CDockBar, pWndChild);
if (pWndDockBar != NULL)
{
pWndDockBar->SetCustomizationMode (bCustMode);
}
pWndChild = pWndChild->GetNextWindow ();
}
//-----------------------------------------------
// Set/reset costumize mode for ALL our toolbars:
//-----------------------------------------------
CBCGToolBar::SetCustomizeMode (bCustMode);
//-------------------------------------------------------------
// Inform the parent frame about mode (for additional actions):
//-------------------------------------------------------------
m_pParentFrame->SendMessage (BCGM_CUSTOMIZETOOLBAR, (WPARAM) bCustMode);*/
}
//**************************************************************************************
BOOL CCustomizePropSheet::Create ()
{
//CBCGLocalResource locaRes;
return 1;//CPropertySheet::Create (m_pParentFrame);
}
//*************************************************************************************
void CCustomizePropSheet::ShowToolBar (CBCGToolBar* pToolBar, BOOL bShow)
{
//m_pToolbarsPage->ShowToolBar (pToolBar, bShow);
}
//*************************************************************************************
BOOL CCustomizePropSheet::OnInitDialog()
{
/*BOOL bResult = CPropertySheet::OnInitDialog();
CRect rectClient; // Client area rectangle
GetClientRect (&rectClient);
//----------------------
// Show "Cancel" button:
//----------------------
CWnd *pWndCancel = GetDlgItem (IDCANCEL);
if (pWndCancel == NULL)
{
return bResult;
}
pWndCancel->ShowWindow (SW_SHOW);
pWndCancel->EnableWindow ();
CRect rectClientCancel;
pWndCancel->GetClientRect (&rectClientCancel);
pWndCancel->MapWindowPoints (this, &rectClientCancel);
//-------------------------------
// Enlarge property sheet window:
//-------------------------------
CRect rectWnd;
GetWindowRect(rectWnd);
SetWindowPos(NULL, 0, 0,
rectWnd.Width (),
rectWnd.Height () + rectClientCancel.Height () + 2 * iButtonMargin,
SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
//-------------------------------------------------
// Move "Cancel" button to the right bottom corner:
//-------------------------------------------------
pWndCancel->SetWindowPos (NULL,
rectClient.right - rectClientCancel.Width () - iButtonMargin,
rectClientCancel.top + iButtonMargin / 2,
0, 0,
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
//---------------------------------------------------
// Change "Cancel" button's style to "DEFPUSHBUTTON":
//---------------------------------------------------
CWnd *pWndOk = GetDlgItem (IDOK);
if (pWndOk != NULL)
{
pWndOk->ModifyStyle (BS_DEFPUSHBUTTON, 0);
}
pWndCancel->ModifyStyle (0, BS_DEFPUSHBUTTON);
//--------------------------------------------------------
// Replace "Cancel" text to "Close"
// (CPropertyPage::CancelToClose method does nothing in a
// modeless property sheet):
//--------------------------------------------------------
CString strCloseText;
{
CBCGLocalResource locaRes;
strCloseText.LoadString (IDS_BCGBARRES_CLOSE);
}
pWndCancel->SetWindowText (strCloseText);
//------------------------
// Adjust the Help button:
//------------------------
CButton *pWndHelp = (CButton*) GetDlgItem (IDHELP);
if (pWndHelp == NULL)
{
return bResult;
}
if (m_uiFlags & BCGCUSTOMIZE_NOHELP)
{
// By Sven Ritter
pWndHelp->ShowWindow (SW_HIDE);
pWndHelp->EnableWindow(FALSE);
}
else
{
pWndHelp->ShowWindow (SW_SHOW);
pWndHelp->EnableWindow ();
//-----------------------
// Set Help button image:
//-----------------------
CBCGLocalResource locaRes;
LPCTSTR lpszResourceName = MAKEINTRESOURCE (IDB_BCGBARRES_HELP);
ASSERT(lpszResourceName != NULL);
HBITMAP hbmpHelp = (HBITMAP) ::LoadImage (
AfxFindResourceHandle (lpszResourceName, RT_BITMAP),
lpszResourceName,
IMAGE_BITMAP,
0, 0,
LR_CREATEDIBSECTION | LR_LOADMAP3DCOLORS);
ASSERT (hbmpHelp != NULL);
pWndHelp->ModifyStyle (0, BS_BITMAP);
pWndHelp->SetBitmap (hbmpHelp);
//-------------------------------------------------
// Move "Help" button to the left bottom corner and
// adjust its size by the bitmap size:
//-------------------------------------------------
BITMAP bmp;
::GetObject (hbmpHelp, sizeof (BITMAP), &bmp);
pWndHelp->SetWindowPos (NULL,
rectClient.left + iButtonMargin,
rectClientCancel.top,
bmp.bmWidth + iButtonMargin, bmp.bmHeight + iButtonMargin,
SWP_NOZORDER | SWP_NOACTIVATE);
}*/
return 0;//bResult;
}
//************************************************************************************
BOOL CCustomizePropSheet::OnCommand(WPARAM wParam, LPARAM lParam)
{
/* switch (LOWORD (wParam))
{
case IDCANCEL:
DestroyWindow ();
return TRUE;
case IDHELP:
ASSERT_VALID (m_pParentFrame);
m_pParentFrame->SendMessage (BCGM_CUSTOMIZEHELP, GetActiveIndex (), (LPARAM) this);
return TRUE;
}
*/
return CPropertySheet::OnCommand(wParam, lParam);
}
//************************************************************************************
void CCustomizePropSheet::EnableUserDefinedToolbars (BOOL bEnable)
{
//m_pToolbarsPage->EnableUserDefinedToolbars (bEnable);
}
//******************************************************************************************
void CCustomizePropSheet::AddMenuCommands (const CMenu* pMenu, BOOL bPopup, LPCTSTR lpszCategory)
{
/*ASSERT (pMenu != NULL);
int iCount = (int) pMenu->GetMenuItemCount ();
for (int i = 0; i < iCount; i ++)
{
UINT uiCmd = pMenu->GetMenuItemID (i);
CString strText;
pMenu->GetMenuString (i, strText, MF_BYPOSITION);
strText.Remove (_T('&'));
switch (uiCmd)
{
case 0: // Separator, ignore it.
break;
case -1: // Submenu
{
CMenu* pSubMenu = pMenu->GetSubMenu (i);
CString strCategory = strText;
if (lpszCategory != NULL)
{
strCategory = lpszCategory;
}
if (m_bAutoSetFromMenus)
{
if (bPopup)
{
AddButton (strCategory,
CBCGToolbarMenuButton ((UINT) -1, pSubMenu->GetSafeHmenu (),
-1,
strText));
}
AddMenuCommands (pSubMenu, TRUE, strCategory);
}
else
{
AddMenuCommands (pSubMenu, TRUE);
}
}
break;
default:
AddButton (lpszCategory == NULL ?
m_strAllCommands : lpszCategory,
CBCGToolbarButton (uiCmd, -1, strText));
}
}*/
}
//******************************************************************************************
void CCustomizePropSheet::FiilCategotiesComboBox (CComboBox& wndCategory) const
{
/*CObList* pCategoryButtonsList;
for (POSITION pos = m_strCategoriesList.GetHeadPosition(); pos != NULL;)
{
CString strCategory = m_strCategoriesList.GetNext (pos);
if (!m_ButtonsByCategory.Lookup (strCategory, pCategoryButtonsList))
{
ASSERT (FALSE);
}
ASSERT_VALID (pCategoryButtonsList);
int iIndex = wndCategory.AddString (strCategory);
wndCategory.SetItemData (iIndex, (DWORD) pCategoryButtonsList);
}
// "All" category should be last!
if (!m_ButtonsByCategory.Lookup (m_strAllCommands, pCategoryButtonsList))
{
ASSERT (FALSE);
}
ASSERT_VALID (pCategoryButtonsList);
int iIndex = wndCategory.AddString (m_strAllCommands);
wndCategory.SetItemData (iIndex, (DWORD) pCategoryButtonsList);*/
}
//******************************************************************************************
void CCustomizePropSheet::FiilCategotiesListBox (CListBox& wndCategory) const
{
/*CObList* pCategoryButtonsList;
for (POSITION pos = m_strCategoriesList.GetHeadPosition(); pos != NULL;)
{
CString strCategory = m_strCategoriesList.GetNext (pos);
if (!m_ButtonsByCategory.Lookup (strCategory, pCategoryButtonsList))
{
ASSERT (FALSE);
}
ASSERT_VALID (pCategoryButtonsList);
int iIndex = wndCategory.AddString (strCategory);
wndCategory.SetItemData (iIndex, (DWORD) pCategoryButtonsList);
}
// "All" category should be last!
if (!m_ButtonsByCategory.Lookup (m_strAllCommands, pCategoryButtonsList))
{
ASSERT (FALSE);
}
ASSERT_VALID (pCategoryButtonsList);
int iIndex = wndCategory.AddString (m_strAllCommands);
wndCategory.SetItemData (iIndex, (DWORD) pCategoryButtonsList);*/
}
//*******************************************************************************************
void CCustomizePropSheet::FillAllCommandsList (CListBox& wndListOfCommands) const
{
/*wndListOfCommands.ResetContent ();
CObList* pAllButtonsList;
if (!m_ButtonsByCategory.Lookup (m_strAllCommands, pAllButtonsList))
{
return;
}
ASSERT_VALID (pAllButtonsList);
for (POSITION pos = pAllButtonsList->GetHeadPosition (); pos != NULL;)
{
CBCGToolbarButton* pButton = (CBCGToolbarButton*) pAllButtonsList->GetNext (pos);
ASSERT (pButton != NULL);
int iIndex = wndListOfCommands.AddString (pButton->m_strText);
wndListOfCommands.SetItemData (iIndex, (DWORD) pButton->m_nID);
}*/
}
//***************************************************************************************
BOOL CCustomizePropSheet::OnHelpInfo(HELPINFO* /*pHelpInfo*/)
{
//ASSERT_VALID (m_pParentFrame);
//m_pParentFrame->SendMessage (BCGM_CUSTOMIZEHELP, GetActiveIndex (), (LPARAM) this);
return TRUE;
}
//***************************************************************************************
LPCTSTR CCustomizePropSheet::GetCommandName (UINT uiCmd) const
{
/*CObList* pAllButtonsList;
if (!m_ButtonsByCategory.Lookup (m_strAllCommands, pAllButtonsList))
{
return NULL;
}
ASSERT_VALID (pAllButtonsList);
for (POSITION pos = pAllButtonsList->GetHeadPosition (); pos != NULL;)
{
CBCGToolbarButton* pButton = (CBCGToolbarButton*) pAllButtonsList->GetNext (pos);
ASSERT (pButton != NULL);
if (pButton->m_nID == uiCmd)
{
return pButton->m_strText;
}
}*/
return NULL;
}
//***************************************************************************************
void CCustomizePropSheet::SetupFromMenus ()
{
/*
//-------------------------------------------------------------------
// Find all application document templates and add menue items to the
// "All commands" category:
//------------------------------------------------------------------
CDocManager* pDocManager = AfxGetApp ()->m_pDocManager;
if (pDocManager != NULL)
{
//---------------------------------------
// Walk all templates in the application:
//---------------------------------------
for (POSITION pos = pDocManager->GetFirstDocTemplatePosition (); pos != NULL;)
{
CMultiDocTemplate* pTemplate =
DYNAMIC_DOWNCAST ( CMultiDocTemplate,
pDocManager->GetNextDocTemplate (pos));
if (pTemplate != NULL)
{
CMenu* pDocMenu = CMenu::FromHandle (pTemplate->m_hMenuShared);
if (pDocMenu != NULL)
{
AddMenuCommands (pDocMenu, FALSE);
}
}
}
}
//------------------------------------
// Add commands from the default menu:
//------------------------------------
CMenu* pFrameMenu = CMenu::FromHandle (m_pParentFrame->m_hMenuDefault);
if (pFrameMenu == NULL)
{
CBCGMDIFrameWnd* pMainMDIFrame = DYNAMIC_DOWNCAST (CBCGMDIFrameWnd, m_pParentFrame);
const CBCGMenuBar* pMenuBar = NULL;
if (pMainMDIFrame != NULL)
{
pMenuBar = pMainMDIFrame->GetMenuBar ();
}
else
{
CBCGFrameWnd* pMainFrame = DYNAMIC_DOWNCAST (CBCGFrameWnd, m_pParentFrame);
if (pMainFrame != NULL)
{
pMenuBar = pMainFrame->GetMenuBar ();
}
}
if (pMenuBar != NULL)
{
pFrameMenu = CMenu::FromHandle (pMenuBar->GetDefaultMenu ());
}
}
if (pFrameMenu != NULL)
{
AddMenuCommands (pFrameMenu, FALSE);
}*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -