📄 bcgpkeyboardpage.cpp
字号:
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) pButton);
}
}
m_wndNewKey.EnableWindow (FALSE);
m_wndCommandsList.SetCurSel (0);
OnSelchangeCommandsList ();
}
//******************************************************************
void CBCGPKeyboardPage::OnSelchangeCommandsList()
{
m_strDesrcription.Empty ();
m_wndCurrentKeysList.ResetContent ();
OnSelchangeCurrentKeysList ();
int iIndex = m_wndCommandsList.GetCurSel ();
if (iIndex == LB_ERR)
{
m_pSelButton = NULL;
m_wndNewKey.EnableWindow (FALSE);
UpdateData (FALSE);
return;
}
//-------------------------
// Set command description:
//-------------------------
m_pSelButton = (CBCGPToolbarButton*) m_wndCommandsList.GetItemData (iIndex);
ASSERT_VALID (m_pSelButton);
CFrameWnd* pParent = GetParentFrame ();
if (pParent != NULL && pParent->GetSafeHwnd () != NULL)
{
pParent->GetMessageString (m_pSelButton->m_nID,
m_strDesrcription);
}
//--------------------------------------------
// Fill keys associated with selected command:
//--------------------------------------------
if (m_lpAccel != NULL)
{
for (int i = 0; i < m_nAccelSize; i ++)
{
if (m_pSelButton->m_nID == m_lpAccel [i].cmd)
{
AddKeyEntry (&m_lpAccel [i]);
}
}
}
m_wndNewKey.EnableWindow ();
UpdateData (FALSE);
}
//******************************************************************
void CBCGPKeyboardPage::OnSelchangeCurrentKeysList()
{
int iIndex = m_wndCurrentKeysList.GetCurSel ();
if (iIndex == LB_ERR)
{
m_pSelEntry = NULL;
m_wndRemoveButton.EnableWindow (FALSE);
return;
}
m_pSelEntry = (LPACCEL) m_wndCurrentKeysList.GetItemData (iIndex);
ASSERT (m_pSelEntry != NULL);
m_wndRemoveButton.EnableWindow ();
}
//******************************************************************
void CBCGPKeyboardPage::OnRemove()
{
ASSERT (m_pSelEntry != NULL);
ASSERT (m_lpAccel != NULL);
//----------------------------
// Create a new entries array:
//----------------------------
LPACCEL lpAccelOld = m_lpAccel;
m_lpAccel = new ACCEL [m_nAccelSize - 1];
ASSERT (m_lpAccel != NULL);
int iNewIndex = 0;
for (int i = 0; i < m_nAccelSize; i ++)
{
if (m_pSelEntry != &lpAccelOld [i])
{
m_lpAccel [iNewIndex ++] = lpAccelOld [i];
int listcount = m_wndCurrentKeysList.GetCount();
for (int idx=0; idx<listcount; idx++)
{
if ( m_wndCurrentKeysList.GetItemData(idx) == (DWORD) &lpAccelOld [i] )
{
m_wndCurrentKeysList.SetItemData(idx, (DWORD) &m_lpAccel [iNewIndex-1]);
break;
}
}
}
}
delete lpAccelOld;
m_nAccelSize --;
g_pKeyboardManager->UpdateAcellTable (
m_pSelTemplate, m_lpAccel, m_nAccelSize);
OnSelchangeCommandsList ();
m_wndCommandsList.SetFocus ();
}
//******************************************************************
void CBCGPKeyboardPage::OnResetAll()
{
{
CBCGPLocalResource locaRes;
CString str;
str.LoadString (IDS_BCGBARRES_RESET_KEYBOARD);
if (MessageBox (str, NULL, MB_YESNO | MB_ICONQUESTION) != IDYES)
{
return;
}
}
g_pKeyboardManager->ResetAll ();
//---------------------------------------------
// Send notification to application main frame:
//---------------------------------------------
if (m_pParentFrame != NULL)
{
m_pParentFrame->SendMessage (BCGM_RESETKEYBOARD);
}
OnSelchangeViewType();
OnSelchangeCommandsList ();
}
//******************************************************************
void CBCGPKeyboardPage::OnSelchangeViewType()
{
m_hAccelTable = NULL;
m_pSelTemplate = NULL;
if (m_lpAccel != NULL)
{
delete m_lpAccel;
m_lpAccel = NULL;
}
int iIndex = m_wndViewTypeList.GetCurSel ();
if (iIndex == CB_ERR)
{
m_wndViewIcon.SetIcon (NULL);
return;
}
HICON hicon = NULL;
CBCGPMultiDocTemplate* pTemplate =
(CBCGPMultiDocTemplate*) m_wndViewTypeList.GetItemData (iIndex);
if (pTemplate != NULL)
{
ASSERT_VALID (pTemplate);
hicon = AfxGetApp ()->LoadIcon (pTemplate->GetResId ());
m_hAccelTable = pTemplate->m_hAccelTable;
}
else
{
CFrameWnd* pWndMain = DYNAMIC_DOWNCAST (CFrameWnd, m_pParentFrame);
if (pWndMain != NULL)
{
hicon = (HICON) GetClassLong (*pWndMain, GCL_HICON);
m_hAccelTable = pWndMain->m_hAccelTable;
}
}
if (hicon == NULL)
{
hicon = ::LoadIcon(NULL, IDI_APPLICATION);
}
m_wndViewIcon.SetIcon (hicon);
ASSERT (m_hAccelTable != NULL);
m_nAccelSize = ::CopyAcceleratorTable (m_hAccelTable, NULL, 0);
m_lpAccel = new ACCEL [m_nAccelSize];
ASSERT (m_lpAccel != NULL);
::CopyAcceleratorTable (m_hAccelTable, m_lpAccel, m_nAccelSize);
m_pSelTemplate = pTemplate;
OnSelchangeCommandsList ();
}
//******************************************************************
void CBCGPKeyboardPage::AddKeyEntry (LPACCEL pEntry)
{
ASSERT (pEntry != NULL);
CBCGPKeyHelper helper (pEntry);
CString str;
helper.Format (str);
int iIndex = m_wndCurrentKeysList.AddString (str);
m_wndCurrentKeysList.SetItemData (iIndex, (DWORD) pEntry);
}
//******************************************************************
void CBCGPKeyboardPage::OnUpdateNewShortcutKey()
{
ACCEL* pAccel = (ACCEL*) m_wndNewKey.GetAccel ();
ASSERT (pAccel != NULL);
m_strAssignedTo.Empty ();
m_wndAssignedToTitle.ShowWindow (SW_HIDE);
m_wndAssignButton.EnableWindow (FALSE);
if (m_wndNewKey.IsKeyDefined ())
{
ASSERT (m_lpAccel != NULL);
BOOL bIsAlreadyDefined = FALSE;
for (int i = 0; !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("????");
}
bIsAlreadyDefined = TRUE;
}
}
if (!bIsAlreadyDefined)
{
CBCGPLocalResource locaRes;
m_strAssignedTo.LoadString (IDP_BCGBARRES_UNASSIGNED);
m_wndAssignButton.EnableWindow ();
}
m_wndAssignedToTitle.ShowWindow (SW_SHOW);
}
UpdateData (FALSE);
}
//*************************************************************************************
void CBCGPKeyboardPage::SetAllCategory (LPCTSTR lpszCategory)
{
ASSERT (lpszCategory != NULL);
m_strAllCategory = lpszCategory;
}
#endif // BCG_NO_CUSTOMIZATION
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -