PageRenderTime 23ms CodeModel.GetById 15ms app.highlight 7ms RepoModel.GetById 0ms app.codeStats 0ms

/3rd_party/wtl/Samples/Wizard97Test/Wizard/TestWizardCompletionPage.cpp

https://code.google.com/p/softart/
C++ | 158 lines | 109 code | 27 blank | 22 comment | 0 complexity | 9e6163e5dd84f306f3982d301a325d0b MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, JSON, MPL-2.0-no-copyleft-exception, GPL-2.0, GPL-3.0, LGPL-3.0, BSD-2-Clause
  1
  2#include "stdafx.h"
  3#include "TestWizardCompletionPage.h"
  4
  5LRESULT CTestWizardCompletionPage::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
  6{
  7	this->InitializeControls();
  8	this->InitializeValues();
  9
 10	return 1;
 11}
 12
 13void CTestWizardCompletionPage::InitializeFont(void)
 14{
 15	// Set the font
 16	CLogFont logFont;
 17	CClientDC dc(m_hWnd);
 18	logFont.SetHeight(8, dc);
 19	::lstrcpy(logFont.lfFaceName, _T("Courier New"));
 20
 21	m_fontSummary.Attach(logFont.CreateFontIndirect());
 22	m_editSummary.SetFont(m_fontSummary);
 23
 24	// Set the tab stops to 4 characters.
 25	// Tab stops are in dialog units.
 26	TEXTMETRIC tm = {0};
 27	CFontHandle oldFont = dc.SelectFont(m_fontSummary);
 28	dc.GetTextMetrics(&tm);
 29	dc.SelectFont(oldFont);
 30
 31	int dialogUnitsX = ::MulDiv(4, tm.tmAveCharWidth, LOWORD(GetDialogBaseUnits()));
 32	int tabStops = 4*dialogUnitsX;
 33
 34	m_editSummary.SetTabStops(tabStops);
 35}
 36
 37void CTestWizardCompletionPage::InitializeControls(void)
 38{
 39	CFontHandle fontExteriorPageTitleFont(baseClass::GetExteriorPageTitleFont());
 40
 41	CWindow title = this->GetDlgItem(IDC_WIZ97_EXTERIOR_TITLE);
 42	title.SetFont(fontExteriorPageTitleFont);
 43
 44	m_editSummary = this->GetDlgItem(IDC_WIZ97_SUMMARY);
 45
 46	this->InitializeFont();
 47}
 48
 49void CTestWizardCompletionPage::InitializeValues(void)
 50{
 51}
 52
 53void CTestWizardCompletionPage::UpdateSummary(void)
 54{
 55	CString path = m_pTestWizardInfo->GetPath();
 56	bool recurse = m_pTestWizardInfo->GetRecurse();
 57	CString filter = m_pTestWizardInfo->GetFilter();
 58	TestWizardOutputType outputType = m_pTestWizardInfo->GetOutputType();
 59
 60	CString text;
 61	text.Format(
 62		_T("Test Wizard: \r\n")
 63		_T("? Find files in the directory:\r\n")
 64		_T("\t%s\r\n")
 65		_T("? %s\r\n")
 66		_T("? Find files matching the filter '%s'\r\n"),
 67		path,
 68		recurse ? _T("Also search sub-directories") : _T("Only search that directory"),
 69		filter);
 70	m_editSummary.SetWindowText(text);
 71
 72	CString outputDescription;
 73	switch(outputType)
 74	{
 75	case eOutput_SendEMail:
 76		outputDescription = 
 77			_T("? Send the file list in an e-mail\r\n")
 78			_T("  (using the default mail client)\r\n");
 79		break;
 80	case eOutput_SaveToFile:
 81		{
 82			CString outputFileName = m_pTestWizardInfo->GetOutputFileName();
 83			TestWizardOutputFileEncoding outputFileEncoding = m_pTestWizardInfo->GetOutputFileEncoding();
 84
 85			outputDescription.Format(
 86				_T("? Save the file list to the file:\r\n")
 87				_T("\t%s\r\n"),
 88				outputFileName);
 89			switch(outputFileEncoding)
 90			{
 91			case eEncoding_ASCII:
 92				outputDescription += _T("  with ASCII encoding\r\n");
 93				break;
 94			case eEncoding_UCS2:
 95				outputDescription += _T("  with Unicode (UCS-2) encoding\r\n");
 96				break;
 97			case eEncoding_UTF8:
 98				outputDescription += _T("  with Unicode (UTF-8) encoding\r\n");
 99				break;
100			}
101		}
102		break;
103	case eOutput_Clipboard:
104	default:
105		outputDescription = _T("? Copy the file list to the clipboard\r\n");
106		break;
107	}
108	m_editSummary.AppendText(outputDescription);
109}
110
111int CTestWizardCompletionPage::OnSetActive()
112{
113	this->SetWizardButtons(PSWIZB_BACK | PSWIZB_FINISH);
114
115	// Don't remember any previous updates to the summary,
116	//  and just regenerate the whole summary
117	this->UpdateSummary();
118
119	// 0 = allow activate
120	// -1 = go back to page that was active
121	// page ID = jump to page
122	return 0;
123}
124
125int CTestWizardCompletionPage::OnWizardBack()
126{
127	// 0  = goto previous page
128	// -1 = prevent page change
129	// >0 = jump to page by dlg ID
130	return m_pTestWizardInfo->FindPreviousPage(IDD);
131}
132
133INT_PTR CTestWizardCompletionPage::OnWizardFinish()
134{
135	// We could either do the work here, or in the place that
136	// called DoModal on our Sheet (which for this example is CTestWizard).
137	// The advantage of doing the work here is that we can prevent
138	// the finish, and tell the user to go back and correct something.
139	// The advantage of doing it in the caller of DoModal is
140	// that the wizard isn't visible while the work is being done.
141
142	// For this example, we'll do the work here (or rather call back into
143	// the info class to do the work), and prevent finish if something fails.
144
145	CWaitCursor waitCursor;
146
147	bool success = m_pTestWizardInfo->FinishWizard(m_hWnd);
148
149	// FALSE = allow finish
150	// TRUE = prevent finish
151	// HWND = prevent finish and set focus to HWND (CommCtrl 5.80 only)
152	return success ? FALSE : TRUE;
153}
154
155void CTestWizardCompletionPage::OnHelp()
156{
157	m_pTestWizardInfo->ShowHelp(IDD);
158}