#include "stdafx.h" #include "LaiPuLaser.h" #include "DlgProgress.h" #include "afxdialogex.h" #include "GlobalDrawMgr.h" #define WORK_TIMER1 1 #define WORK_TIME_DELAY1 200 IMPLEMENT_DYNAMIC(CDlgProgress, CDialogEx) CDlgProgress::CDlgProgress(CWnd* pParent /*=NULL*/) : CDialogEx(CDlgProgress::IDD, pParent) { } CDlgProgress::~CDlgProgress() { } void CDlgProgress::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Control(pDX, IDC_PROGRESS1, m_WorkProgress1); } BEGIN_MESSAGE_MAP(CDlgProgress, CDialogEx) ON_WM_TIMER() END_MESSAGE_MAP() BOOL CDlgProgress::OnInitDialog() { CDialogEx::OnInitDialog(); //设置对话框的位置 CRect rect; CWnd* pWnd = AfxGetMainWnd(); pWnd->GetWindowRect(rect); CPoint pos = gDraw->GetProgressDlgPos(); MoveWindow(rect.left+pos.x, rect.top+pos.y, 500, 90); //禁用关闭按钮 CMenu* pMenu = this->GetSystemMenu(FALSE); pMenu->ModifyMenu(SC_CLOSE,MF_BYCOMMAND | MF_GRAYED ); SetTimer(WORK_TIMER1,WORK_TIME_DELAY1,NULL); UpdateData(FALSE); return TRUE; } //截获一部分键盘输入传递给view BOOL CDlgProgress::PreTranslateMessage(MSG* pMsg) { if(pMsg->message==WM_KEYDOWN) { char c = pMsg->wParam; if(c==VK_RETURN || c==VK_ESCAPE) { return TRUE; } } return CDialogEx::PreTranslateMessage(pMsg); } void CDlgProgress::OnTimer(UINT nIDEvent) { if(nIDEvent == WORK_TIMER1) { //检查进度条是否结束 if(m_WorkProgress1.GetPos()>99) CDialog::OnOK(); } CDialog::OnTimer(nIDEvent); }