This commit is contained in:
100
HookMsg/WaitDlg.cpp
Normal file
100
HookMsg/WaitDlg.cpp
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
// 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user