home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Softwarová Záchrana 3
/
Softwarova-zachrana-3.bin
/
pserv.cpl
/
pserv-2.4.exe
/
source
/
ServiceControlDialog.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2005-01-05
|
3KB
|
98 lines
// ServiceControlDialog.cpp : implementation file
//
#include "stdafx.h"
#include "pserv2.h"
#include "ServiceControlDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CServiceControlDialog dialog
void DisplayErrorMessage(LPCTSTR lpszCaption, ...);
CServiceControlDialog::CServiceControlDialog(CService* pService, DWORD dwWaitHint, QUERYSTATEFN QueryStateFN, LPCTSTR lpszAction, CWnd* pParent /*=NULL*/)
: CDialog(CServiceControlDialog::IDD, pParent),
m_dwWaitHint( dwWaitHint ),
m_nTimerID( 0 ),
m_QueryStateFN( QueryStateFN ),
m_lpszAction( lpszAction ),
m_pService( pService )
{
//{{AFX_DATA_INIT(CServiceControlDialog)
m_strDescription = "";
//}}AFX_DATA_INIT
m_strDescription.Format(_T("About to %s %s"), lpszAction, (LPCTSTR) pService->m_strDisplayName);
}
void CServiceControlDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CServiceControlDialog)
DDX_Control(pDX, IDC_PROGRESS1, m_Progress);
DDX_Text(pDX, IDC_DESCRIPTION, m_strDescription);
//}}AFX_DATA_MAP
if( pDX->m_bSaveAndValidate )
{
CWnd::KillTimer(123);
}
else
{
ASSERT( ::IsWindow(m_hWnd));
m_dwSecondsExpected = 2 + (m_dwWaitHint / 500);
m_dwSecondsElapsed = 0;
m_Progress.SetRange(0, (short) m_dwSecondsExpected );
m_Progress.SetStep(1);
m_Progress.StepIt();
m_nTimerID = 123;
CWnd::SetTimer(m_nTimerID, 500, 0);
}
}
BEGIN_MESSAGE_MAP(CServiceControlDialog, CDialog)
//{{AFX_MSG_MAP(CServiceControlDialog)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CServiceControlDialog::OnTimer(UINT nIDEvent)
{
ASSERT( nIDEvent == 123 );
if( m_nTimerID != 0 )
{
m_dwSecondsElapsed++;
if( m_dwSecondsElapsed >= m_dwSecondsExpected )
{
m_nTimerID = 0;
DisplayErrorMessage(_T("ERROR, unable to %s %s in time"), m_lpszAction, (LPCTSTR) m_pService->m_strDisplayName );
EndDialog(IDCANCEL);
}
SERVICE_STATE_TYPE sst = (m_pService->*m_QueryStateFN)();
if( sst == SERVICE_STATE_REACHED )
{
m_nTimerID = 0;
EndDialog(IDOK);
}
else if( sst == SERVICE_STATE_FAILED )
{
m_nTimerID = 0;
DisplayErrorMessage(_T("ERROR, unable to query status of %s"), (LPCTSTR) m_pService->m_strDisplayName );
EndDialog(IDCANCEL);
}
m_Progress.StepIt();
}
CDialog::OnTimer(nIDEvent);
}