-
Notifications
You must be signed in to change notification settings - Fork 0
/
GroupCombo.cpp
116 lines (92 loc) · 2.13 KB
/
GroupCombo.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
// GroupCombo.cpp : implementation file
//
#include "stdafx.h"
#include "cp_main.h"
#include "GroupCombo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGroupCombo
//##ModelId=474D306600AE
CGroupCombo::CGroupCombo()
{
m_lSkipGroupID = -1;
}
//##ModelId=474D306600AF
CGroupCombo::~CGroupCombo()
{
}
BEGIN_MESSAGE_MAP(CGroupCombo, CComboBox)
//{{AFX_MSG_MAP(CGroupCombo)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGroupCombo message handlers
//##ModelId=474D306600BD
void CGroupCombo::FillCombo()
{
ResetContent();
int nIndex = AddString(_T("--NONE--"));
SetItemData(nIndex, 0);
FillCombo(-1, 1);
}
//##ModelId=474D306600CC
void CGroupCombo::FillCombo(long lParentID, long lSpaces)
{
try
{
int nIndex;
CString csSpaces;
for(int i = 0; i < lSpaces; i++)
{
csSpaces += "---";
}
//First time through
if(lSpaces > 0)
{
csSpaces += " ";
//ResetContent();
}
lSpaces++;
CppSQLite3Query q = theApp.m_db.execQueryEx(_T("SELECT lID, mText FROM Main WHERE bIsGroup = 1 AND lParentID = %d"), lParentID);
if(q.eof() == false)
{
while(!q.eof())
{
if(q.getIntField(_T("lID")) != m_lSkipGroupID)
{
nIndex = AddString(csSpaces + q.getStringField(_T("mText")));
SetItemData(nIndex, q.getIntField(_T("lID")));
FillCombo(q.getIntField(_T("lID")), lSpaces);
}
q.nextRow();
}
}
}
CATCH_SQLITE_EXCEPTION
}
//##ModelId=474D306600DD
BOOL CGroupCombo::SetCurSelOnItemData(long lItemData)
{
long lCount = GetCount();
for(int i = 0; i < lCount; i++)
{
if(GetItemData(i) == lItemData)
{
SetCurSel(i);
return TRUE;
}
}
SetCurSel(-1);
return FALSE;
}
//##ModelId=474D306600EC
int CGroupCombo::GetItemDataFromCursel()
{
int nCursel = GetCurSel();
return (int)GetItemData(nCursel);
}