Leaked source code of windows server 2003
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.

686 lines
21 KiB

  1. // wizards.h - Wizards header
  2. #ifndef _WIZARDS_H_
  3. #define _WIZARDS_H_
  4. #include "util.h"
  5. #include "scopenode.h"
  6. class CAddQueryWizard;
  7. class CQueryNode;
  8. // Common wizard base class
  9. class CWizardBase
  10. {
  11. public:
  12. CWizardBase() : m_hFontWelcome(0) {}
  13. virtual ~CWizardBase() { if (m_hFontWelcome) DeleteObject(m_hFontWelcome); }
  14. virtual HRESULT Run(IPropertySheetProvider* pProvider, HWND hwndParent) = 0;
  15. virtual int OnNext(UINT uPageID) { return 0; }
  16. virtual int OnBack(UINT uPageID) { return 0; }
  17. virtual BOOL OnCancel() = 0;
  18. HFONT GetWelcomeFont();
  19. protected:
  20. void SetWizardBitmaps(UINT watermarkID, UINT headerID);
  21. BOOL AddPage(HPROPSHEETPAGE hPage) { return m_propsheet.AddPage(hPage); }
  22. HWND GetActivePage() { return m_propsheet.GetActivePage(); }
  23. int DoModal(HWND hwndParent) { return m_propsheet.DoModal(hwndParent); }
  24. private:
  25. HFONT m_hFontWelcome;
  26. CPropertySheet m_propsheet;
  27. };
  28. ///////////////////////////////////////////////////////////////////////////
  29. // CQueryWizPage
  30. class CQueryWizPage : public CPropertyPageImpl<CQueryWizPage>
  31. {
  32. public:
  33. typedef CPropertyPageImpl<CQueryWizPage> BC;
  34. enum { IDD = IDD_QUERY_WIZ_QUERY };
  35. // Constructor/destructor
  36. CQueryWizPage(CWizardBase* pWizard) : m_pWizard(pWizard), m_pQueryNode(NULL) {}
  37. void Initialize(CQueryNode* pQueryNode)
  38. {
  39. m_pQueryNode = pQueryNode;
  40. m_psp.dwFlags |= PSP_USEHEADERTITLE|PSP_USEHEADERSUBTITLE;
  41. m_strTitle.LoadString(IDS_QUERYWIZ_TITLE);
  42. m_psp.pszHeaderTitle = m_strTitle;
  43. m_strSubTitle.LoadString(IDS_QUERYWIZ_SUBTITLE);
  44. m_psp.pszHeaderSubTitle = m_strSubTitle;
  45. }
  46. LPCWSTR GetQueryName() { return m_strQueryName.c_str(); }
  47. protected:
  48. BEGIN_MSG_MAP( CQueryWizPage )
  49. COMMAND_HANDLER(IDC_NAME, EN_CHANGE, OnNameChange)
  50. COMMAND_HANDLER(IDC_CREATEQUERY, BN_CLICKED, OnCreateQuery)
  51. COMMAND_HANDLER(IDC_QUERYSCOPE, BN_CLICKED, OnScopeChange)
  52. COMMAND_HANDLER(IDC_LOCALSCOPE, BN_CLICKED, OnScopeChange)
  53. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  54. CHAIN_MSG_MAP(BC)
  55. END_MSG_MAP()
  56. // message handlers
  57. LRESULT OnInitDialog( UINT mMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  58. LRESULT OnNameChange( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  59. LRESULT OnCreateQuery( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  60. LRESULT OnScopeChange( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  61. // overrrides
  62. BOOL OnSetActive();
  63. BOOL OnKillActive();
  64. BOOL OnQueryCancel() { return m_pWizard ? m_pWizard->OnCancel() : FALSE; }
  65. int OnWizardNext() { return m_pWizard ? m_pWizard->OnNext(IDD_QUERY_WIZ_QUERY) : 0; }
  66. void UpdateButtons();
  67. void DisplayScope();
  68. private:
  69. CWizardBase* m_pWizard;
  70. CQueryNode* m_pQueryNode;
  71. tstring m_strQueryName;
  72. CString m_strTitle;
  73. CString m_strSubTitle;
  74. };
  75. ///////////////////////////////////////////////////////////////////////////
  76. // CQueryIconPage
  77. class CQueryIconPage : public CPropertyPageImpl<CQueryIconPage>
  78. {
  79. public:
  80. typedef CPropertyPageImpl<CQueryIconPage> BC;
  81. enum { IDD = IDD_SELECTICON_PAGE };
  82. // Constructor/destructor
  83. CQueryIconPage(CWizardBase* pWizard) : m_pWizard(pWizard), m_pQueryNode(NULL) {}
  84. void Initialize(CQueryNode* pQueryNode)
  85. {
  86. m_pQueryNode = pQueryNode;
  87. m_psp.dwFlags |= PSP_USEHEADERTITLE|PSP_USEHEADERSUBTITLE;
  88. m_strTitle.LoadString(IDS_QUERYICON_TITLE);
  89. m_psp.pszHeaderTitle = m_strTitle;
  90. m_strSubTitle.LoadString(IDS_QUERYICON_SUBTITLE);
  91. m_psp.pszHeaderSubTitle = m_strSubTitle;
  92. }
  93. protected:
  94. BEGIN_MSG_MAP( CQueryIconPage )
  95. NOTIFY_HANDLER ( IDC_ICONLIST, LVN_ITEMCHANGED, OnIconSelected )
  96. MESSAGE_HANDLER( WM_INITDIALOG, OnInitDialog )
  97. CHAIN_MSG_MAP(BC)
  98. END_MSG_MAP()
  99. // message handlers
  100. LRESULT OnInitDialog ( UINT mMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  101. LRESULT OnIconSelected ( int idCtrl, LPNMHDR pnmh, BOOL& bHandled );
  102. // overrrides
  103. BOOL OnSetActive();
  104. BOOL OnKillActive();
  105. BOOL OnQueryCancel() { return m_pWizard ? m_pWizard->OnCancel() : FALSE; }
  106. int OnWizardBack() { return m_pWizard ? m_pWizard->OnBack(IDD_SELECTICON_PAGE) : 0; }
  107. int OnWizardNext() { return m_pWizard ? m_pWizard->OnNext(IDD_SELECTICON_PAGE) : 0; }
  108. void UpdateButtons();
  109. private:
  110. CWizardBase* m_pWizard;
  111. CQueryNode* m_pQueryNode;
  112. CString m_strTitle;
  113. CString m_strSubTitle;
  114. };
  115. //////////////////////////////////////////////////////////////////////////
  116. // CObjectWizPage
  117. class CObjectWizPage : public CPropertyPageImpl<CObjectWizPage>
  118. {
  119. public:
  120. typedef CPropertyPageImpl<CObjectWizPage> BC;
  121. enum { IDD = IDD_QUERY_WIZ_OBJECT };
  122. // Constructor/destructor
  123. CObjectWizPage(CWizardBase* pWizard) : m_pWizard(pWizard), m_bSkipObjects(FALSE), m_pvpClassInfo(NULL) {}
  124. void Initialize()
  125. {
  126. m_psp.dwFlags |= PSP_USEHEADERTITLE|PSP_USEHEADERSUBTITLE;
  127. m_strTitle.LoadString(IDS_OBJECTWIZ_TITLE);
  128. m_psp.pszHeaderTitle = m_strTitle;
  129. m_strSubTitle.LoadString(IDS_OBJECTWIZ_SUBTITLE);
  130. m_psp.pszHeaderSubTitle = m_strSubTitle;
  131. }
  132. void SetClassInfo(std::vector<CClassInfo*>* pvpClassInfo) { m_pvpClassInfo = pvpClassInfo; }
  133. BOOL SkipObjects() { return m_bSkipObjects; }
  134. protected:
  135. BEGIN_MSG_MAP( CObjectWizPage )
  136. COMMAND_HANDLER(IDC_DEFINE_QUERY_OBJS, BN_CLICKED, OnSkipChange)
  137. COMMAND_HANDLER(IDC_SKIP_QUERY_OBJS, BN_CLICKED, OnSkipChange)
  138. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  139. CHAIN_MSG_MAP(BC)
  140. END_MSG_MAP()
  141. // message handlers
  142. LRESULT OnInitDialog( UINT mMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  143. LRESULT OnSkipChange( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  144. // overrrides
  145. BOOL OnSetActive();
  146. BOOL OnQueryCancel() { return m_pWizard ? m_pWizard->OnCancel() : FALSE; }
  147. int OnWizardNext() { return m_pWizard ? m_pWizard->OnNext(IDD_QUERY_WIZ_OBJECT) : 0; }
  148. private:
  149. CWizardBase* m_pWizard;
  150. BOOL m_bSkipObjects;
  151. CString m_strTitle;
  152. CString m_strSubTitle;
  153. std::vector<CClassInfo*>* m_pvpClassInfo;
  154. };
  155. /////////////////////////////////////////////////////////////////
  156. // CMenuWizPage
  157. class CMenuWizPage : public CPropertyPageImpl<CMenuWizPage>
  158. {
  159. public:
  160. typedef CPropertyPageImpl<CMenuWizPage> BC;
  161. // Constructor/destructor
  162. CMenuWizPage(CWizardBase* pWizard) : m_pWizard(pWizard), m_pClassInfo(NULL), m_pStringTable(NULL) {}
  163. virtual ~CMenuWizPage() { m_MenuLV.Detach(); }
  164. enum { IDD = IDD_COMMON_WIZ_MENU };
  165. void Initialize(IStringTable* pStringTable)
  166. {
  167. m_pStringTable = pStringTable;
  168. m_psp.dwFlags |= PSP_USEHEADERTITLE|PSP_USEHEADERSUBTITLE;
  169. m_strTitle.LoadString(IDS_MENUWIZ_TITLE);
  170. m_psp.pszHeaderTitle = m_strTitle;
  171. m_strSubTitle.LoadString(IDS_MENUWIZ_SUBTITLE);
  172. m_psp.pszHeaderSubTitle = m_strSubTitle;
  173. }
  174. void SetClassInfo(CClassInfo* pClassInfo) { m_pClassInfo = pClassInfo; }
  175. void AddMenuItem(CMenuCmd* pMenuCmd);
  176. protected:
  177. BEGIN_MSG_MAP( CMenuWizPage )
  178. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  179. NOTIFY_HANDLER(IDC_MENULIST, LVN_ITEMCHANGED, OnMenuListChanged)
  180. COMMAND_HANDLER(IDC_ADDMENU, BN_CLICKED, OnAddMenu)
  181. COMMAND_HANDLER(IDC_REMOVEMENU, BN_CLICKED, OnRemoveMenu)
  182. CHAIN_MSG_MAP(BC)
  183. END_MSG_MAP()
  184. // message handlers
  185. LRESULT OnInitDialog( UINT mMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  186. LRESULT OnAddMenu( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  187. LRESULT OnRemoveMenu( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  188. LRESULT OnMenuListChanged(int idCtrl, LPNMHDR pNMHDR, BOOL& bHandled);
  189. // overrrides
  190. BOOL OnSetActive();
  191. BOOL OnQueryCancel() { return m_pWizard ? m_pWizard->OnCancel() : FALSE; }
  192. int OnWizardNext() { return m_pWizard ? m_pWizard->OnNext(IDD_COMMON_WIZ_MENU) : 0; }
  193. int OnWizardBack() { return m_pWizard ? m_pWizard->OnBack(IDD_COMMON_WIZ_MENU) : 0; }
  194. private:
  195. CWizardBase* m_pWizard;
  196. IStringTable* m_pStringTable;
  197. CClassInfo* m_pClassInfo;
  198. CListViewEx m_MenuLV;
  199. CString m_strTitle;
  200. CString m_strSubTitle;
  201. };
  202. ///////////////////////////////////////////////////////////////////////
  203. // CPropertyWizPage
  204. class CPropertyWizPage : public CPropertyPageImpl<CPropertyWizPage>
  205. {
  206. public:
  207. typedef CPropertyPageImpl<CPropertyWizPage> BC;
  208. enum { IDD = IDD_COMMON_WIZ_PROPERTIES };
  209. // Constructor/destructor
  210. CPropertyWizPage(CWizardBase* pWizard) : m_pWizard(pWizard), m_pClassInfo(NULL) {}
  211. void Initialize()
  212. {
  213. m_psp.dwFlags |= PSP_USEHEADERTITLE|PSP_USEHEADERSUBTITLE;
  214. m_strTitle.LoadString(IDS_PROPWIZ_TITLE);
  215. m_psp.pszHeaderTitle = m_strTitle;
  216. m_strSubTitle.LoadString(IDS_PROPWIZ_SUBTITLE);
  217. m_psp.pszHeaderSubTitle = m_strSubTitle;
  218. }
  219. void SetClassInfo(CClassInfo* pClassInfo) { m_pClassInfo = pClassInfo; }
  220. protected:
  221. BEGIN_MSG_MAP( CPropertyWizPage )
  222. NOTIFY_HANDLER(IDC_COLUMNLIST, LVN_ITEMCHANGED, OnColumnChanged)
  223. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  224. CHAIN_MSG_MAP(BC)
  225. END_MSG_MAP()
  226. // message handlers
  227. LRESULT OnInitDialog( UINT mMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  228. LRESULT OnColumnChanged(int idCtrl, LPNMHDR pNMHDR, BOOL& bHandled);
  229. // overrrides
  230. BOOL OnSetActive();
  231. BOOL OnKillActive();
  232. BOOL OnQueryCancel() { return m_pWizard ? m_pWizard->OnCancel() : FALSE; }
  233. int OnWizardNext() { return m_pWizard ? m_pWizard->OnNext(IDD_COMMON_WIZ_PROPERTIES) : 0; }
  234. int OnWizardBack() { return m_pWizard ? m_pWizard->OnBack(IDD_COMMON_WIZ_PROPERTIES) : 0; }
  235. virtual void SetDialogText(LPCTSTR pszClass);
  236. protected:
  237. CWizardBase* m_pWizard;
  238. CClassInfo* m_pClassInfo;
  239. CListViewEx m_ColumnLV;
  240. CString m_strTitle;
  241. CString m_strSubTitle;
  242. BOOL m_bLoading;
  243. };
  244. ///////////////////////////////////////////////////////////////////////////////
  245. // CColumnWizPage
  246. //
  247. // This class derives from CPropertyWizPage and just overrides the Initialization
  248. // and SetDialogText methods in order to display the term Columns rather than Properties.
  249. // The Object wizard uses the term Properties and the Query wizard uses Columns.
  250. class CColumnWizPage : public CPropertyWizPage
  251. {
  252. public:
  253. CColumnWizPage(CWizardBase* pWizard) : CPropertyWizPage(pWizard) {}
  254. void Initialize()
  255. {
  256. m_psp.dwFlags |= PSP_USEHEADERTITLE|PSP_USEHEADERSUBTITLE;
  257. m_strTitle.LoadString(IDS_COLWIZ_TITLE);
  258. m_psp.pszHeaderTitle = m_strTitle;
  259. m_strSubTitle.LoadString(IDS_COLWIZ_SUBTITLE);
  260. m_psp.pszHeaderSubTitle = m_strSubTitle;
  261. }
  262. protected:
  263. virtual void SetDialogText(LPCTSTR pszClass);
  264. };
  265. //////////////////////////////////////////////////////////////////////////
  266. // CAddQueryWelcomePage
  267. class CAddQueryWelcomePage : public CPropertyPageImpl<CAddQueryWelcomePage>
  268. {
  269. public:
  270. typedef CPropertyPageImpl<CAddQueryWelcomePage> BC;
  271. enum { IDD = IDD_QUERY_WIZ_WELCOME };
  272. // Constructor/destructor
  273. CAddQueryWelcomePage(CWizardBase* pWizard) : m_pWizard(pWizard)
  274. {
  275. // show watwrmark rather than header
  276. m_psp.dwFlags |= PSP_HIDEHEADER;
  277. }
  278. protected:
  279. BEGIN_MSG_MAP( CAddQueryWelcomePage )
  280. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  281. CHAIN_MSG_MAP(BC)
  282. END_MSG_MAP()
  283. // message handlers
  284. LRESULT OnInitDialog( UINT mMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  285. // overrrides
  286. BOOL OnSetActive();
  287. BOOL OnQueryCancel() { return m_pWizard ? m_pWizard->OnCancel() : FALSE; }
  288. private:
  289. CWizardBase* m_pWizard;
  290. };
  291. ///////////////////////////////////////////////////////////////////////////
  292. // CAddQueryCompletionPage
  293. class CAddQueryCompletionPage : public CPropertyPageImpl<CAddQueryCompletionPage>
  294. {
  295. public:
  296. typedef CPropertyPageImpl<CAddQueryCompletionPage> BC;
  297. // Constructor/destructor
  298. CAddQueryCompletionPage(CWizardBase* pWizard) : m_pWizard(pWizard), m_pQueryNode(NULL)
  299. {
  300. // show watwrmark rather than header
  301. m_psp.dwFlags |= PSP_HIDEHEADER;
  302. }
  303. void Initialize(CQueryNode* pQueryNode) { m_pQueryNode = pQueryNode; }
  304. enum { IDD = IDD_QUERY_WIZ_COMPLETION };
  305. protected:
  306. BEGIN_MSG_MAP( CAddQueryCompletionPage )
  307. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  308. CHAIN_MSG_MAP(BC)
  309. END_MSG_MAP()
  310. // message handlers
  311. LRESULT OnInitDialog( UINT mMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  312. // overrrides
  313. BOOL OnSetActive();
  314. BOOL OnQueryCancel() { return m_pWizard ? m_pWizard->OnCancel(): FALSE; }
  315. int OnWizardBack() { return m_pWizard ? m_pWizard->OnBack(IDD_QUERY_WIZ_COMPLETION) : 0; }
  316. private:
  317. CWizardBase* m_pWizard;
  318. CQueryNode* m_pQueryNode;
  319. };
  320. //////////////////////////////////////////////////////////////////////////////
  321. // CAddQueryWizard
  322. class CAddQueryWizard : public CWizardBase
  323. {
  324. public:
  325. CAddQueryWizard() : m_pQueryNode(NULL), m_pRootNode(NULL),
  326. m_WelcomePage(this), m_ObjectPage(this), m_QueryPage(this), m_MenuPage(this),
  327. m_PropertyPage(this), m_CompletionPage(this), m_IconPage(this) {}
  328. virtual ~CAddQueryWizard()
  329. {
  330. // Delete the class info because the vector holds plain pointers
  331. std::vector<CClassInfo*>::iterator itpClass;
  332. for (itpClass = m_vpClassInfo.begin(); itpClass != m_vpClassInfo.end(); ++itpClass)
  333. delete *itpClass;
  334. }
  335. void Initialize(CQueryNode* pQueryNode, CRootNode* pRootNode, IStringTable* pStringTable)
  336. {
  337. ASSERT(pQueryNode != NULL && pRootNode != NULL && pStringTable != NULL);
  338. m_pQueryNode = pQueryNode;
  339. m_pRootNode = pRootNode;
  340. m_QueryPage.Initialize(pQueryNode);
  341. m_IconPage.Initialize(pQueryNode);
  342. m_ObjectPage.Initialize();
  343. m_MenuPage.Initialize(pStringTable);
  344. m_PropertyPage.Initialize();
  345. m_CompletionPage.Initialize(pQueryNode);
  346. }
  347. virtual HRESULT Run(IPropertySheetProvider* pProvider, HWND hwndParent);
  348. LPCWSTR GetQueryName() { return m_QueryPage.GetQueryName(); }
  349. std::vector<CClassInfo*>& GetNewClassInfo() { return m_vpClassInfo; }
  350. public:
  351. // CWizardBase methods
  352. virtual int OnNext(UINT uPageID);
  353. virtual int OnBack(UINT uPageID);
  354. virtual BOOL OnCancel();
  355. protected:
  356. void SelectClasses();
  357. protected:
  358. CAddQueryWelcomePage m_WelcomePage;
  359. CQueryWizPage m_QueryPage;
  360. CQueryIconPage m_IconPage;
  361. CObjectWizPage m_ObjectPage;
  362. CMenuWizPage m_MenuPage;
  363. CPropertyWizPage m_PropertyPage;
  364. CAddQueryCompletionPage m_CompletionPage;
  365. CQueryNode* m_pQueryNode;
  366. CRootNode* m_pRootNode;
  367. int m_iClassIndex;
  368. std::vector<CClassInfo*> m_vpClassInfo;
  369. };
  370. //////////////////////////////////////////////////////////////////////////
  371. // CAddObjectWelcomePage
  372. class CAddObjectWelcomePage : public CPropertyPageImpl<CAddObjectWelcomePage>
  373. {
  374. public:
  375. typedef CPropertyPageImpl<CAddObjectWelcomePage> BC;
  376. enum { IDD = IDD_OBJECT_WIZ_WELCOME };
  377. // Constructor/destructor
  378. CAddObjectWelcomePage(CWizardBase* pWizard) : m_pWizard(pWizard)
  379. {
  380. // show watwrmark rather than header
  381. m_psp.dwFlags |= PSP_HIDEHEADER;
  382. }
  383. protected:
  384. BEGIN_MSG_MAP( CAddObjectWelcomePage )
  385. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  386. CHAIN_MSG_MAP(BC)
  387. END_MSG_MAP()
  388. // message handlers
  389. LRESULT OnInitDialog( UINT mMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  390. // overrrides
  391. BOOL OnSetActive();
  392. BOOL OnQueryCancel() { return m_pWizard ? m_pWizard->OnCancel() : FALSE; }
  393. private:
  394. CWizardBase* m_pWizard;
  395. };
  396. ///////////////////////////////////////////////////////////////////////////
  397. // CAddObjectCompletionPage
  398. class CAddObjectCompletionPage : public CPropertyPageImpl<CAddObjectCompletionPage>
  399. {
  400. public:
  401. typedef CPropertyPageImpl<CAddObjectCompletionPage> BC;
  402. // Constructor/destructor
  403. CAddObjectCompletionPage(CWizardBase* pWizard) : m_pWizard(pWizard), m_pClassInfo(NULL)
  404. {
  405. // show watermark rather than header
  406. m_psp.dwFlags |= PSP_HIDEHEADER;
  407. }
  408. void SetClassInfo(CClassInfo* pClassInfo) { m_pClassInfo = pClassInfo; }
  409. enum { IDD = IDD_OBJECT_WIZ_COMPLETION };
  410. protected:
  411. BEGIN_MSG_MAP( CAddObjectCompletionPage )
  412. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  413. COMMAND_HANDLER(IDC_SETTINGS, EN_SETFOCUS, OnSetFocus)
  414. CHAIN_MSG_MAP(BC)
  415. END_MSG_MAP()
  416. // message handlers
  417. LRESULT OnInitDialog( UINT mMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  418. LRESULT OnSetFocus( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  419. // overrrides
  420. BOOL OnSetActive();
  421. BOOL OnQueryCancel() { return m_pWizard ? m_pWizard->OnCancel() : FALSE; }
  422. int OnWizardBack() { return m_pWizard ? m_pWizard->OnBack(IDD_QUERY_WIZ_COMPLETION) : 0; }
  423. private:
  424. CWizardBase* m_pWizard;
  425. CClassInfo* m_pClassInfo;
  426. BOOL bFirstFocus;
  427. };
  428. ///////////////////////////////////////////////////////////////////////////
  429. // CObjSelectWizPage
  430. class CObjSelectWizPage : public CPropertyPageImpl<CObjSelectWizPage>
  431. {
  432. public:
  433. typedef CPropertyPageImpl<CObjSelectWizPage> BC;
  434. enum { IDD = IDD_OBJECT_WIZ_SELECT };
  435. // Constructor/destructor
  436. CObjSelectWizPage(CWizardBase* pWizard) : m_pWizard(pWizard), m_pvstrCurClasses(NULL) {}
  437. void Initialize(string_vector* pvstrCurClasses)
  438. {
  439. m_pvstrCurClasses = pvstrCurClasses;
  440. m_psp.dwFlags |= PSP_USEHEADERTITLE|PSP_USEHEADERSUBTITLE;
  441. m_strTitle.LoadString(IDS_OBJSELWIZ_TITLE);
  442. m_psp.pszHeaderTitle = m_strTitle;
  443. m_strSubTitle.LoadString(IDS_OBJSELWIZ_SUBTITLE);
  444. m_psp.pszHeaderSubTitle = m_strSubTitle;
  445. }
  446. LPCWSTR GetSelectedClass();
  447. protected:
  448. BEGIN_MSG_MAP( CObjSelectWizPage )
  449. COMMAND_HANDLER(IDC_OBJECTLIST, LBN_SELCHANGE, OnObjectSelect)
  450. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  451. CHAIN_MSG_MAP(BC)
  452. END_MSG_MAP()
  453. // message handlers
  454. LRESULT OnInitDialog( UINT mMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  455. LRESULT OnObjectSelect( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  456. // overrrides
  457. BOOL OnSetActive();
  458. BOOL OnQueryCancel() { return m_pWizard ? m_pWizard->OnCancel() : FALSE; }
  459. int OnWizardNext() { return m_pWizard ? m_pWizard->OnNext(IDD_OBJECT_WIZ_SELECT) : 0; }
  460. void UpdateButtons();
  461. private:
  462. CWizardBase* m_pWizard;
  463. string_vector* m_pvstrCurClasses;
  464. CString m_strTitle;
  465. CString m_strSubTitle;
  466. };
  467. //////////////////////////////////////////////////////////////////////////////
  468. // CAddObjectWizard
  469. class CAddObjectWizard : public CWizardBase
  470. {
  471. public:
  472. CAddObjectWizard() : m_pRootNode(NULL), m_pClassInfo(NULL),
  473. m_WelcomePage(this), m_ObjSelectPage(this), m_MenuPage(this),
  474. m_PropertyPage(this), m_CompletionPage(this) {}
  475. virtual ~CAddObjectWizard() {}
  476. void Initialize(string_vector* pvstrCurClasses, IStringTable* pStringTable)
  477. {
  478. m_ObjSelectPage.Initialize(pvstrCurClasses);
  479. m_MenuPage.Initialize(pStringTable);
  480. m_PropertyPage.Initialize();
  481. }
  482. CClassInfo* GetNewObject() { return m_pClassInfo; }
  483. virtual HRESULT Run(IPropertySheetProvider* pProvider, HWND hwndParent);
  484. public:
  485. // CWizardBase methods
  486. virtual int OnNext(UINT uPageID);
  487. virtual BOOL OnCancel();
  488. protected:
  489. CAddObjectWelcomePage m_WelcomePage;
  490. CObjSelectWizPage m_ObjSelectPage;
  491. CMenuWizPage m_MenuPage;
  492. CPropertyWizPage m_PropertyPage;
  493. CAddObjectCompletionPage m_CompletionPage;
  494. CRootNode* m_pRootNode;
  495. CClassInfo* m_pClassInfo;
  496. };
  497. #endif //_WIZARDS_H_