📄 searchdlg.cpp
字号:
// SearchDlg.cpp : implementation file
//
#include "stdafx.h"
#include "DiamondReader.h"
#include "SearchDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSearchDlg dialog
CSearchDlg::CSearchDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSearchDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSearchDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
CSearchDlg::CSearchDlg(char **key,int *type,char **start,char **end,CWnd *pParent /* = NULL */)
: CDialog(CSearchDlg::IDD, pParent)
{
this->key = key;
this->start = start;
this->end = end;
this->type = type;
*(this->start) = new char[20];
*(this->end) = new char[20];
strcpy(*(this->start),"0000/00/00 00:00:00");
strcpy(*(this->end),"9999/12/31 23:59:59");
b_s = false;
b_e = false;
}
void CSearchDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSearchDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSearchDlg, CDialog)
//{{AFX_MSG_MAP(CSearchDlg)
ON_BN_CLICKED(IDC_CHECK_STARTTIME, OnCheckStarttime)
ON_BN_CLICKED(IDC_CHECK_ENDTIME, OnCheckEndtime)
ON_BN_CLICKED(IDC_SEARCHDLG_START_SEARCH, OnSearchdlgStartSearch)
ON_WM_CLOSE()
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSearchDlg message handlers
void CSearchDlg::OnCheckStarttime()
{
// TODO: Add your control notification handler code here
CDateTimeCtrl *startCtrl = (CDateTimeCtrl*)this->GetDlgItem(IDC_DATETIMEPICKER_STARTTIME);
CButton *btn = (CButton*)this->GetDlgItem(IDC_CHECK_STARTTIME);
b_s = !b_s;
if (!b_s)
{
startCtrl->EnableWindow(false);
}
else
{
startCtrl->EnableWindow(TRUE);
}
}
BOOL CSearchDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CButton *startCheck = (CButton*)this->GetDlgItem(IDC_CHECK_STARTTIME);
CButton *endCheck = (CButton*)this->GetDlgItem(IDC_CHECK_ENDTIME);
startCheck->SetCheck(BST_UNCHECKED);
endCheck->SetCheck(BST_UNCHECKED);
CDateTimeCtrl *endtCtrl = (CDateTimeCtrl*)this->GetDlgItem(IDC_DATETIMEPICKER_ENDTIME);
CDateTimeCtrl *startCtrl = (CDateTimeCtrl*)this->GetDlgItem(IDC_DATETIMEPICKER_STARTTIME);
endtCtrl->EnableWindow(false);
startCtrl->EnableWindow(false);
CComboBox *searchType = (CComboBox*)this->GetDlgItem(IDC_COMBO_SEARCHTYPE);
searchType->InsertString(0,TEXT("标题"));
searchType->InsertString(1,TEXT("作者"));
searchType->SetCurSel(0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSearchDlg::OnCheckEndtime()
{
// TODO: Add your control notification handler code here
CDateTimeCtrl *endtCtrl = (CDateTimeCtrl*)this->GetDlgItem(IDC_DATETIMEPICKER_ENDTIME);
CButton *btn = (CButton*)this->GetDlgItem(IDC_CHECK_ENDTIME);
b_e = !b_e;
if (!b_e)
{
endtCtrl->EnableWindow(false);
}
else
{
endtCtrl->EnableWindow(TRUE);
}
}
void CSearchDlg::OnSearchdlgStartSearch()
{
// TODO: Add your control notification handler code here
CEdit *keyEdit = (CEdit*)this->GetDlgItem(IDC_EDIT_SEARCHKEY);
CComboBox *keyTypeCombox = (CComboBox*)this->GetDlgItem(IDC_COMBO_SEARCHTYPE);
CDateTimeCtrl *startTimeCtrl = (CDateTimeCtrl*)this->GetDlgItem(IDC_DATETIMEPICKER_STARTTIME);
CDateTimeCtrl *endTimeCtrl = (CDateTimeCtrl*)this->GetDlgItem(IDC_DATETIMEPICKER_ENDTIME);
int keyLength = keyEdit->LineLength(0);
*key = new char[keyLength+1];
keyEdit->GetLine(0,*key);
CString cs;
keyEdit->GetWindowText(cs);
strcpy(*key,(LPTSTR)(LPCTSTR)cs);
CTime starttime,endtime;
CString s_start,s_end;
if (startTimeCtrl->IsWindowEnabled())
{
startTimeCtrl->GetTime(starttime);
s_start = starttime.Format(TEXT("%Y/%m/%d %H:%M:%S"));
strncpy(*(this->start),s_start,20);
}
if (endTimeCtrl->IsWindowEnabled())
{
endTimeCtrl->GetTime(endtime);
s_end = endtime.Format(TEXT("%Y/%m/%d %H:%M:%S"));
strncpy(*(this->end),s_end,20);
}
*type = keyTypeCombox->GetCurSel();
EndDialog(1);
}
void CSearchDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
EndDialog(0);
CDialog::OnClose();
}
int CSearchDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -