In
the ClassWizard dialog
box, select the Message Maps
tab and in the Class Name
box,
select the class CTestVC0Dlg.
In
the Member Functions
list, select the function name - OnSelchangeTab1:
Choose Edit Code
-or-
Double-click the function name.
The insertion point moves to the function
in theTestVC0Dlg.cpp file.
Edit the Text
Code, examine these changes ...
TestVC0Dlg.cpp file - the new Text
Code is red.
// TestVC0Dlg.cpp
: implementation file
//
...
...................................................................................................................................................
...................................................................................................................................................
void CTestVC0Dlg::OnSelchangeTab1(NMHDR*
pNMHDR, LRESULT* pResult)
{
int ntab = m_tab1.GetCurSel();
switch(ntab)
{
case 0: //tab label = By word
{
m_staticsel.ShowWindow(SW_HIDE);
m_combobook.ShowWindow(SW_HIDE);
m_combotitle.ShowWindow(SW_HIDE);
m_combochapter.ShowWindow(SW_HIDE);
m_comboverse.ShowWindow(SW_HIDE);
m_staticbook.ShowWindow(SW_HIDE);
m_statictitle.ShowWindow(SW_HIDE);
m_staticchapter.ShowWindow(SW_HIDE);
m_staticverse.ShowWindow(SW_HIDE);
m_searchlist.ShowWindow(SW_SHOW);
m_edwordcontrol.ShowWindow(SW_SHOW);
m_display.ShowWindow(SW_SHOW);
m_statictype.ShowWindow(SW_SHOW);
m_staticfoundcontrol.ShowWindow(SW_SHOW);
break;
}
case 1: //tab label = By address
{
m_staticsel.ShowWindow(SW_SHOW);
m_combobook.ShowWindow(SW_SHOW);
m_combotitle.ShowWindow(SW_SHOW);
m_combochapter.ShowWindow(SW_SHOW);
m_comboverse.ShowWindow(SW_SHOW);
m_staticbook.ShowWindow(SW_SHOW);
m_statictitle.ShowWindow(SW_SHOW);
m_staticchapter.ShowWindow(SW_SHOW);
m_staticverse.ShowWindow(SW_SHOW);
m_searchlist.ShowWindow(SW_HIDE);
m_edwordcontrol.ShowWindow(SW_HIDE);
m_display.ShowWindow(SW_HIDE);
m_statictype.ShowWindow(SW_HIDE);
m_staticfoundcontrol.ShowWindow(SW_HIDE);
//
break;
// }
// }
//************************
Work with ComboBoxes **
//Recordset declaration
if (m_pRSW0)
if (m_pRSW0->IsOpen())
m_pRSW0->Close();
delete m_pRSW0;
m_pRSW0 = new CDaoRecordset(m_pDB);
m_pRSW0->Open(dbOpenDynaset,
"SELECT * from BibleTable",
0);
//Clear the comboboxes
m_combobook.ResetContent();
m_combotitle.ResetContent();
m_combochapter.ResetContent();
m_comboverse.ResetContent();
m_combobookrecno.ResetContent();
m_combotitlerecno.ResetContent();
m_combochapterrecno.ResetContent();
m_comboverserecno.ResetContent();
//Move to 2nd record
m_pRSW0->Move(2);
while (!m_pRSW0->IsEOF())
{
//Absolute position of record
pos = m_pRSW0->GetAbsolutePosition();
ltoa(pos,chrrecno,10);
//Values of Book, Title, Chapter
and Verse fields
varbook1 = m_pRSW0->GetFieldValue(_T("Book"));
vartitle = m_pRSW0->GetFieldValue(_T("BookTitle"));
varchapter1 = m_pRSW0->GetFieldValue(_T("Chapter"));
varverse1 = m_pRSW0->GetFieldValue(_T("Verse"));
if (CString(V_BSTRT(&varbook1))
!= m_book)
{
if ((CString(V_BSTRT(&varchapter1))
== "001") && (CString(V_BSTRT(&varverse1))
== "001"))
{
//Add item to book and title
comboboxes
m_combobook.AddString(CString(V_BSTRT(&varbook1)));
m_combotitle.AddString(CString(V_BSTRT(&vartitle)));
//Add item to bookrecno and
titlerecno comboboxes
m_combobookrecno.AddString(CString(chrrecno));
m_combotitlerecno.AddString(CString(chrrecno));
}
}
else
{
if ((CString(V_BSTRT(&varchapter1))
== "001") && (CString(V_BSTRT(&varverse1))
== "001"))
{
//Add item to book and title
comboboxes
m_combobook.AddString(CString(V_BSTRT(&varbook1)));
m_combotitle.AddString(CString(V_BSTRT(&vartitle)));
//Add item to bookrecno and
titlerecno comboboxes
m_combobookrecno.AddString(CString(chrrecno));
m_combotitlerecno.AddString(CString(chrrecno));
}
if (CString(V_BSTRT(&varchapter1))
!= m_chapter)
{
if (CString(V_BSTRT(&varverse1))
== "001")
{
//Add item to chapter and
chapterrecno comboboxes
m_combochapter.AddString(CString(V_BSTRT(&varchapter1)));
m_combochapterrecno.AddString(CString(chrrecno));
}
}
else
{
if (CString(V_BSTRT(&varverse1))
== "001")
{
//Add item to chapter and verse
comboboxes
m_combochapter.AddString(CString(V_BSTRT(&varchapter1)));
m_comboverse.AddString(CString(V_BSTRT(&varverse1)));
//Add item to chapterrecno and
verserecno comboboxes
m_combochapterrecno.AddString(CString(chrrecno));
m_comboverserecno.AddString(CString(chrrecno));
}
else
{
//Add item to verse and
verserecno comboboxes
m_comboverse.AddString(CString(V_BSTRT(&varverse1)));
m_comboverserecno.AddString(CString(chrrecno));
}
}
}
m_pRSW0->MoveNext();
}
break;
}
}
UpdateData(FALSE);
//Values display in the current
strings of Comboboxes
CString varcombo;
int varcount = m_combobook.GetCount();
for( int i =
0; i < varcount; ++i )
{
m_combobook.GetLBText(i,varcombo);
if (varcombo == m_book)
{
m_combobook.SetCurSel(i);
m_combotitle.SetCurSel(i);
goto Ptbook;
}
}
Ptbook:
varcount = m_combochapter.GetCount();
for( i = 0; i < varcount; ++i
)
{
m_combochapter.GetLBText(i,varcombo);
if (varcombo == m_chapter)
{
m_combochapter.SetCurSel(i);
goto Ptchapter;
}
}
Ptchapter:
varcount = m_comboverse.GetCount();
for( i = 0; i < varcount; ++i
)
{
m_comboverse.GetLBText(i,varcombo);
if (varcombo == m_verse)
{
m_comboverse.SetCurSel(i);
goto Ptverse;
}
}
Ptverse:
// TODO: Add your control
notification handler code here
*pResult = 0;
} |
|