This repository has been archived on 2024-03-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
ContactBook/FindDlg.cpp
2024-03-20 09:28:18 -05:00

93 lines
2.2 KiB
C++

// finddlg.cpp : implementation file
//
#include "stdafx.h"
#include <stddef.h>
#include "CB32.h"
#include "ComboBar.h"
#include "MainFrm.h"
#include "CB32Doc.h"
#include "CB32View.h"
#include "FindDlg.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFindDlg dialog
CFindDlg::CFindDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFindDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFindDlg)
m_bMatchCase = FALSE;
m_szText = _T("");
m_nDirection = 1; // down by default
m_bStartTop = FALSE;
m_nWhichName = 0;
//}}AFX_DATA_INIT
}
void CFindDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFindDlg)
DDX_Control(pDX, IDC_FCOMBO, m_strList);
DDX_Check(pDX, IDC_CHECK1, m_bMatchCase);
DDX_CBString(pDX, IDC_COMBO1, m_szText);
DDX_Radio(pDX, IDC_RADIO1, m_nDirection);
DDX_Check(pDX, IDC_CHECK2, m_bStartTop);
DDX_CBIndex(pDX, IDC_FCOMBO, m_nWhichName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFindDlg, CDialog)
//{{AFX_MSG_MAP(CFindDlg)
ON_BN_CLICKED(ID_EDIT_FIND_NEXT, OnEditFindNext)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFindDlg message handlers
void CFindDlg::OnEditFindNext()
{
// the user selected to search. see if there is a search pattern in the edit control
// using the default data exchange.
// if no search string is present, keep the dialog box up.
UpdateData(TRUE);
if (!m_szText.GetLength())
{
MessageBeep(MB_ICONEXCLAMATION);
GotoDlgCtrl(GetDlgItem(IDC_COMBO1));
return ;
}
EndDialog(TRUE);
GetApplicationView()->m_searchHistory.AddString(m_szText);
}
BOOL CFindDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CWnd* pWnd = GetDlgItem(IDC_COMBO1);
CCB32View* pView = GetApplicationView();
pView->m_searchHistory.FillCombobox();
for (int y=0; y < COLS; y++)
m_strList.AddString(pView->arLabel[y]);
m_strList.SetCurSel(m_nWhichName);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}