Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Remote Processes and Machine control of Windows NT based systems (2000/XP)

, 1 Apr 2012 CPOL
Control certain aspects of machines sitting remotely, without having to install and trigger an application on the remote machine.
// 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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Prateek Kaul
Web Developer
India India
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141223.1 | Last Updated 1 Apr 2012
Article Copyright 2003 by Prateek Kaul
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid