📄 sawenumdlg.cpp
字号:
// SAWEnumDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SAWEnum.h"
#include "SAWEnumDlg.h"
#include "SAWEnumImpl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CSAWEnumDlg dialog
CSAWEnumDlg::CSAWEnumDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSAWEnumDlg::IDD, pParent)
, m_nStep(4)
, m_nResult(0)
, m_bMutiThread(FALSE)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CSAWEnumDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_nStep);
DDV_MinMaxInt(pDX, m_nStep, 4, 40);
DDX_Radio(pDX, IDC_RADIO1, m_bMutiThread);
}
BEGIN_MESSAGE_MAP(CSAWEnumDlg, CDialog)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDOK, OnBnClickedOk)
ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
END_MESSAGE_MAP()
// CSAWEnumDlg message handlers
BOOL CSAWEnumDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CSAWEnumDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CSAWEnumDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CSAWEnumDlg::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
if(UpdateData(TRUE))
{
SAWEnum saw(m_nStep, m_bMutiThread);
BeginWaitCursor();
CTime t = CTime::GetCurrentTime();
AfxGetApp()->SetThreadPriority(THREAD_PRIORITY_HIGHEST);
SetThreadIdealProcessor(AfxGetApp()->m_hThread, 0);
saw.DistributeWorks();
AfxGetApp()->SetThreadPriority(THREAD_PRIORITY_NORMAL);
m_nResult = -1;
while(m_nResult == -1)
{
Sleep(1000);
m_nResult = saw.GetPathCount();
}
CTimeSpan ts = CTime::GetCurrentTime() - t;
CString cs;
cs.Format("%I64d", m_nResult);
GetDlgItem(IDC_EDIT2)->SetWindowText(cs);
GetDlgItem(IDC_EDIT3)->SetWindowText(ts.Format("%Mmin%Ssec"));
EndWaitCursor();
}
}
void CSAWEnumDlg::OnBnClickedCancel()
{
// TODO: Add your control notification handler code here
OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -