|
// ProgressDlg.cpp : implementation file
//
#include "stdafx.h"
#include "RemoteAdmin.h"
#include "ProgressDlg.h"
#include "RemoteAdminDoc.h"
#include "GlobalMFCHelperFunc.h"
#include "ProgressWndThread.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CProgressDlg, CDialog)
CProgressDlg::CProgressDlg(CWnd* pParent /*=NULL*/)
: CDialog(CProgressDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CProgressDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pRemoteAdminDoc = NULL;
}
void CProgressDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CProgressDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CProgressDlg, CDialog)
//{{AFX_MSG_MAP(CProgressDlg)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CProgressDlg::SetDlgTitle(CString strDlgTitle)
{
SetWindowText(strDlgTitle);
}
void CProgressDlg::SetProgressText(CString strDlgProgressTxt)
{
SetDlgItemText(IDC_PROGRESS, strDlgProgressTxt);
}
void CProgressDlg::IncrementProgressBar()
{
UINT iConnectionsInProgress = m_pRemoteAdminDoc->GetNumberOfMachineConnectionsStillInProgress();
CString strDlgProgressTxt;
strDlgProgressTxt.Format("Connection request to %d machine(s) pending.....", iConnectionsInProgress);
SetProgressText(strDlgProgressTxt);
CProgressCtrl* pProgressCtrl = static_cast<CProgressCtrl*>(GetDlgItem(IDC_PROGRESS_BAR));
pProgressCtrl->StepIt();
}
BOOL CProgressDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CProgressCtrl* pProgressCtrl = static_cast<CProgressCtrl*>(GetDlgItem(IDC_PROGRESS_BAR));
pProgressCtrl->SetRange32(0, 100);
pProgressCtrl->SetStep(1);
// Disable close button
CMenu* pSysMenu = GetSystemMenu(FALSE);
pSysMenu->DeleteMenu(SC_CLOSE, MF_BYCOMMAND);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CProgressDlg::Create()
{
return CDialog::Create(CProgressDlg::IDD) ;
}
void CProgressDlg::OnTimer(UINT nIDEvent)
{
if (nIDEvent == TIMER_STEP)
{
if (m_pRemoteAdminDoc != NULL)
{
if (m_pRemoteAdminDoc->AreConnectionsStillPending() == FALSE)
{
DestroyProgressBarAndExitThread();
}
else
{
IncrementProgressBar();
}
}
}
CDialog::OnTimer(nIDEvent);
}
void CProgressDlg::DestroyProgressBarAndExitThread()
{
// Show zero connections pending on the progress bar
CString strDlgProgressTxt = _T("No more connections pending !");
SetProgressText(strDlgProgressTxt);
::Sleep(1000);
// Finish the progress dialog and exit the thread
DestroyWindow();
::AfxEndThread(0);
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.