WizardPages.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. /****************************************************************/
  2. /* */
  3. /* WizardPages.cpp */
  4. /* */
  5. /* Implementation of the New User Wizard. */
  6. /* */
  7. /* Programmed by LYFZ van der Meer */
  8. /* Copyright LYFZ Software Solutions 2002 */
  9. /* http://www.LYFZvandermeer.nl */
  10. /* */
  11. /* Last updated: 10 july 2002 */
  12. /* */
  13. /****************************************************************/
  14. #include "stdafx.h"
  15. #include "DBServer.h"
  16. #include "theDBServer.h"
  17. #include "WizardPages.h"
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. IMPLEMENT_DYNAMIC(CWizardSheet, CPropertySheetEx)
  24. CWizardSheet::CWizardSheet(UINT nIDCaption, CWnd* pParentWnd,
  25. UINT iSelectPage, HBITMAP hbmWatermark, HPALETTE hpalWatermark,
  26. HBITMAP hbmHeader)
  27. : CPropertySheetEx(nIDCaption, pParentWnd, iSelectPage,
  28. hbmWatermark, hpalWatermark, hbmHeader)
  29. {
  30. // add all the pages of the wizard
  31. InitPages();
  32. // set the WIZARD97 flag so we'll get the new look
  33. m_psh.dwFlags |= PSH_WIZARD97;
  34. m_psh.dwFlags &= ~PSH_HASHELP;
  35. }
  36. CWizardSheet::CWizardSheet(LPCTSTR pszCaption, CWnd* pParentWnd,
  37. UINT iSelectPage, HBITMAP hbmWatermark, HPALETTE hpalWatermark,
  38. HBITMAP hbmHeader)
  39. : CPropertySheetEx(pszCaption, pParentWnd, iSelectPage,
  40. hbmWatermark, hpalWatermark, hbmHeader)
  41. {
  42. // add all the pages of the wizard
  43. InitPages();
  44. // set the WIZARD97 flag so we'll get the new look
  45. m_psh.dwFlags |= PSH_WIZARD97;
  46. m_psh.dwFlags &= ~PSH_HASHELP;
  47. }
  48. CWizardSheet::~CWizardSheet()
  49. {
  50. }
  51. BEGIN_MESSAGE_MAP(CWizardSheet, CPropertySheetEx)
  52. //{{AFX_MSG_MAP(CWizardSheet)
  53. //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55. /********************************************************************/
  56. /* */
  57. /* Function name : InitPages */
  58. /* Description : Add pages to wizard. */
  59. /* */
  60. /********************************************************************/
  61. void CWizardSheet::InitPages()
  62. {
  63. AddPage(&m_Page1);
  64. AddPage(&m_Page2);
  65. AddPage(&m_Page3);
  66. AddPage(&m_Page4);
  67. AddPage(&m_PageFinish);
  68. }
  69. IMPLEMENT_DYNCREATE(CWizardPage1, CPropertyPageEx)
  70. CWizardPage1::CWizardPage1() : CPropertyPageEx(CWizardPage1::IDD, 0, IDS_HEADERTITLE1, NULL)
  71. {
  72. //{{AFX_DATA_INIT(CWizardPage1)
  73. m_strAccountName = _T("");
  74. //}}AFX_DATA_INIT
  75. m_psp.dwFlags &= ~PSP_HASHELP;
  76. }
  77. CWizardPage1::~CWizardPage1()
  78. {
  79. }
  80. void CWizardPage1::DoDataExchange(CDataExchange* pDX)
  81. {
  82. CPropertyPageEx::DoDataExchange(pDX);
  83. //{{AFX_DATA_MAP(CWizardPage1)
  84. DDX_Text(pDX, IDC_ACCOUNTNAME, m_strAccountName);
  85. //}}AFX_DATA_MAP
  86. }
  87. BEGIN_MESSAGE_MAP(CWizardPage1, CPropertyPageEx)
  88. //{{AFX_MSG_MAP(CWizardPage1)
  89. //}}AFX_MSG_MAP
  90. END_MESSAGE_MAP()
  91. /********************************************************************/
  92. /* */
  93. /* Function name : OnSetActive */
  94. /* Description : Called when this becomes the active page. */
  95. /* */
  96. /********************************************************************/
  97. BOOL CWizardPage1::OnSetActive()
  98. {
  99. CPropertySheetEx* parent = (CPropertySheetEx*)GetParent();
  100. parent->SetWizardButtons(PSWIZB_NEXT);
  101. return CPropertyPageEx::OnSetActive();
  102. }
  103. /********************************************************************/
  104. /* */
  105. /* Function name : OnWizardNext */
  106. /* Description : Called when Next button has been pressed. */
  107. /* */
  108. /********************************************************************/
  109. LRESULT CWizardPage1::OnWizardNext()
  110. {
  111. CEdit *editBox = (CEdit *)GetDlgItem(IDC_ACCOUNTNAME);
  112. if (editBox->GetWindowTextLength() == 0)
  113. {
  114. MessageBox("You must enter an account name.", "Account Wizard", MB_OK | MB_ICONEXCLAMATION);
  115. editBox->SetFocus();
  116. return -1;
  117. }
  118. return CPropertyPageEx::OnWizardNext();
  119. }
  120. IMPLEMENT_DYNCREATE(CWizardPage2, CPropertyPageEx)
  121. CWizardPage2::CWizardPage2() : CPropertyPageEx(CWizardPage2::IDD, 0, IDS_HEADERTITLE2, NULL)
  122. {
  123. //{{AFX_DATA_INIT(CWizardPage2)
  124. m_strPassword = _T("");
  125. //}}AFX_DATA_INIT
  126. m_psp.dwFlags &= ~PSP_HASHELP;
  127. }
  128. CWizardPage2::~CWizardPage2()
  129. {
  130. }
  131. void CWizardPage2::DoDataExchange(CDataExchange* pDX)
  132. {
  133. CPropertyPageEx::DoDataExchange(pDX);
  134. //{{AFX_DATA_MAP(CWizardPage2)
  135. DDX_Text(pDX, IDC_PASSWORD, m_strPassword);
  136. //}}AFX_DATA_MAP
  137. }
  138. BEGIN_MESSAGE_MAP(CWizardPage2, CPropertyPageEx)
  139. //{{AFX_MSG_MAP(CWizardPage2)
  140. // NOTE: the ClassWizard will add message map macros here
  141. //}}AFX_MSG_MAP
  142. END_MESSAGE_MAP()
  143. /********************************************************************/
  144. /* */
  145. /* Function name : OnSetActive */
  146. /* Description : Called when this becomes the active page. */
  147. /* */
  148. /********************************************************************/
  149. BOOL CWizardPage2::OnSetActive()
  150. {
  151. CPropertySheetEx* parent = (CPropertySheetEx*)GetParent();
  152. parent->SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);
  153. return CPropertyPageEx::OnSetActive();
  154. }
  155. /********************************************************************/
  156. /* */
  157. /* Function name : OnWizardNext */
  158. /* Description : Called when Next button has been pressed. */
  159. /* */
  160. /********************************************************************/
  161. LRESULT CWizardPage2::OnWizardNext()
  162. {
  163. CString strPassword, strConfirmPassword;
  164. GetDlgItemText(IDC_PASSWORD, strPassword);
  165. GetDlgItemText(IDC_CONFIRMPASSWORD, strConfirmPassword);
  166. if (strPassword != strConfirmPassword)
  167. {
  168. MessageBox("The passwords do not match!\r\nPlease make sure 'Password' and 'Confirm Password' are the same.", "Connection Wizard", MB_OK | MB_ICONEXCLAMATION);
  169. GetDlgItem(IDC_PASSWORD)->SetFocus();
  170. return -1;
  171. }
  172. return CPropertyPageEx::OnWizardNext();
  173. }
  174. IMPLEMENT_DYNCREATE(CWizardPage3, CPropertyPageEx)
  175. CWizardPage3::CWizardPage3() : CPropertyPageEx(CWizardPage3::IDD, 0, IDS_HEADERTITLE3, NULL)
  176. {
  177. //{{AFX_DATA_INIT(CWizardPage3)
  178. m_strHomeDirectory = _T("");
  179. //}}AFX_DATA_INIT
  180. m_psp.dwFlags &= ~PSP_HASHELP;
  181. }
  182. CWizardPage3::~CWizardPage3()
  183. {
  184. }
  185. void CWizardPage3::DoDataExchange(CDataExchange* pDX)
  186. {
  187. CPropertyPageEx::DoDataExchange(pDX);
  188. //{{AFX_DATA_MAP(CWizardPage3)
  189. DDX_Text(pDX, IDC_HOMEDIRECTORY, m_strHomeDirectory);
  190. //}}AFX_DATA_MAP
  191. }
  192. BEGIN_MESSAGE_MAP(CWizardPage3, CPropertyPageEx)
  193. //{{AFX_MSG_MAP(CWizardPage3)
  194. ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
  195. //}}AFX_MSG_MAP
  196. END_MESSAGE_MAP()
  197. /********************************************************************/
  198. /* */
  199. /* Function name : OnSetActive */
  200. /* Description : Called when this becomes the active page. */
  201. /* */
  202. /********************************************************************/
  203. BOOL CWizardPage3::OnSetActive()
  204. {
  205. CPropertySheetEx* parent = (CPropertySheetEx*)GetParent();
  206. parent->SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);
  207. return CPropertyPageEx::OnSetActive();
  208. }
  209. /********************************************************************/
  210. /* */
  211. /* Function name : OnBrowse */
  212. /* Description : Browse for folder. */
  213. /* */
  214. /********************************************************************/
  215. void CWizardPage3::OnBrowse()
  216. {
  217. CString strDir = BrowseForFolder(m_hWnd, "Select a directory:", BIF_RETURNONLYFSDIRS);
  218. if (!strDir.IsEmpty())
  219. {
  220. GetDlgItem(IDC_HOMEDIRECTORY)->SetWindowText(strDir);
  221. }
  222. }
  223. /********************************************************************/
  224. /* */
  225. /* Function name : OnWizardNext */
  226. /* Description : Called when Next button has been pressed. */
  227. /* */
  228. /********************************************************************/
  229. LRESULT CWizardPage3::OnWizardNext()
  230. {
  231. CString strHomeDirectory;
  232. if (GetDlgItemText(IDC_HOMEDIRECTORY, strHomeDirectory) == 0)
  233. {
  234. MessageBox("You must specify a home directory.", "Account Wizard", MB_OK | MB_ICONEXCLAMATION);
  235. GetDlgItem(IDC_HOMEDIRECTORY)->SetFocus();
  236. return -1;
  237. }
  238. // check if it's a valid directory
  239. if (GetFileAttributes(strHomeDirectory) == 0xFFFFFFFF)
  240. {
  241. MessageBox("The directory you entered is not valid.", "Account Wizard", MB_OK | MB_ICONEXCLAMATION);
  242. GetDlgItem(IDC_HOMEDIRECTORY)->SetFocus();
  243. return -1;
  244. }
  245. return CPropertyPageEx::OnWizardNext();
  246. }
  247. IMPLEMENT_DYNCREATE(CWizardPage4, CPropertyPageEx)
  248. CWizardPage4::CWizardPage4() : CPropertyPageEx(CWizardPage4::IDD, 0, IDS_HEADERTITLE4, NULL)
  249. {
  250. //{{AFX_DATA_INIT(CWizardPage4)
  251. m_bAllowCreateDirectory = FALSE;
  252. m_bAllowDelete = FALSE;
  253. m_bAllowDownload = FALSE;
  254. m_bAllowRename = FALSE;
  255. m_bAllowUpload = FALSE;
  256. //}}AFX_DATA_INIT
  257. m_psp.dwFlags &= ~PSP_HASHELP;
  258. }
  259. CWizardPage4::~CWizardPage4()
  260. {
  261. }
  262. void CWizardPage4::DoDataExchange(CDataExchange* pDX)
  263. {
  264. CPropertyPageEx::DoDataExchange(pDX);
  265. //{{AFX_DATA_MAP(CWizardPage4)
  266. DDX_Check(pDX, IDC_CREATE_DIR, m_bAllowCreateDirectory);
  267. DDX_Check(pDX, IDC_DELETE, m_bAllowDelete);
  268. DDX_Check(pDX, IDC_DOWNLOAD, m_bAllowDownload);
  269. DDX_Check(pDX, IDC_RENAME, m_bAllowRename);
  270. DDX_Check(pDX, IDC_UPLOAD, m_bAllowUpload);
  271. //}}AFX_DATA_MAP
  272. }
  273. BEGIN_MESSAGE_MAP(CWizardPage4, CPropertyPageEx)
  274. //{{AFX_MSG_MAP(CWizardPage4)
  275. //}}AFX_MSG_MAP
  276. END_MESSAGE_MAP()
  277. /********************************************************************/
  278. /* */
  279. /* Function name : OnInitDialog */
  280. /* Description : Initialize dialog. */
  281. /* */
  282. /********************************************************************/
  283. BOOL CWizardPage4::OnInitDialog()
  284. {
  285. CPropertyPageEx::OnInitDialog();
  286. return TRUE;
  287. }
  288. /********************************************************************/
  289. /* */
  290. /* Function name : OnSetActive */
  291. /* Description : Called when this becomes the active page. */
  292. /* */
  293. /********************************************************************/
  294. BOOL CWizardPage4::OnSetActive()
  295. {
  296. CPropertySheetEx* parent = (CPropertySheetEx*)GetParent();
  297. parent->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT);
  298. return CPropertyPageEx::OnSetActive();
  299. }
  300. IMPLEMENT_DYNCREATE(CWizardFinish, CPropertyPageEx)
  301. CWizardFinish::CWizardFinish() : CPropertyPageEx(CWizardFinish::IDD)
  302. {
  303. //{{AFX_DATA_INIT(CWizardFinish)
  304. //}}AFX_DATA_INIT
  305. m_psp.dwFlags |= PSP_HIDEHEADER;
  306. m_psp.dwFlags &= ~PSP_HASHELP;
  307. }
  308. CWizardFinish::~CWizardFinish()
  309. {
  310. }
  311. void CWizardFinish::DoDataExchange(CDataExchange* pDX)
  312. {
  313. CPropertyPageEx::DoDataExchange(pDX);
  314. //{{AFX_DATA_MAP(CWizardFinish)
  315. //}}AFX_DATA_MAP
  316. }
  317. BEGIN_MESSAGE_MAP(CWizardFinish, CPropertyPageEx)
  318. //{{AFX_MSG_MAP(CWizardFinish)
  319. ON_BN_CLICKED(IDC_CONNECTNOW, OnConnectnow)
  320. //}}AFX_MSG_MAP
  321. END_MESSAGE_MAP()
  322. /********************************************************************/
  323. /* */
  324. /* Function name : OnSetActive */
  325. /* Description : Called when this becomes the active page. */
  326. /* */
  327. /********************************************************************/
  328. BOOL CWizardFinish::OnSetActive()
  329. {
  330. CPropertySheetEx* parent = (CPropertySheetEx*)GetParent();
  331. parent->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT | PSWIZB_FINISH);
  332. return CPropertyPageEx::OnSetActive();
  333. }
  334. /********************************************************************/
  335. /* */
  336. /* Function name : OnConnectnow */
  337. /* Description : */
  338. /* */
  339. /********************************************************************/
  340. void CWizardFinish::OnConnectnow()
  341. {
  342. UpdateData();
  343. }