00001
00002
00003
00004
00005
00006 #include "stdafx.h"
00007 #include "FdmApp.h"
00008 #include "WaitDlg.h"
00009
00010 #ifdef _DEBUG
00011 #define new DEBUG_NEW
00012 #undef THIS_FILE
00013 static char THIS_FILE[] = __FILE__;
00014 #endif
00015
00016 CWaitDlg::CWaitDlg(CWnd* pParent )
00017 : CDialog(CWaitDlg::IDD, pParent)
00018 {
00019
00020
00021
00022 }
00023
00024 void CWaitDlg::DoDataExchange(CDataExchange* pDX)
00025 {
00026 CDialog::DoDataExchange(pDX);
00027
00028 DDX_Control(pDX, IDC_PROGRESS, m_wndProgress);
00029
00030 }
00031
00032 BEGIN_MESSAGE_MAP(CWaitDlg, CDialog)
00033
00034 ON_WM_TIMER()
00035
00036 END_MESSAGE_MAP()
00037
00038 void CWaitDlg::OnCancel()
00039 {
00040
00041
00042 m_info.bNeedStop = TRUE;
00043 GetDlgItem (IDCANCEL)->EnableWindow (FALSE);
00044 }
00045
00046 UINT CWaitDlg::StartWaiting(LPCSTR pszMessage, LPTHREAD_START_ROUTINE procWait, BOOL bEnableCancel, LPVOID lpParam1, LPVOID lpParam2, LPVOID lpParam3, LPVOID lpParam4, LPVOID lpParam5, BOOL bModal)
00047 {
00048 DWORD dw;
00049
00050 m_info.bNeedStop = FALSE;
00051 m_info.bWaitDone = FALSE;
00052 m_info.lpParam1 = lpParam1;
00053 m_info.lpParam2 = lpParam2;
00054 m_info.lpParam3 = lpParam3;
00055 m_info.lpParam4 = lpParam4;
00056 m_info.lpParam5 = lpParam5;
00057 m_info.iProgress = 0;
00058
00059 m_strMsg = pszMessage;
00060 CloseHandle (CreateThread (NULL, 0, procWait, &m_info, 0, &dw));
00061
00062 m_bCancel = bEnableCancel;
00063
00064 m_bNeedRelease = bModal == false;
00065
00066 if (bModal)
00067 {
00068 return _DlgMgr.DoModal (this);
00069 }
00070 else
00071 {
00072 Create (IDD_WAITER, AfxGetApp ()->m_pMainWnd);
00073 ShowWindow (SW_SHOW);
00074 SetForegroundWindow ();
00075 return TRUE;
00076 }
00077 }
00078
00079 BOOL CWaitDlg::OnInitDialog()
00080 {
00081 CDialog::OnInitDialog();
00082
00083 SetDlgItemText (IDC_MESSAGE, m_strMsg);
00084
00085 GetDlgItem (IDCANCEL)->EnableWindow (m_bCancel);
00086
00087 m_wndProgress.SetRange (0, 100);
00088
00089 SetTimer (1, 500, NULL);
00090
00091 SetWindowText (LS (L_PLEASEWAIT));
00092 GetDlgItem (IDCANCEL)->SetWindowText (LS (L_CANCEL));
00093
00094 return TRUE;
00095
00096 }
00097
00098 void CWaitDlg::OnTimer(UINT )
00099 {
00100 if (m_info.bWaitDone)
00101 {
00102 EndDialog (m_info.bNeedStop == FALSE ? IDOK : IDCANCEL);
00103 if (m_bNeedRelease)
00104 delete this;
00105 return;
00106 }
00107
00108 m_wndProgress.SetPos (m_info.iProgress);
00109 }