-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAccelPropertySheet.cpp
121 lines (106 loc) · 2.81 KB
/
AccelPropertySheet.cpp
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// AccelPropertySheet.cpp : implementation file
//
// $Id$
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "phreeqci2.h"
#include "AccelPropertySheet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAccelPropertySheet
IMPLEMENT_DYNAMIC(CAccelPropertySheet, baseAccelPropertySheet)
CAccelPropertySheet::CAccelPropertySheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
:baseAccelPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
}
CAccelPropertySheet::CAccelPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
:baseAccelPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
}
CAccelPropertySheet::~CAccelPropertySheet()
{
}
BEGIN_MESSAGE_MAP(CAccelPropertySheet, baseAccelPropertySheet)
//{{AFX_MSG_MAP(CAccelPropertySheet)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAccelPropertySheet message handlers
BOOL CAccelPropertySheet::PreTranslateMessage(MSG* pMsg)
{
// Handle accelerator keys
if (pMsg->message == WM_SYSKEYDOWN)
{
TCHAR buffer[100];
CTabCtrl* pTabCtrl = GetTabControl();
// load tab accelerators
// Won't handle pages added on the fly
if (pTabCtrl && pTabCtrl->GetSafeHwnd() && m_accel.IsEmpty())
{
CString str;
int nTabs = pTabCtrl->GetItemCount();
TCITEM item;
item.mask = TCIF_TEXT;
item.cchTextMax = 100;
item.pszText = buffer;
int nPos;
for (int i = 0; i < nTabs; ++i)
{
pTabCtrl->GetItem(i, &item);
str = item.pszText;
nPos = str.Find("&", 0);
if (nPos != -1 && ((nPos + 1) < str.GetLength()))
{
int j = toupper(str.GetAt(nPos + 1));
// make sure accelerator not already defined
ASSERT(m_accel.Lookup(j, i) == FALSE);
m_accel.SetAt(j, i);
}
}
}
if (!m_accel.IsEmpty())
{
int nPage;
if (m_accel.Lookup((int)pMsg->wParam, nPage))
{
if (GetActiveIndex() != nPage)
SetActivePage(nPage);
return TRUE; /* handled */
}
}
}
// Set focus to next control on Ctrl+Tab
// and to previous control on Shift+Ctrl+Tab
if (pMsg->message == WM_KEYDOWN)
{
switch (pMsg->wParam)
{
case VK_TAB :
TRACE("CPropertySheetAccel::PreTranslateMessage\n");
if (GetKeyState(VK_SHIFT) < 0)
{
GetActivePage()->PrevDlgCtrl();
}
else
{
GetActivePage()->NextDlgCtrl();
}
{
CWnd* pWnd = GetFocus();
if (pWnd != NULL)
pWnd->SetFocus();
}
return TRUE; /* handled */
break;
default :
return baseAccelPropertySheet::PreTranslateMessage(pMsg);
break;
}
}
return baseAccelPropertySheet::PreTranslateMessage(pMsg);
}