📄 dlgoptioncnt.cpp
字号:
// DlgOptionCnt.cpp : implementation file
//
#include "stdafx.h"
#include "StockRefer.h"
#include "DlgOptionCnt.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define SEARCH_TIME_MIN 15
#define SEARCH_TIME_MAX 300
#define MIN_INGORE_NUM 50
#define MAX_INGORE_NUM 10000
#define ACC_INGORE_NUM 50
/////////////////////////////////////////////////////////////////////////////
// CDlgOptionCnt property page
IMPLEMENT_DYNCREATE(CDlgOptionCnt, CPropertyPage)
CDlgOptionCnt::CDlgOptionCnt() : CPropertyPage(CDlgOptionCnt::IDD)
{
//{{AFX_DATA_INIT(CDlgOptionCnt)
//}}AFX_DATA_INIT
}
CDlgOptionCnt::~CDlgOptionCnt()
{
}
void CDlgOptionCnt::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgOptionCnt)
DDX_Control(pDX, IDC_EDIT_THREAD, m_edThread);
DDX_Control(pDX, IDC_STATIC_TIME, m_strTime);
DDX_Control(pDX, IDC_STATIC_THREAD, m_icoThread);
DDX_Control(pDX, IDC_STATIC_PROXY, m_icoProxy);
DDX_Control(pDX, IDC_SPIN_THREAD, m_spThread);
DDX_Control(pDX, IDC_SPIN_INGORE, m_spIngore);
DDX_Control(pDX, IDC_SLIDER_TIME, m_sliTime);
DDX_Control(pDX, IDC_EDIT_URL, m_edURL);
DDX_Control(pDX, IDC_EDIT_PORT, m_edPort);
DDX_Control(pDX, IDC_EDIT_INGORE, m_edIngore);
DDX_Control(pDX, IDC_CHECK_PROXY, m_chkProxy);
DDX_Control(pDX, IDC_CHECK_INGORE, m_chkIngore);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgOptionCnt, CPropertyPage)
//{{AFX_MSG_MAP(CDlgOptionCnt)
ON_BN_CLICKED(IDC_CHECK_INGORE, OnCheckIngore)
ON_BN_CLICKED(IDC_CHECK_PROXY, OnCheckProxy)
ON_EN_KILLFOCUS(IDC_EDIT_THREAD, OnKillfocusEditThread)
ON_WM_HSCROLL()
ON_EN_KILLFOCUS(IDC_EDIT_INGORE, OnKillfocusEditIngore)
ON_EN_UPDATE(IDC_EDIT_INGORE, OnUpdateEditIngore)
ON_EN_UPDATE(IDC_EDIT_PORT, OnUpdateEditPort)
ON_EN_UPDATE(IDC_EDIT_THREAD, OnUpdateEditThread)
ON_EN_UPDATE(IDC_EDIT_URL, OnUpdateEditUrl)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgOptionCnt message handlers
BOOL CDlgOptionCnt::OnInitDialog()
{
CPropertyPage::OnInitDialog();
// TODO: Add extra initialization here
CBitmap bmp;
CImageList img;
bmp.LoadBitmap(IDB_BMP_CONNECT);
img.Create(32,32,ILC_COLOR24 | ILC_MASK,2,0);
img.Add(&bmp,RGB(255,0,255));
m_icoThread.SetIcon(img.ExtractIcon(0));
m_icoProxy.SetIcon(img.ExtractIcon(1));
CMainFrame *pFrame = (CMainFrame*)AfxGetMainWnd();
ASSERT(pFrame != NULL);
m_ThreadCount = pFrame->m_MaxThreadCount;
CString strNum;
strNum.Format(_T("%d"),m_ThreadCount);
m_edThread.SetWindowText(strNum);
m_edThread.SetLimitText(2);
m_spThread.SetRange32(1,MAX_WAIT_THREAD);
m_sliTime.SetPageSize(15);
m_sliTime.SetLineSize(15);
m_sliTime.SetRange(SEARCH_TIME_MIN,SEARCH_TIME_MAX);
m_TimeOut = pFrame->m_TimeOut;
m_sliTime.SetPos(m_TimeOut);
FormatTimeVal(m_TimeOut);
m_Ingore = pFrame->m_IngoreLegth;
m_edIngore.LimitText(5);
UDACCEL Accel;
Accel.nInc = ACC_INGORE_NUM;
m_spIngore.SetAccel(1,&Accel);
m_spIngore.SetRange32(MIN_INGORE_NUM,MAX_INGORE_NUM);
strNum.Format(_T("%d"),m_Ingore);
m_edIngore.SetWindowText(strNum);
m_chkIngore.SetCheck(pFrame->m_IsIngoreLong);
OnCheckIngore();
m_edURL.SetWindowText(pFrame->m_Proxy);
m_edPort.SetWindowText(pFrame->m_Port);
m_chkProxy.SetCheck(pFrame->m_UseProxy);
OnCheckProxy();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgOptionCnt::OnCheckIngore()
{
// TODO: Add your control notification handler code here
BOOL m_Enable;
m_Enable = m_chkIngore.GetCheck() == 1 ? TRUE : FALSE;
m_edIngore.EnableWindow(m_Enable);
m_spIngore.EnableWindow(m_Enable);
SetModified();
}
void CDlgOptionCnt::OnCheckProxy()
{
// TODO: Add your control notification handler code here
BOOL m_Enable;
m_Enable = m_chkProxy.GetCheck() == 1 ? TRUE : FALSE;
m_edURL.EnableWindow(m_Enable);
m_edPort.EnableWindow(m_Enable);
SetModified();
}
void CDlgOptionCnt::OnKillfocusEditThread()
{
// TODO: Add your control notification handler code here
CString strNum;
m_edThread.GetWindowText(strNum);
int num = atoi(strNum);
if(num < 1 || num > MAX_WAIT_THREAD)
{
num = num < 1 ? 1 : MAX_WAIT_THREAD;
strNum.Format(_T("%d"),num);
m_edThread.SetWindowText(strNum);
}
}
void CDlgOptionCnt::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
m_TimeOut = m_sliTime.GetPos();
FormatTimeVal(m_TimeOut);
SetModified();
CPropertyPage::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CDlgOptionCnt::FormatTimeVal(int iTime)
{
CString strMin,strSec,strVal;
int minute,second;
minute = iTime/60;
second = iTime%60;
strMin.Format(IDS_TIME_FMTMIN,minute);
strSec.Format(IDS_TIME_FMTSEC,second);
if(minute == 0)
strVal = strSec;
else if(second == 0)
strVal = strMin;
else
strVal.Format(_T("%s %s"),strMin,strSec);
m_strTime.SetWindowText(strVal);
}
void CDlgOptionCnt::OnKillfocusEditIngore()
{
// TODO: Add your control notification handler code here
CString strNum;
m_edIngore.GetWindowText(strNum);
int num = atoi(strNum);
if(num < MIN_INGORE_NUM || num > MAX_INGORE_NUM)
{
num = num < MIN_INGORE_NUM ? MIN_INGORE_NUM : MAX_INGORE_NUM;
strNum.Format(_T("%d"),num);
m_edIngore.SetWindowText(strNum);
}
}
BOOL CDlgOptionCnt::OnApply()
{
// TODO: Add your specialized code here and/or call the base class
SetOptionCntVal();
return CPropertyPage::OnApply();
}
void CDlgOptionCnt::OnOK()
{
// TODO: Add your specialized code here and/or call the base class
if(GetParent()->GetDlgItem(ID_APPLY_NOW)->IsWindowEnabled())
SetOptionCntVal();
CPropertyPage::OnOK();
}
void CDlgOptionCnt::SetOptionCntVal()
{
CMainFrame *pFrame = (CMainFrame*)AfxGetMainWnd();
ASSERT(pFrame != NULL);
CString strNum;
m_edThread.GetWindowText(strNum);
pFrame->m_MaxThreadCount = atol(strNum);
m_edIngore.GetWindowText(strNum);
pFrame->m_IngoreLegth = atol(strNum);
pFrame->m_IsIngoreLong = m_chkIngore.GetCheck() == 1 ? TRUE : FALSE;
pFrame->m_UseProxy = m_chkProxy.GetCheck() == 1 ? TRUE : FALSE;
m_edURL.GetWindowText(pFrame->m_Proxy);
m_edPort.GetWindowText(pFrame->m_Port);
pFrame->m_TimeOut = m_sliTime.GetPos();
}
void CDlgOptionCnt::OnUpdateEditIngore()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CPropertyPage::OnInitDialog()
// function to send the EM_SETEVENTMASK message to the control
// with the ENM_UPDATE flag ORed into the lParam mask.
// TODO: Add your control notification handler code here
SetModified();
}
void CDlgOptionCnt::OnUpdateEditPort()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CPropertyPage::OnInitDialog()
// function to send the EM_SETEVENTMASK message to the control
// with the ENM_UPDATE flag ORed into the lParam mask.
// TODO: Add your control notification handler code here
SetModified();
}
void CDlgOptionCnt::OnUpdateEditThread()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CPropertyPage::OnInitDialog()
// function to send the EM_SETEVENTMASK message to the control
// with the ENM_UPDATE flag ORed into the lParam mask.
// TODO: Add your control notification handler code here
SetModified();
}
void CDlgOptionCnt::OnUpdateEditUrl()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CPropertyPage::OnInitDialog()
// function to send the EM_SETEVENTMASK message to the control
// with the ENM_UPDATE flag ORed into the lParam mask.
// TODO: Add your control notification handler code here
SetModified();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -