-
Notifications
You must be signed in to change notification settings - Fork 1
/
MacroDefineDialog.cpp
98 lines (77 loc) · 2.51 KB
/
MacroDefineDialog.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
// MacroDefineDialog.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "MacroDefineDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMacroDefineDialog dialog
CMacroDefineDialog::CMacroDefineDialog(CWnd* pParent /*=NULL*/)
: CDialog(CMacroDefineDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CMacroDefineDialog)
//}}AFX_DATA_INIT
}
void CMacroDefineDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMacroDefineDialog)
DDX_Control(pDX, IDC_MACRO_NAME, m_edtMacroName);
DDX_Control(pDX, IDC_MACRO_LIST, m_lstMacro);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMacroDefineDialog, CDialog)
//{{AFX_MSG_MAP(CMacroDefineDialog)
ON_WM_DESTROY()
ON_NOTIFY(LVN_ITEMCHANGED, IDC_MACRO_LIST, OnItemchangedMacroList)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMacroDefineDialog message handlers
BOOL CMacroDefineDialog::OnInitDialog()
{
CString szText;
CDialog::OnInitDialog();
szText.LoadString(IDS_CTRL_DEFINE_MACRO_NO);
m_lstMacro.InsertColumn(0, szText, LVCFMT_LEFT, 40);
szText.LoadString(IDS_CTRL_DEFINE_MACRO_NAME);
m_lstMacro.InsertColumn(1, szText, LVCFMT_LEFT, 145);
m_lstMacro.SetExtendedStyle(LVS_EX_FULLROWSELECT);
for(INT i = 0; i < 10; i++) {
CString szText; szText.Format("%d", (i+1) % 10);
m_lstMacro.InsertItem(i, szText);
m_lstMacro.SetItemText(i, 1, m_szMacroName[i+1]);
}
m_lstMacro.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
m_nSelected = 1;
CString szMacroName; szMacroName.LoadString(IDS_CTRL_DEFINE_MACRO_NEW);
m_edtMacroName.SetWindowText(szMacroName);
return TRUE;
}
void CMacroDefineDialog::OnDestroy()
{
CString szMacroName; m_edtMacroName.GetWindowText( szMacroName );
for(INT i = 0; i < 10; i++) {
if( m_lstMacro.GetItemState(i, LVIS_SELECTED) ) {
m_szMacroName[i+1] = szMacroName;
m_nSelected = i+1;
}
}
CDialog::OnDestroy();
}
void CMacroDefineDialog::OnItemchangedMacroList(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
if( (pNMListView->iItem >= 0) && (pNMListView->uNewState & LVIS_SELECTED) ) {
INT nMacro = pNMListView->iItem;
CString szMacroName = m_lstMacro.GetItemText( nMacro, 1 );
if( szMacroName == "- Empty -" ) szMacroName = "";
if( szMacroName == "[Noname]" ) szMacroName = "";
m_edtMacroName.SetWindowText( szMacroName );
}
*pResult = 0;
}