-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathPaneToolBar.cpp
More file actions
75 lines (61 loc) · 1.59 KB
/
PaneToolBar.cpp
File metadata and controls
75 lines (61 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "stdafx.h"
#include "PaneToolBar.h"
CPaneToolBar::CPaneToolBar()
{
m_nSize = 0;
m_pAccel = nullptr;
}
CPaneToolBar::~CPaneToolBar()
{
delete[] m_pAccel;
}
void CPaneToolBar::OnUpdateCmdUI(CFrameWnd *, BOOL bDisableIfNoHndler)
{
CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler);
}
BOOL CPaneToolBar::OnUserToolTip(CMFCToolBarButton * pButton, CString & strTTText) const
{
TCHAR szFullText[256];
AfxLoadString(pButton->m_nID, szFullText);
AfxExtractSubString(strTTText, szFullText, 1, '\n');
if (m_bShowShortcutKeys)
{
CString strAccelText;
BOOL bFound = FALSE;
for (int i = 0; i < m_nSize; i++)
{
if (m_pAccel[i].cmd == pButton->m_nID)
{
bFound = TRUE;
CMFCAcceleratorKey helper(&m_pAccel[i]);
CString strKey;
helper.Format(strKey);
if (!strAccelText.IsEmpty())
{
strAccelText += _T("; ");
}
strAccelText += strKey;
#if 0
if (!m_bAllAccelerators)
{
break;
}
#endif
}
}
if (bFound)
{
strTTText += _T(" (");
strTTText += strAccelText;
strTTText += _T(')');
}
}
return TRUE;
}
void CPaneToolBar::SetAccel(HACCEL hAccel)
{
m_nSize = ::CopyAcceleratorTable(hAccel, nullptr, 0);
delete[] m_pAccel;
m_pAccel = new ACCEL[m_nSize];
::CopyAcceleratorTable(hAccel, m_pAccel, m_nSize);
}