Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

555 lines
13 KiB

  1. /*++
  2. Copyright (c) 1994-1998 Microsoft Corporation
  3. Module Name :
  4. wizard.h
  5. Abstract:
  6. Enhanced dialog and IIS MMC Wizards definitions
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. #ifndef __IISUI_WIZARD_H__
  14. #define __IISUI_WIZARD_H__
  15. //
  16. // CIISWizardPage parameters
  17. //
  18. #define HEADER_PAGE (TRUE)
  19. #define WELCOME_PAGE (FALSE)
  20. #if (_WIN32_IE < 0x0400)
  21. //
  22. // Defined in comctrl.h. Defined here because NT 5 MFC42.dll are
  23. // defined with _WIN32_IE 0x300
  24. //
  25. #pragma message("Warning: privately defining _WIN32_IE definitions")
  26. #define PSH_WIZARD97 0x00002000
  27. #define ICC_INTERNET_CLASSES 0x00000800
  28. #define PSP_HIDEHEADER 0x00000800
  29. #define PSP_USEHEADERTITLE 0x00001000
  30. #define PSP_USEHEADERSUBTITLE 0x00002000
  31. #define PSH_WIZARD_LITE 0x00400000
  32. #endif // _WIN32_IE
  33. //
  34. // Using dialog font as a basis, create a new special effects font
  35. //
  36. COMDLL BOOL
  37. CreateSpecialDialogFont(
  38. IN CWnd * pdlg, // Source dialog
  39. IN OUT CFont * pfontSpecial, // Font to be used must be allocated already
  40. IN LONG lfOffsetWeight = +300, // Assuming boldification
  41. IN LONG lfOffsetHeight = +0, // Assuming no change in height
  42. IN LONG lfOffsetWidth = +0, // Assuming no change in width (or true type)
  43. IN BOOL fItalic = FALSE, // Do not invert italic state
  44. IN BOOL fUnderline = FALSE // Do not invert underline state
  45. );
  46. //
  47. // Apply fonts to child controls of a dialog
  48. //
  49. COMDLL void
  50. ApplyFontToControls(
  51. IN CWnd * pdlg, // Parent dialog
  52. IN CFont * pfont, // Font to be applied
  53. IN UINT nFirst, // First control ID in the series
  54. IN UINT nLast // Last control ID in the series
  55. );
  56. class COMDLL CEmphasizedDialog : public CDialog
  57. /*++
  58. Class Description:
  59. A standard CDialog that allows use of emphasized fonts as follows:
  60. control ID Meaning
  61. --------------------------------------------------------------------------
  62. IDC_ED_BOLD1 Dialog font, bold-faced.
  63. IDC_ED_BOLD2 Dialog font, bold-faced.
  64. IDC_ED_BOLD3 Dialog font, bold-faced.
  65. IDC_ED_BOLD4 Dialog font, bold-faced.
  66. IDC_ED_BOLD5 Dialog font, bold-faced.
  67. Note: others might be added as needed.
  68. Public Interface:
  69. CEmphasizedDialog : Constructor
  70. --*/
  71. {
  72. DECLARE_DYNCREATE(CEmphasizedDialog)
  73. //
  74. // Constructors
  75. //
  76. public:
  77. CEmphasizedDialog(LPCTSTR lpszTemplateName, CWnd * pParentWnd = NULL);
  78. CEmphasizedDialog(UINT nIDTemplate, CWnd * pParentWnd = NULL);
  79. CEmphasizedDialog();
  80. protected:
  81. virtual BOOL OnInitDialog();
  82. afx_msg void OnDestroy();
  83. DECLARE_MESSAGE_MAP()
  84. private:
  85. CFont m_fontBold;
  86. };
  87. class COMDLL CIISWizardSheet : public CPropertySheet
  88. /*++
  89. Class Description:
  90. IIS Wizard sheet base class
  91. Public Interface:
  92. CIISWizardSheet : Constructor
  93. IsWizard97 : TRUE if the wizard is in '97 mode
  94. GetSpecialFont : Get pointer to special font
  95. GetBitmapMemDC : Get memory DC where bitmap resides.
  96. GetBackgroundBrush : Get background brush
  97. QueryBitmapWidth : Get bitmap width
  98. QueryBitmapHeight : Get bitmap height
  99. Notes:
  100. The sheets will be shown in wizard '97 format
  101. if a welcome bitmap ID is specified. In that
  102. case, a header bitmap ID must also be specified.
  103. Additionally, the same control IDs as used in CEmphasizedDialog
  104. above have special meaning.
  105. --*/
  106. {
  107. DECLARE_DYNCREATE(CIISWizardSheet)
  108. //
  109. // Construction
  110. //
  111. public:
  112. //
  113. // Specifying a welcome bitmap make the wizard
  114. // wizard '97, otherwise it's a plain-old wizard
  115. // page.
  116. //
  117. CIISWizardSheet(
  118. IN UINT nWelcomeBitmap = 0,
  119. IN UINT nHeaderBitmap = 0,
  120. IN COLORREF rgbForeColor = RGB(0,0,0), // Black
  121. IN COLORREF rgbBkColor = RGB(255,255,255) // White
  122. );
  123. //
  124. // Access
  125. //
  126. public:
  127. BOOL IsWizard97() const;
  128. CFont * GetSpecialFont(BOOL fHeader);
  129. CFont * GetBoldFont() { return &m_fontTitle; }
  130. CFont * GetBigFont() { return &m_fontWelcome; }
  131. CDC * GetBitmapMemDC(BOOL fHeader);
  132. HBRUSH GetBackgroundBrush() const { return m_brBkgnd; }
  133. CBrush * GetWindowBrush() { return &m_brWindow; }
  134. LONG QueryBitmapWidth(BOOL fHeader) const;
  135. LONG QueryBitmapHeight(BOOL fHeader) const;
  136. COLORREF QueryWindowColor() const { return m_rgbWindow; }
  137. COLORREF QueryWindowTextColor() const { return m_rgbWindowText; }
  138. void EnableButton(int nID, BOOL fEnable = TRUE);
  139. protected:
  140. virtual BOOL OnInitDialog();
  141. virtual void WinHelp(DWORD dwData, UINT nCmd = HELP_CONTEXT);
  142. afx_msg void OnDestroy();
  143. DECLARE_MESSAGE_MAP()
  144. protected:
  145. static const int s_cnBoldDeltaFont;
  146. static const int s_cnBoldDeltaHeight;
  147. static const int s_cnBoldDeltaWidth;
  148. protected:
  149. COLORREF m_rgbWindow;
  150. COLORREF m_rgbWindowText;
  151. private:
  152. CFont m_fontWelcome;
  153. CFont m_fontTitle;
  154. HBRUSH m_brBkgnd;
  155. CBrush m_brWindow;
  156. CBitmap m_bmpWelcome;
  157. CBitmap m_bmpHeader;
  158. BITMAP m_bmWelcomeInfo;
  159. BITMAP m_bmHeaderInfo;
  160. CDC m_dcMemWelcome;
  161. CDC m_dcMemHeader;
  162. HBITMAP m_hbmpOldWelcome;
  163. HBITMAP m_hbmpOldHeader;
  164. };
  165. class COMDLL CIISWizardPage : public CPropertyPage
  166. /*++
  167. Class Description:
  168. IIS Wizard page base class
  169. Public Interface:
  170. CIISWizardPage : Constructor
  171. ValidateString : DDX/DDV Helper
  172. Notes:
  173. If the sheet is constructed with bitmap IDs, the
  174. pages will be displayed in wizard '97 format.
  175. Wizard '97 pages will be displayed in either welcome
  176. page or header page format. The welcome page will
  177. be displayed on a welcome bitmap background, with
  178. the welcome text (IDC_STATIC_WZ_WELCOME) displayed
  179. in large bold. Header pages (ordinary pages), display
  180. IDC_STATIC_WZ_TITLE in bold, and use the header bitmap
  181. at the top of the page.
  182. Special control IDs:
  183. --------------------
  184. IDC_STATIC_WZ_WELCOME - Welcome text displayed in bold
  185. IDC_STATIC_WZ_TITLE - Title text displayed in bold
  186. IDC_STATIC_WZ_SUBTITLE - Subtitle text
  187. --*/
  188. {
  189. DECLARE_DYNCREATE(CIISWizardPage)
  190. //
  191. // Construction
  192. //
  193. public:
  194. CIISWizardPage(
  195. IN UINT nIDTemplate = 0,
  196. IN UINT nIDCaption = USE_DEFAULT_CAPTION,
  197. IN BOOL fHeaderPage = FALSE,
  198. IN UINT nIDHeaderTitle = USE_DEFAULT_CAPTION,
  199. IN UINT nIDSubHeaderTitle = USE_DEFAULT_CAPTION
  200. );
  201. public:
  202. //
  203. // DDX/DDV Helper
  204. //
  205. BOOL ValidateString(
  206. IN CEdit & edit,
  207. OUT CString & str,
  208. IN int nMin,
  209. IN int nMax
  210. );
  211. //
  212. // Interface
  213. //
  214. protected:
  215. virtual BOOL OnInitDialog();
  216. afx_msg HBRUSH OnCtlColor(CDC * pDC, CWnd * pWnd, UINT nCtlColor);
  217. afx_msg BOOL OnEraseBkgnd(CDC * pDC);
  218. DECLARE_MESSAGE_MAP()
  219. //
  220. // Sheet Access
  221. //
  222. protected:
  223. CIISWizardSheet * GetSheet() const;
  224. void SetWizardButtons(DWORD dwFlags);
  225. void EnableSheetButton(int nID, BOOL fEnable = TRUE);
  226. BOOL IsWizard97() const;
  227. BOOL IsHeaderPage() const { return m_fUseHeader; }
  228. CFont * GetSpecialFont();
  229. CFont * GetBoldFont();
  230. CFont * GetBigFont();
  231. CDC * GetBitmapMemDC();
  232. HBRUSH GetBackgroundBrush() const;
  233. CBrush * GetWindowBrush();
  234. LONG QueryBitmapWidth() const;
  235. LONG QueryBitmapHeight() const;
  236. COLORREF QueryWindowColor() const;
  237. COLORREF QueryWindowTextColor() const;
  238. protected:
  239. static const int s_cnHeaderOffset;
  240. private:
  241. BOOL m_fUseHeader; // TRUE to use header
  242. CRect m_rcFillArea; // Fill area
  243. CPoint m_ptOrigin; // Bitmap origin
  244. CString m_strTitle; // Title text
  245. CString m_strSubTitle; // Subtitle text
  246. };
  247. class COMDLL CIISWizardBookEnd : public CIISWizardPage
  248. /*++
  249. Class Description:
  250. Welcome / Completion Page
  251. Public Interface:
  252. CIISWizardBookEnd : Constructor
  253. Notes:
  254. The resource template is not required. If not provided,
  255. a default template will be used.
  256. Special control IDs (on the dialog template):
  257. ---------------------------------------------
  258. IDC_STATIC_WZ_WELCOME - Welcome text displayed in bold
  259. IDC_STATIC_WZ_BODY - Body text will be placed here
  260. IDC_STATIC_WZ_CLICK - Click instructions.
  261. The click instructions default to something sensible, and body text
  262. will default to the error text on a failure page and to nothing on
  263. success and welcome page. The body text may include the %h/%H
  264. escape sequences for CError on a success/failure page.
  265. --*/
  266. {
  267. DECLARE_DYNCREATE(CIISWizardBookEnd)
  268. public:
  269. //
  270. // Constructor for success/failure completion page
  271. //
  272. CIISWizardBookEnd(
  273. IN HRESULT * phResult,
  274. IN UINT nIDWelcomeTxtSuccess ,
  275. IN UINT nIDWelcomeTxtFailure,
  276. IN UINT nIDCaption = USE_DEFAULT_CAPTION,
  277. IN UINT nIDBodyTxtSuccess = USE_DEFAULT_CAPTION,
  278. IN UINT nIDBodyTxtFailure = USE_DEFAULT_CAPTION,
  279. IN UINT nIDClickTxt = USE_DEFAULT_CAPTION,
  280. IN UINT nIDTemplate = 0
  281. );
  282. //
  283. // Constructor for a welcome page
  284. //
  285. CIISWizardBookEnd(
  286. IN UINT nIDWelcomeTxt = 0,
  287. IN UINT nIDCaption = USE_DEFAULT_CAPTION,
  288. IN UINT nIDBodyTxt = USE_DEFAULT_CAPTION,
  289. IN UINT nIDClickTxt = USE_DEFAULT_CAPTION,
  290. IN UINT nIDTemplate = 0
  291. );
  292. //
  293. // Dialog Data
  294. //
  295. protected:
  296. //{{AFX_DATA(CPWWelcome)
  297. enum { IDD = IDD_WIZARD_BOOKEND };
  298. //}}AFX_DATA
  299. //
  300. // Overrides
  301. //
  302. protected:
  303. //{{AFX_VIRTUAL(CIISWizardBookEnd)
  304. public:
  305. virtual BOOL OnSetActive();
  306. //}}AFX_VIRTUAL
  307. //
  308. // Implementation
  309. //
  310. protected:
  311. // Generated message map functions
  312. //{{AFX_MSG(CPWTemplate)
  313. virtual BOOL OnInitDialog();
  314. //}}AFX_MSG
  315. DECLARE_MESSAGE_MAP()
  316. BOOL IsWelcomePage() const { return m_phResult == NULL; }
  317. private:
  318. HRESULT * m_phResult;
  319. CString m_strWelcomeSuccess;
  320. CString m_strWelcomeFailure;
  321. CString m_strBodySuccess;
  322. CString m_strBodyFailure;
  323. CString m_strClick;
  324. };
  325. //
  326. // Inline Expansion
  327. //
  328. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  329. inline CEmphasizedDialog::CEmphasizedDialog(
  330. IN LPCTSTR lpszTemplateName,
  331. IN CWnd * pParentWnd
  332. )
  333. : CDialog(lpszTemplateName, pParentWnd)
  334. {
  335. }
  336. inline CEmphasizedDialog::CEmphasizedDialog(
  337. IN UINT nIDTemplate,
  338. IN CWnd * pParentWnd
  339. )
  340. : CDialog(nIDTemplate, pParentWnd)
  341. {
  342. }
  343. inline CEmphasizedDialog::CEmphasizedDialog()
  344. : CDialog()
  345. {
  346. }
  347. inline BOOL CIISWizardSheet::IsWizard97() const
  348. {
  349. return ((HBITMAP)m_bmpWelcome != NULL);
  350. }
  351. inline CFont * CIISWizardSheet::GetSpecialFont(BOOL fHeader)
  352. {
  353. return fHeader ? &m_fontTitle : &m_fontWelcome;
  354. }
  355. inline CDC * CIISWizardSheet::GetBitmapMemDC(BOOL fHeader)
  356. {
  357. return fHeader ? &m_dcMemHeader : &m_dcMemWelcome;
  358. }
  359. inline LONG CIISWizardSheet::QueryBitmapWidth(BOOL fHeader) const
  360. {
  361. return fHeader ? m_bmHeaderInfo.bmWidth : m_bmWelcomeInfo.bmWidth;
  362. }
  363. inline LONG CIISWizardSheet::QueryBitmapHeight(BOOL fHeader) const
  364. {
  365. return fHeader ? m_bmHeaderInfo.bmHeight : m_bmWelcomeInfo.bmHeight;
  366. }
  367. inline CIISWizardSheet * CIISWizardPage::GetSheet() const
  368. {
  369. return (CIISWizardSheet *)GetParent();
  370. }
  371. inline void CIISWizardPage::SetWizardButtons(DWORD dwFlags)
  372. {
  373. GetSheet()->SetWizardButtons(dwFlags);
  374. }
  375. inline void CIISWizardPage::EnableSheetButton(int nID, BOOL fEnable)
  376. {
  377. GetSheet()->EnableButton(nID, fEnable);
  378. }
  379. inline BOOL CIISWizardPage::IsWizard97() const
  380. {
  381. return GetSheet()->IsWizard97();
  382. }
  383. inline CFont * CIISWizardPage::GetSpecialFont()
  384. {
  385. ASSERT(IsWizard97());
  386. return GetSheet()->GetSpecialFont(m_fUseHeader);
  387. }
  388. inline CFont * CIISWizardPage::GetBoldFont()
  389. {
  390. ASSERT(IsWizard97());
  391. return GetSheet()->GetBoldFont();
  392. }
  393. inline CFont * CIISWizardPage::GetBigFont()
  394. {
  395. ASSERT(IsWizard97());
  396. return GetSheet()->GetBigFont();
  397. }
  398. inline CDC * CIISWizardPage::GetBitmapMemDC()
  399. {
  400. ASSERT(IsWizard97());
  401. return GetSheet()->GetBitmapMemDC(m_fUseHeader);
  402. }
  403. inline LONG CIISWizardPage::QueryBitmapWidth() const
  404. {
  405. ASSERT(IsWizard97());
  406. return GetSheet()->QueryBitmapWidth(m_fUseHeader);
  407. }
  408. inline LONG CIISWizardPage::QueryBitmapHeight() const
  409. {
  410. ASSERT(IsWizard97());
  411. return GetSheet()->QueryBitmapHeight(m_fUseHeader);
  412. }
  413. inline HBRUSH CIISWizardPage::GetBackgroundBrush() const
  414. {
  415. ASSERT(IsWizard97());
  416. return GetSheet()->GetBackgroundBrush();
  417. }
  418. inline CBrush * CIISWizardPage::GetWindowBrush()
  419. {
  420. ASSERT(IsWizard97());
  421. return GetSheet()->GetWindowBrush();
  422. }
  423. inline COLORREF CIISWizardPage::QueryWindowColor() const
  424. {
  425. ASSERT(IsWizard97());
  426. return GetSheet()->QueryWindowColor();
  427. }
  428. inline COLORREF CIISWizardPage::QueryWindowTextColor() const
  429. {
  430. ASSERT(IsWizard97());
  431. return GetSheet()->QueryWindowTextColor();
  432. }
  433. #endif // __IISUI_WIZARD_H__