summaryrefslogtreecommitdiff
path: root/Checklist/DonePage.cpp
blob: 76b4eb48fdc04befdbd00cb7f73e01ddc2f1ebf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// DonePage.cpp : implementation file
//

#include "stdafx.h"
#include "DonePage.h"
#include <atlctrls.h>
#include <appmisc.h>

/////////////////////////////////////////////////////////////////////////////
// CDonePage property page

CDonePage::CDonePage(CPropertySheet* pParent, UINT nPos /*= WIZPAGE_MIDDLE*/) 
	: CPropertyPage(CDonePage::IDD),

	m_nPos(nPos)		// Position in the Wizard (WIZPAGE_FIRST, WIZPAGE_MIDDLE 
						// or WIZPAGE_LAST)
{
	ASSERT(pParent);		// Have to have a valid parent
	m_pParentSheet = pParent;	// or we can't survive
	SetHelp(true);
}

CDonePage::~CDonePage()
{
}

/////////////////////////////////////////////////////////////////////////////
// CDonePage message handlers

LRESULT CDonePage::OnSetActive(int idCtrl, LPNMHDR pnmh, BOOL& bHandled) 
{
	DWORD dwButtons;

	// Depening on our Position in the Wizard
	// Set the Buttons at the bottom on and off

	switch(m_nPos){
		case WIZPAGE_FIRST:
			dwButtons = PSWIZB_NEXT;
			break;
		case WIZPAGE_LAST:
			dwButtons = PSWIZB_BACK | PSWIZB_FINISH;
			break;
		default:
			dwButtons = PSWIZB_BACK | PSWIZB_NEXT;
			break;
	}

	m_pParentSheet->SetWizardButtons(dwButtons);
	
	return 0;
}

LRESULT CDonePage::OnHelp(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
	WinHelp(NS_HELP_FILE, HELP_FINDER, 0);
	return 1;
}

LRESULT CDonePage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 
{
	// Set the Help ID for our Help File
//	m_nIDHelp = 300;

	HICON hIconNightSec = ::LoadIcon(_Module.m_hInstResource, MAKEINTRESOURCE(IDI_SHUTDOWN));

	CButton btnNew = GetDlgItem(IDC_SHUTDOWN);
	btnNew.SetIcon(hIconNightSec);
	btnNew.Detach();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

LRESULT CDonePage::OnShutdown(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 
{
	m_pParentSheet->PressButton(PSBTN_FINISH);

	string sShutdownCmd = GetProgramFolder(_Module.m_hInst);
	sShutdownCmd += _T("Shutdown.exe");

	// Start the Shutdown Program
	if(ShellExecute(NULL, _T("open"), sShutdownCmd, NULL, NULL, SW_SHOWNORMAL) <= (HINSTANCE)32)
		::MessageBox(NULL, _T("Couldn't start Secure Shutdown. Make sure it's installed properly."), _T("Secure Shutdown"), MB_ICONSTOP);

	return 1;
}