📄 waitdlg.cpp
字号:
// WaitDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ChooseBookTool.h"
#include "WaitDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWaitDlg dialog
CWaitDlg::CWaitDlg(CWnd* pParent /*=NULL*/)
: CDialog(CWaitDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CWaitDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_bExitCycle = FALSE;
m_bExitProgram = FALSE;
m_strMessage = _T("");
}
void CWaitDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CWaitDlg)
DDX_Control(pDX, IDC_RUNPRO, m_CtrRunProgress);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CWaitDlg, CDialog)
//{{AFX_MSG_MAP(CWaitDlg)
ON_WM_DESTROY()
ON_WM_CLOSE()
ON_WM_CTLCOLOR()
ON_BN_CLICKED(ID_EXIT, OnExit)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWaitDlg message handlers
void CWaitDlg::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
void CWaitDlg::OnCancel()
{
// TODO: Add extra cleanup here
//CDialog::OnCancel();
}
void CWaitDlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
}
void CWaitDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
m_bExitCycle = TRUE;
CDialog::OnClose();
CDialog::OnCancel();
}
HBRUSH CWaitDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if (nCtlColor == CTLCOLOR_STATIC)
{
pDC->SetTextColor(RGB(0,0,255));
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
void CWaitDlg::OnExit()
{
// TODO: Add your control notification handler code here
m_bExitCycle = TRUE;
//this->m_pRunThread->ExitInstance();
CDialog::OnCancel();
}
void CWaitDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
for(int i = 0;i<100;i++)
{
m_CtrRunProgress.SetPos(i);
}
CDialog::OnTimer(nIDEvent);
}
void CWaitDlg::Create()
{
CDialog::Create(IDD_DIALOG_WAIT);
}
void CWaitDlg::SetRunMessage(CString str)
{
m_strMessage = str;
GetDlgItem(IDC_RUNMESSAGE)->SetWindowText(str);
}
void CWaitDlg::Running()
{
m_bRunning = TRUE;
//SetTimer(WM_TIMER,300,NULL);
this->m_pRunThread = new CRunDlgThread(this);
this->m_pRunThread->CreateThread(CREATE_SUSPENDED);
VERIFY(this->m_pRunThread->SetThreadPriority(THREAD_PRIORITY_NORMAL));
this->m_pRunThread->ResumeThread();
}
void CWaitDlg::StopRunning()
{
m_bRunning = FALSE;
//KillTimer(WM_TIMER);
//this->m_pRunThread->ExitInstance();
}
BOOL CWaitDlg::GetCycleStatus()
{
return m_bExitCycle;
}
void CWaitDlg::SetCycleStatus(BOOL flag)
{
m_bExitCycle = flag;
}
BOOL CWaitDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_CtrRunProgress.SetPos(0);
m_CtrRunProgress.SetRange(0,100);
m_CtrRunProgress.SetStep(1);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CWaitDlg::BeginProgress()
{
static int i = 0;
while (m_bRunning)
{
if (i==100)
{
i=0;
}
m_CtrRunProgress.SetPos(i);
i++;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -