// WaitDlg.cpp : implementation file // #include "stdafx.h" #include "hookmsg.h" #include "WaitDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CWaitDlg dialog //UINT CWaitDlg::WaitThread(void * lParam); // ÀÛ¾÷ ½º·¹µå ÇÔ¼ö 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_hWaitEvent = INVALID_HANDLE_VALUE; } void CWaitDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CWaitDlg) DDX_Control(pDX, IDC_WAIT_PROGRESS, m_hProgress); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CWaitDlg, CDialog) //{{AFX_MSG_MAP(CWaitDlg) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CWaitDlg message handlers void CWaitDlg::OnOK() { // CDialog::OnOK(); } void CWaitDlg::OnCancel() { int nID = MessageBox( "ÇÁ·Î±×·¥ °­Á¦Á¾·áÇϽðڽÀ´Ï±î?\r\n" "Á¤»óÁ¾·áó¸®Áß¿¡ ¹®Á¦°¡ ÀÖÀ»¶§ °­Á¦Á¾·áÇϼ¼¿ä. \r\n" , "ÇÁ·Î±×·¥ Á¾·á", MB_YESNO|MB_ICONQUESTION ); if( nID == IDYES ) { CDialog::OnCancel(); } } BOOL CWaitDlg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here AfxBeginThread(WaitThread, this); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } UINT CWaitDlg::WaitThread(void * lParam) // ÀÛ¾÷ ½º·¹µå ÇÔ¼ö { int nResult = 0; CWaitDlg* pDlg = (CWaitDlg*)lParam; pDlg->m_hProgress.SetRange(0,100); // À¯È¿ ¹üÀ§ ¼³Á¤ CString str; int idx = 0; for(int i = 0; i <= 100; i++) { pDlg->m_hProgress.SetPos(i); // ÁøÇà À§Ä¡ ¼³Á¤ // the thread is still running. DWORD dwRet = ::WaitForSingleObject(pDlg->m_hWaitEvent,50); if( dwRet == WAIT_OBJECT_0 || dwRet == WAIT_FAILED ) // ¾²·¹µå Á¾·á¸¦ È®ÀÎ. { pDlg->PostMessage(WM_QUIT); break; } if( i == 100 ) i = 0; } return 0; }