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.

865 lines
33 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright(c) Microsoft Corp., 1994 **
  4. //*********************************************************************
  5. #include "pre.h"
  6. #ifndef ICWDEBUG
  7. #include "tutor.h"
  8. extern CICWTutorApp* g_pICWTutorApp;
  9. #endif
  10. #define BITMAP_WIDTH 164
  11. #define BITMAP_HEIGHT 458
  12. /*******************************************************************
  13. NAME: GetDlgIDFromIndex
  14. SYNOPSIS: For a given zero-based page index, returns the
  15. corresponding dialog ID for the page
  16. 4/24/97 jmazner When dealing with apprentice pages, we may call
  17. this function with dialog IDs (IDD_PAGE_*), rather
  18. than an index (ORD_PAGE*). Added code to check
  19. whether the number passed in is an index or dlgID.
  20. ********************************************************************/
  21. UINT GetDlgIDFromIndex(UINT uPageIndex)
  22. {
  23. if( uPageIndex <= EXE_MAX_PAGE_INDEX )
  24. {
  25. ASSERT(uPageIndex < EXE_NUM_WIZARD_PAGES);
  26. return PageInfo[uPageIndex].uDlgID;
  27. }
  28. else
  29. {
  30. return(uPageIndex);
  31. }
  32. }
  33. //
  34. // GENDLG.C -
  35. // Generic DLG proc for common wizard functions
  36. //
  37. // HISTORY:
  38. //
  39. // 05/13/98 donaldm Created.
  40. //
  41. // ############################################################################
  42. HRESULT MakeWizard97Title (HWND hwnd)
  43. {
  44. HRESULT hr = ERROR_SUCCESS;
  45. HFONT hfont = NULL;
  46. HFONT hnewfont = NULL;
  47. LOGFONT *plogfont = NULL;
  48. HDC hDC;
  49. if (!hwnd) goto MakeWizard97TitleExit;
  50. hfont = (HFONT)SendMessage(hwnd,WM_GETFONT,0,0);
  51. if (!hfont)
  52. {
  53. hr = ERROR_GEN_FAILURE;
  54. goto MakeWizard97TitleExit;
  55. }
  56. plogfont = (LOGFONT*)malloc(sizeof(LOGFONT));
  57. if (!plogfont)
  58. {
  59. hr = ERROR_NOT_ENOUGH_MEMORY;
  60. goto MakeWizard97TitleExit;
  61. }
  62. if (!GetObject(hfont,sizeof(LOGFONT),(LPVOID)plogfont))
  63. {
  64. hr = ERROR_GEN_FAILURE;
  65. goto MakeWizard97TitleExit;
  66. }
  67. // We want 12 PT Veranda for Wizard 97.
  68. hDC = GetDC(NULL);
  69. if(hDC)
  70. {
  71. plogfont->lfHeight = -MulDiv(WIZ97_TITLE_FONT_PTS, GetDeviceCaps(hDC, LOGPIXELSY), 72);
  72. ReleaseDC(NULL, hDC);
  73. }
  74. plogfont->lfWeight = (int) FW_BOLD;
  75. if (!LoadString(g_hInstance, IDS_WIZ97_TITLE_FONT_FACE, plogfont->lfFaceName, LF_FACESIZE))
  76. lstrcpy(plogfont->lfFaceName, TEXT("Verdana"));
  77. if (!(hnewfont = CreateFontIndirect(plogfont)))
  78. {
  79. hr = ERROR_GEN_FAILURE;
  80. goto MakeWizard97TitleExit;
  81. }
  82. SendMessage(hwnd,WM_SETFONT,(WPARAM)hnewfont,MAKELPARAM(TRUE,0));
  83. free(plogfont);
  84. MakeWizard97TitleExit:
  85. //if (hfont) DeleteObject(hfont);
  86. // BUG:? Do I need to delete hnewfont at some time?
  87. // The answer is Yes. ChrisK 7/1/96
  88. return hr;
  89. }
  90. // ############################################################################
  91. HRESULT ReleaseBold(HWND hwnd)
  92. {
  93. HFONT hfont = NULL;
  94. hfont = (HFONT)SendMessage(hwnd,WM_GETFONT,0,0);
  95. if (hfont) DeleteObject(hfont);
  96. return ERROR_SUCCESS;
  97. }
  98. //-----------------------------------------------------------------------------
  99. // Function MiscInitProc
  100. //
  101. // Synopsis Our generic dialog proc calls this in case any of the wizard
  102. // dialogs have to do any sneaky stuff.
  103. //
  104. // Arguments: hDlg - dialog window
  105. // fFirstInit - TRUE if this is the first time the dialog
  106. // is initialized, FALSE if this InitProc has been called
  107. // before (e.g. went past this page and backed up)
  108. //
  109. // Returns: TRUE
  110. //
  111. // History: 10/28/96 ValdonB Created
  112. // 11/25/96 Jmazner copied from icwconn1\psheet.cpp
  113. // Normandy #10586
  114. //
  115. //-----------------------------------------------------------------------------
  116. BOOL CALLBACK MiscInitProc
  117. (
  118. HWND hDlg,
  119. BOOL fFirstInit,
  120. UINT uDlgID
  121. )
  122. {
  123. // switch( uDlgID )
  124. // {
  125. // }
  126. return TRUE;
  127. }
  128. INT_PTR CALLBACK CancelCmdProc
  129. (
  130. HWND hDlg,
  131. UINT uMsg,
  132. WPARAM wParam,
  133. LPARAM lParam
  134. )
  135. {
  136. switch (uMsg)
  137. {
  138. case WM_INITDIALOG:
  139. // put the dialog in the center of the screen
  140. RECT rc;
  141. GetWindowRect(hDlg, &rc);
  142. SetWindowPos(hDlg,
  143. NULL,
  144. ((GetSystemMetrics(SM_CXSCREEN) - (rc.right - rc.left)) / 2),
  145. ((GetSystemMetrics(SM_CYSCREEN) - (rc.bottom - rc.top)) / 2),
  146. 0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
  147. break;
  148. case WM_COMMAND:
  149. switch (LOWORD(wParam))
  150. {
  151. case IDOK:
  152. if (Button_GetCheck(GetDlgItem(hDlg, IDC_CHECK_HIDE_ICW)))
  153. {
  154. // Set the welcome state
  155. UpdateWelcomeRegSetting(TRUE);
  156. // Restore the desktop
  157. UndoDesktopChanges(g_hInstance);
  158. // Mark the ICW as being complete
  159. SetICWComplete();
  160. gfQuitWizard = TRUE;
  161. }
  162. EndDialog(hDlg,TRUE);
  163. break;
  164. case IDCANCEL:
  165. EndDialog(hDlg,FALSE);
  166. break;
  167. }
  168. break;
  169. }
  170. return FALSE;
  171. }
  172. //This is a dummy winproc needed for a dummy child window
  173. //which will be used by dlls etc to get the hwnd for this app.
  174. //**************************************************
  175. //***REMOVING THIS CODE WILL CAUSE OTHER CODE ***
  176. //***IN ICWHELP AND POSSIBLY OTHER PACES TO FAIL ***
  177. //**************************************************
  178. LRESULT CALLBACK InvisibleChildDummyWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  179. {
  180. return DefWindowProc (hWnd, message, wParam, lParam);
  181. }
  182. /*******************************************************************
  183. //
  184. // Function: PaintWithPaletteBitmap
  185. //
  186. // Arguments: lprc is the target rectangle.
  187. // cy is the putative dimensions of hbmpPaint.
  188. // If the target rectangle is taller than cy, then
  189. // fill the rest with the pixel in the upper left
  190. // corner of the hbmpPaint.
  191. //
  192. // Returns: void
  193. //
  194. // History: 10-29-98 Vyung - Stole from prsht.c
  195. //
  196. ********************************************************************/
  197. void PaintWithPaletteBitmap(HDC hdc, LPRECT lprc, int cy, HBITMAP hbmpPaint)
  198. {
  199. HDC hdcBmp;
  200. hdcBmp = CreateCompatibleDC(hdc);
  201. SelectObject(hdcBmp, hbmpPaint);
  202. BitBlt(hdc, lprc->left, lprc->top, RECTWIDTH(*lprc), cy, hdcBmp, 0, 0, SRCCOPY);
  203. // StretchBlt does mirroring if you pass a negative height,
  204. // so do the stretch only if there actually is unpainted space
  205. if (RECTHEIGHT(*lprc) - cy > 0)
  206. StretchBlt(hdc, lprc->left, cy,
  207. RECTWIDTH(*lprc), RECTHEIGHT(*lprc) - cy,
  208. hdcBmp, 0, 0, 1, 1, SRCCOPY);
  209. DeleteDC(hdcBmp);
  210. }
  211. /*******************************************************************
  212. //
  213. // Function: Prsht_EraseWizBkgnd
  214. //
  215. // Arguments: Draw the background for wizard pages.
  216. // hDlg is dialog handle.
  217. // hdc is device context
  218. //
  219. // Returns: void
  220. //
  221. // History: 10-29-98 Vyung - Stole from prsht.c
  222. //
  223. ********************************************************************/
  224. LRESULT Prsht_EraseWizBkgnd(HWND hDlg, HDC hdc)
  225. {
  226. HBRUSH hbrWindow = GetSysColorBrush(COLOR_WINDOW);
  227. RECT rc;
  228. GetClientRect(hDlg, &rc);
  229. FillRect(hdc, &rc, hbrWindow);
  230. rc.right = BITMAP_WIDTH;
  231. rc.left = 0;
  232. PaintWithPaletteBitmap(hdc, &rc, BITMAP_HEIGHT, gpWizardState->cmnStateData.hbmWatermark);
  233. return TRUE;
  234. }
  235. /*******************************************************************
  236. NAME: GenDlgProc
  237. SYNOPSIS: Generic dialog proc for all wizard pages
  238. NOTES: This dialog proc provides the following default behavior:
  239. init: back and next buttons enabled
  240. next btn: switches to page following current page
  241. back btn: switches to previous page
  242. cancel btn: prompts user to confirm, and cancels the wizard
  243. dlg ctrl: does nothing (in response to WM_COMMANDs)
  244. Wizard pages can specify their own handler functions
  245. (in the PageInfo table) to override default behavior for
  246. any of the above actions.
  247. ********************************************************************/
  248. INT_PTR CALLBACK GenDlgProc
  249. (
  250. HWND hDlg,
  251. UINT uMsg,
  252. WPARAM wParam,
  253. LPARAM lParam
  254. )
  255. {
  256. static HCURSOR hcurOld = NULL;
  257. static BOOL bKilledSysmenu = FALSE;
  258. PAGEINFO *pPageInfo = (PAGEINFO *) GetWindowLongPtr(hDlg,DWLP_USER);
  259. switch (uMsg)
  260. {
  261. case WM_ERASEBKGND:
  262. {
  263. if(gpWizardState->cmnStateData.bOEMCustom)
  264. {
  265. FillWindowWithAppBackground(hDlg, (HDC)wParam);
  266. return TRUE;
  267. }
  268. else
  269. {
  270. // Only paint the external page
  271. if ((!pPageInfo->nIdTitle) && (IDD_PAGE_BRANDEDINTRO != pPageInfo->uDlgID))
  272. {
  273. Prsht_EraseWizBkgnd(hDlg, (HDC) wParam);
  274. return TRUE;
  275. }
  276. }
  277. break;
  278. }
  279. GENDLG_CTLCOLOR:
  280. case WM_CTLCOLOR:
  281. case WM_CTLCOLORMSGBOX:
  282. case WM_CTLCOLORLISTBOX:
  283. case WM_CTLCOLORBTN:
  284. case WM_CTLCOLORSCROLLBAR:
  285. {
  286. // Only paint the external page and except the ISP sel page
  287. if ((!pPageInfo->nIdTitle) && (IDD_PAGE_BRANDEDINTRO != pPageInfo->uDlgID))
  288. {
  289. HBRUSH hbrWindow = GetSysColorBrush(COLOR_WINDOW);
  290. DefWindowProc(hDlg, uMsg, wParam, lParam);
  291. SetBkMode((HDC)wParam, TRANSPARENT);
  292. return (LRESULT)hbrWindow;
  293. }
  294. break;
  295. }
  296. // We need to make sure static controls draw transparently
  297. // on the background bitmap. This is done by painting in
  298. // the appropriate portion of the background, and then
  299. // returning a NULL brush so the control just draws the text
  300. case WM_CTLCOLORSTATIC:
  301. if(gpWizardState->cmnStateData.bOEMCustom)
  302. {
  303. SetTextColor((HDC)wParam, gpWizardState->cmnStateData.clrText);
  304. // See if the control is an ES_READONLY style edit box, and if
  305. // so then don't make it transparent
  306. if (!(GetWindowLong((HWND)lParam, GWL_STYLE) & ES_READONLY))
  307. {
  308. SetBkMode((HDC)wParam, TRANSPARENT);
  309. return (INT_PTR) GetStockObject(NULL_BRUSH);
  310. }
  311. break;
  312. }
  313. else
  314. {
  315. // Not in modeless opperation so just do the default cltcolor
  316. // handling
  317. goto GENDLG_CTLCOLOR;
  318. }
  319. #ifndef ICWDEBUG
  320. case WM_RUNICWTUTORAPP:
  321. {
  322. g_pICWTutorApp->LaunchTutorApp();
  323. break;
  324. }
  325. #endif
  326. case WM_INITDIALOG:
  327. {
  328. // get propsheet page struct passed in
  329. LPPROPSHEETPAGE lpsp = (LPPROPSHEETPAGE) lParam;
  330. ASSERT(lpsp);
  331. // fetch our private page info from propsheet struct
  332. pPageInfo = (PAGEINFO *)lpsp->lParam;
  333. // store pointer to private page info in window data for later
  334. SetWindowLongPtr(hDlg,DWLP_USER,(LPARAM) pPageInfo);
  335. if(!gpWizardState->cmnStateData.bOEMCustom)
  336. {
  337. if (!bKilledSysmenu )
  338. {
  339. HWND hWnd = GetParent(hDlg);
  340. RECT rect;
  341. //Get our current pos and width etc.
  342. GetWindowRect(hWnd, &rect);
  343. //Let's get centred
  344. MoveWindow(hWnd,
  345. (GetSystemMetrics(SM_CXSCREEN) - (rect.right - rect.left )) / 2, //int X,
  346. (GetSystemMetrics(SM_CYSCREEN) - (rect.bottom - rect.top )) / 2, //int Y,
  347. rect.right - rect.left, //width
  348. rect.bottom - rect.top, // height
  349. TRUE);
  350. // Get the main frame window's style
  351. LONG window_style = GetWindowLong(GetParent(hDlg), GWL_EXSTYLE);
  352. //Remove the system menu from the window's style
  353. window_style &= ~WS_EX_CONTEXTHELP;
  354. //set the style attribute of the main frame window
  355. SetWindowLong(GetParent(hDlg), GWL_EXSTYLE, window_style);
  356. bKilledSysmenu = TRUE;
  357. }
  358. }
  359. else
  360. {
  361. // Parent should control us, so the user can tab out of our property sheet
  362. DWORD dwStyle = GetWindowLong(hDlg, GWL_EXSTYLE);
  363. dwStyle = dwStyle | WS_EX_CONTROLPARENT;
  364. SetWindowLong(hDlg, GWL_EXSTYLE, dwStyle);
  365. }
  366. // initialize 'back' and 'next' wizard buttons, if
  367. // page wants something different it can fix in init proc below
  368. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_NEXT | PSWIZB_BACK);
  369. // Make the title text bold
  370. MakeWizard97Title(GetDlgItem(hDlg,IDC_LBLTITLE));
  371. // call init proc for this page if one is specified
  372. if (pPageInfo->InitProc)
  373. {
  374. if (!( pPageInfo->InitProc(hDlg,TRUE, NULL)))
  375. {
  376. // If a fatal error occured, quit the wizard.
  377. // Note: gfQuitWizard is also used to terminate the wizard
  378. // for non-error reasons, but in that case TRUE is returned
  379. // from the OK proc and the case is handled below.
  380. if (gfQuitWizard)
  381. {
  382. // Don't reboot if error occured.
  383. gpWizardState->fNeedReboot = FALSE;
  384. // send a 'cancel' message to ourselves (to keep the prop.
  385. // page mgr happy)
  386. //
  387. // ...Unless we're serving as an Apprentice. In which case, let
  388. // the Wizard decide how to deal with this.
  389. PropSheet_PressButton(GetParent(hDlg),PSBTN_CANCEL);
  390. }
  391. }
  392. }
  393. // 11/25/96 jmazner Normandy #10586 (copied from icwconn1)
  394. // Before we return, lets send another message to ourself so
  395. // we have a second chance of initializing stuff that the
  396. // property sheet wizard doesn't normally let us do.
  397. PostMessage(hDlg, WM_MYINITDIALOG, 1, lParam);
  398. return TRUE;
  399. }
  400. break; // WM_INITDIALOG
  401. // 11/25/96 jmazner Normandy #10586 (copied from icwconn1)
  402. case WM_MYINITDIALOG:
  403. {
  404. PAGEINFO * pPageInfo = (PAGEINFO *) GetWindowLongPtr(hDlg,DWLP_USER);
  405. ASSERT(pPageInfo);
  406. if (pPageInfo->PostInitProc)
  407. {
  408. if (!( pPageInfo->PostInitProc(hDlg, (BOOL)wParam, NULL)))
  409. {
  410. // If a fatal error occured, quit the wizard.
  411. // Note: gfQuitWizard is also used to terminate the wizard
  412. // for non-error reasons, but in that case TRUE is returned
  413. // from the OK proc and the case is handled below.
  414. if (gfQuitWizard)
  415. {
  416. // Don't reboot if error occured.
  417. gpWizardState->fNeedReboot = FALSE;
  418. // send a 'cancel' message to ourselves (to keep the prop.
  419. // page mgr happy)
  420. //
  421. // ...Unless we're serving as an Apprentice. In which case, let
  422. // the Wizard decide how to deal with this.
  423. PropSheet_PressButton(GetParent(hDlg),PSBTN_CANCEL);
  424. }
  425. }
  426. }
  427. // wParam tells whether this is the first initialization or not
  428. MiscInitProc(hDlg, (BOOL)wParam, pPageInfo->uDlgID);
  429. return TRUE;
  430. }
  431. case WM_DESTROY:
  432. ReleaseBold(GetDlgItem(hDlg,IDC_LBLTITLE));
  433. // 12/18/96 jmazner Normandy #12923
  434. // bKilledSysmenu is static, so even if the window is killed and reopened later
  435. // (as happens when user starts in conn1, goes into man path, backs up
  436. // to conn1, and then returns to man path), the value of bKilledSysmenu is preserved.
  437. // So when the window is about to die, set it to FALSE, so that on the next window
  438. // init we go through and kill the sysmenu again.
  439. bKilledSysmenu = FALSE;
  440. break;
  441. #ifdef HAS_HELP
  442. case WM_HELP:
  443. {
  444. DWORD dwData = 1000;
  445. WinHelp(hDlg,"connect.hlp>proc4",HELP_CONTEXT, dwData);
  446. break;
  447. }
  448. #endif
  449. case WM_NOTIFY:
  450. {
  451. BOOL fRet,fKeepHistory=TRUE;
  452. NMHDR * lpnm = (NMHDR *) lParam;
  453. #define NEXTPAGEUNITIALIZED -1
  454. int iNextPage = NEXTPAGEUNITIALIZED;
  455. switch (lpnm->code)
  456. {
  457. case PSN_TRANSLATEACCELERATOR:
  458. {
  459. if (pPageInfo->bIsHostingWebOC)
  460. {
  461. //SUCEEDED macro will not work here cuz ret maybe S_FALSE
  462. if (S_OK == gpWizardState->pICWWebView->HandleKey((LPMSG)((PSHNOTIFY*)lParam)->lParam))
  463. SetWindowLongPtr(hDlg,DWLP_MSGRESULT, PSNRET_MESSAGEHANDLED);
  464. else
  465. SetWindowLongPtr(hDlg,DWLP_MSGRESULT, PSNRET_NOERROR);
  466. }
  467. else if (((IDD_PAGE_END == pPageInfo->uDlgID) ||
  468. (IDD_PAGE_ENDOEMCUSTOM == pPageInfo->uDlgID))
  469. && !g_bAllowCancel)
  470. {
  471. //needed to disable Alt-F4
  472. LPMSG lpMsg = (LPMSG)((PSHNOTIFY*)lParam)->lParam;
  473. if ((WM_SYSKEYDOWN == lpMsg->message) && (lpMsg->wParam == VK_F4))
  474. {
  475. SetWindowLongPtr(hDlg,DWLP_MSGRESULT, PSNRET_MESSAGEHANDLED);
  476. }
  477. }
  478. return TRUE;
  479. }
  480. case PSN_SETACTIVE:
  481. // If a fatal error occured in first call to init proc
  482. // from WM_INITDIALOG, don't call init proc again.
  483. if (FALSE == gfQuitWizard)
  484. {
  485. // For modeless operation, we are suppressing the painting
  486. // of the wizard page background to get the effect of
  487. // transparency, so we need to for an update of the
  488. // app's client area after hiding the current page.
  489. if(gpWizardState->cmnStateData.bOEMCustom)
  490. {
  491. // Set the position of the page that is being activated
  492. SetWindowPos(hDlg, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
  493. // Set the page title
  494. if (pPageInfo->nIdTitle)
  495. {
  496. SendMessage(gpWizardState->cmnStateData.hWndApp, WUM_SETTITLE, (WPARAM)g_hInstance, MAKELONG(pPageInfo->nIdTitle, 0));
  497. }
  498. }
  499. // initialize 'back' and 'next' wizard buttons, if
  500. // page wants something different it can fix in init proc below
  501. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_NEXT | PSWIZB_BACK);
  502. // call init proc for this page if one is specified
  503. if (pPageInfo->InitProc)
  504. {
  505. pPageInfo->InitProc(hDlg,FALSE, (UINT*)&iNextPage);
  506. // See if the init proc want to skip this step
  507. if (NEXTPAGEUNITIALIZED != iNextPage)
  508. {
  509. // Skipping
  510. SetPropSheetResult(hDlg,GetDlgIDFromIndex(iNextPage));
  511. return (iNextPage);
  512. }
  513. }
  514. }
  515. // If we set the wait cursor, set the cursor back
  516. if (hcurOld)
  517. {
  518. SetCursor(hcurOld);
  519. hcurOld = NULL;
  520. }
  521. PostMessage(hDlg, WM_MYINITDIALOG, 0, lParam);
  522. return TRUE;
  523. break;
  524. case PSN_WIZNEXT:
  525. case PSN_WIZBACK:
  526. case PSN_WIZFINISH:
  527. if(lpnm->code == PSN_WIZFINISH)
  528. {
  529. // Set the welcome state
  530. UpdateWelcomeRegSetting(TRUE);
  531. // Restore the desktop
  532. UndoDesktopChanges(g_hInstance);
  533. }
  534. // Change cursor to an hour glass
  535. hcurOld = SetCursor(LoadCursor(NULL, IDC_WAIT));
  536. // call OK proc for this page if one is specified
  537. if (pPageInfo->OKProc)
  538. {
  539. if (!pPageInfo->OKProc(hDlg,(lpnm->code != PSN_WIZBACK), (UINT*)&iNextPage,&fKeepHistory))
  540. {
  541. // If a fatal error occured, quit the wizard.
  542. // Note: gfQuitWizard is also used to terminate the wizard
  543. // for non-error reasons, but in that case TRUE is returned
  544. // from the OK proc and the case is handled below.
  545. if (gfQuitWizard)
  546. {
  547. // Don't reboot if error occured.
  548. gpWizardState->fNeedReboot = FALSE;
  549. // send a 'cancel' message to ourselves (to keep the prop.
  550. // page mgr happy)
  551. //
  552. // ...Unless we're serving as an Apprentice. In which case, let
  553. // the Wizard decide how to deal with this.
  554. PropSheet_PressButton(GetParent(hDlg),PSBTN_CANCEL);
  555. }
  556. // stay on this page
  557. SetPropSheetResult(hDlg,-1);
  558. return TRUE;
  559. }
  560. }
  561. if (lpnm->code != PSN_WIZBACK)
  562. {
  563. // 'next' pressed
  564. ASSERT(gpWizardState->uPagesCompleted < EXE_NUM_WIZARD_PAGES);
  565. // save the current page index in the page history,
  566. // unless this page told us not to when we called
  567. // its OK proc above
  568. if (fKeepHistory)
  569. {
  570. gpWizardState->uPageHistory[gpWizardState->uPagesCompleted] = gpWizardState->uCurrentPage;
  571. TraceMsg(TF_GENDLG, TEXT("GENDLG: added page %d (IDD %d) to history list"),
  572. gpWizardState->uCurrentPage, GetDlgIDFromIndex(gpWizardState->uCurrentPage));
  573. gpWizardState->uPagesCompleted++;
  574. }
  575. else
  576. {
  577. TraceMsg(TF_GENDLG, TEXT("GENDLG: not adding %d (IDD: %d) to the history list"),
  578. gpWizardState->uCurrentPage, GetDlgIDFromIndex(gpWizardState->uCurrentPage));
  579. }
  580. // if no next page specified or no OK proc,
  581. // advance page by one
  582. if (0 > iNextPage)
  583. iNextPage = gpWizardState->uCurrentPage + 1;
  584. }
  585. else
  586. {
  587. // 'back' pressed
  588. // switch( gpWizardState->uCurrentPage )
  589. // {
  590. // }
  591. if( NEXTPAGEUNITIALIZED == iNextPage )
  592. {
  593. if (gpWizardState->uPagesCompleted > 0)
  594. {
  595. // get the last page from the history list
  596. gpWizardState->uPagesCompleted --;
  597. iNextPage = gpWizardState->uPageHistory[gpWizardState->uPagesCompleted];
  598. TraceMsg(TF_GENDLG, TEXT("GENDLG: extracting page %d (IDD %d) from history list"),iNextPage, GetDlgIDFromIndex(iNextPage));
  599. }
  600. else
  601. {
  602. ASSERT(0);
  603. // This is bad, the history list position pointer indicates that
  604. // there are no pages in the history, so we should probably
  605. // just stay right were we are.
  606. iNextPage = gpWizardState->uCurrentPage;
  607. }
  608. }
  609. #if 0 // We shouldn't be depend on this piece of code, as we should always use History.
  610. else
  611. {
  612. // The OK proc has specified a specific page to goto so lets see if it
  613. // is in the history stack, otherwise we we want to back the stack up
  614. // anyways
  615. while (gpWizardState->uPagesCompleted > 0)
  616. {
  617. --gpWizardState->uPagesCompleted;
  618. if (iNextPage == (int)gpWizardState->uPageHistory[gpWizardState->uPagesCompleted])
  619. break;
  620. }
  621. }
  622. #endif
  623. }
  624. // if we need to exit the wizard now (e.g. launching
  625. // signup app and want to terminate the wizard), send
  626. // a 'cancel' message to ourselves (to keep the prop.
  627. // page mgr happy)
  628. if (gfQuitWizard)
  629. {
  630. //
  631. // if we are going from manual to conn1 then
  632. // then do not show the REBOOT dialog but
  633. // still preserve the gpWizardState -MKarki Bug #404
  634. //
  635. if (lpnm->code == PSN_WIZBACK)
  636. {
  637. gfBackedUp = TRUE;
  638. gfReboot = gpWizardState->fNeedReboot;
  639. }
  640. // send a 'cancel' message to ourselves (to keep the prop.
  641. // page mgr happy)
  642. //
  643. // ...Unless we're serving as an Apprentice. In which case, let
  644. // the Wizard decide how to deal with this.
  645. PropSheet_PressButton(GetParent(hDlg),PSBTN_CANCEL);
  646. SetPropSheetResult(hDlg,-1);
  647. return TRUE;
  648. }
  649. // set next page, only if 'next' or 'back' button
  650. // was pressed
  651. if (lpnm->code != PSN_WIZFINISH)
  652. {
  653. // set the next current page index
  654. gpWizardState->uCurrentPage = iNextPage;
  655. TraceMsg(TF_GENDLG, TEXT("GENDLG: going to page %d (IDD %d)"), iNextPage, GetDlgIDFromIndex(iNextPage));
  656. // tell the prop sheet mgr what the next page to
  657. // display is
  658. SetPropSheetResult(hDlg,GetDlgIDFromIndex(iNextPage));
  659. return TRUE;
  660. }
  661. break;
  662. case PSN_QUERYCANCEL:
  663. {
  664. // if global flag to exit is set, then this cancel
  665. // is us pretending to push 'cancel' so prop page mgr
  666. // will kill the wizard. Let this through...
  667. if (gfQuitWizard)
  668. {
  669. SetWindowLongPtr(hDlg,DWLP_MSGRESULT,FALSE);
  670. return TRUE;
  671. }
  672. #ifndef ICWDEBUG
  673. //Dialing is a super special case cuz we wanna skip all the UI and
  674. //go striaght to a dialing error page
  675. if (gpWizardState->uCurrentPage == ORD_PAGE_REFSERVDIAL)
  676. {
  677. // if this page has a special cancel proc, call it
  678. if (pPageInfo->CancelProc)
  679. SetWindowLongPtr(hDlg,DWLP_MSGRESULT,pPageInfo->CancelProc(hDlg));
  680. }
  681. else
  682. {
  683. #endif //ICWDEBUG
  684. // default behavior: pop up a message box confirming
  685. // the cancel...
  686. // ... unless we're serving as an Apprentice, in which case
  687. // we should let the Wizard handle things
  688. // Display a dialog and allow the user to select modem
  689. #ifndef ICWDEBUG
  690. if ((gpWizardState->uCurrentPage == ORD_PAGE_INTRO) && !GetCompletedBit())
  691. {
  692. fRet=(BOOL)DialogBoxParam(g_hInstance,MAKEINTRESOURCE(IDD_QUIT),hDlg, CancelCmdProc,0);
  693. }
  694. else
  695. #endif //ICWDEBUG
  696. fRet = (MsgBox(hDlg,IDS_QUERYCANCEL,
  697. MB_ICONQUESTION,MB_YESNO |
  698. MB_DEFBUTTON2) == IDYES);
  699. gfUserCancelled = fRet;
  700. if(gfUserCancelled)
  701. {
  702. // if this page has a special cancel proc, call it
  703. if (pPageInfo->CancelProc)
  704. fRet = pPageInfo->CancelProc(hDlg);
  705. if (gpWizardState->pTapiLocationInfo && (gpWizardState->lLocationID != gpWizardState->lDefaultLocationID))
  706. {
  707. gpWizardState->pTapiLocationInfo->put_LocationId(gpWizardState->lDefaultLocationID);
  708. }
  709. }
  710. // don't reboot if cancelling
  711. gpWizardState->fNeedReboot = FALSE;
  712. // return the value thru window data
  713. SetWindowLongPtr(hDlg,DWLP_MSGRESULT,!fRet);
  714. #ifndef ICWDEBUG
  715. }
  716. #endif //ICWDEBUG
  717. return TRUE;
  718. break;
  719. }
  720. default:
  721. {
  722. // See if the page has a notify proc
  723. if (pPageInfo->NotifyProc)
  724. {
  725. pPageInfo->NotifyProc(hDlg,wParam,lParam);
  726. }
  727. break;
  728. }
  729. }
  730. break;
  731. }
  732. case WM_COMMAND:
  733. {
  734. // if this page has a command handler proc, call it
  735. if (pPageInfo->CmdProc)
  736. {
  737. pPageInfo->CmdProc(hDlg, wParam, lParam);
  738. }
  739. }
  740. }
  741. return FALSE;
  742. }