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.

2086 lines
60 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: I S D N S H T S . C P P
  7. //
  8. // Contents: Dialog procs for the ISDN Property sheets and wizard pages
  9. //
  10. // Notes:
  11. //
  12. // Author: danielwe 9 Mar 1998
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include <ncxbase.h>
  18. #include <ncui.h>
  19. #include "ncreg.h"
  20. #include "isdncfg.h"
  21. #include "isdnshts.h"
  22. #include "resource.h"
  23. #include "ncmisc.h"
  24. #ifndef IDD_NetDevSelect
  25. #define IDD_NetDevSelect 21013
  26. #endif
  27. //---[ Constants ]------------------------------------------------------------
  28. const DWORD c_iMaxChannelName = 3; // For the channel listbox
  29. struct SWITCH_TYPE_MASK_INFO
  30. {
  31. DWORD dwMask;
  32. UINT idsSwitchType;
  33. };
  34. //
  35. // Switch type masks.
  36. //
  37. // Maps the switch type to a description string.
  38. //
  39. static const SWITCH_TYPE_MASK_INFO c_astmi[] =
  40. {
  41. {ISDN_SWITCH_AUTO, IDS_ISDN_SWITCH_AUTO},
  42. {ISDN_SWITCH_ATT, IDS_ISDN_SWITCH_ATT},
  43. {ISDN_SWITCH_NI1, IDS_ISDN_SWITCH_NI1},
  44. {ISDN_SWITCH_NI2, IDS_ISDN_SWITCH_NI2},
  45. {ISDN_SWITCH_NTI, IDS_ISDN_SWITCH_NTI},
  46. {ISDN_SWITCH_INS64, IDS_ISDN_SWITCH_INS64},
  47. {ISDN_SWITCH_1TR6, IDS_ISDN_SWITCH_1TR6},
  48. {ISDN_SWITCH_VN3, IDS_ISDN_SWITCH_VN3},
  49. // {ISDN_SWITCH_NET3, IDS_ISDN_SWITCH_DSS1},
  50. {ISDN_SWITCH_DSS1, IDS_ISDN_SWITCH_DSS1},
  51. {ISDN_SWITCH_AUS, IDS_ISDN_SWITCH_AUS},
  52. {ISDN_SWITCH_BEL, IDS_ISDN_SWITCH_BEL},
  53. {ISDN_SWITCH_VN4, IDS_ISDN_SWITCH_VN4},
  54. {ISDN_SWITCH_SWE, IDS_ISDN_SWITCH_SWE},
  55. {ISDN_SWITCH_TWN, IDS_ISDN_SWITCH_TWN},
  56. {ISDN_SWITCH_ITA, IDS_ISDN_SWITCH_ITA},
  57. };
  58. static const INT c_cstmi = celems(c_astmi);
  59. static const WCHAR c_szIsdnShowPages[] = L"ShowIsdnPages";
  60. //+---------------------------------------------------------------------------
  61. //
  62. // Function: FShowIsdnPages
  63. //
  64. // Purpose: Determines whether the ISDN wizard property page or wizard
  65. // pages should be shown.
  66. //
  67. // Arguments:
  68. // hkey [in] Driver instance key for ISDN device
  69. //
  70. // Returns: If the ShowIsdnPages value is:
  71. //
  72. // not present: TRUE, if adapter has ISDN in lower
  73. // range
  74. // present and zero: FALSE
  75. // present and non-zero: TRUE, unconditionally
  76. //
  77. // Author: danielwe 15 Dec 1998
  78. //
  79. // Notes:
  80. //
  81. BOOL FShowIsdnPages(HKEY hkey)
  82. {
  83. DWORD dwValue;
  84. if (SUCCEEDED(HrRegQueryDword(hkey, c_szIsdnShowPages, &dwValue)))
  85. {
  86. if (!dwValue)
  87. {
  88. return FALSE;
  89. }
  90. else
  91. {
  92. return TRUE;
  93. }
  94. }
  95. else
  96. {
  97. return FAdapterIsIsdn(hkey);
  98. }
  99. }
  100. //
  101. // Switch Type page functions
  102. //
  103. //+---------------------------------------------------------------------------
  104. //
  105. // Function: OnIsdnSwitchTypeInit
  106. //
  107. // Purpose: Called when the switch type page is initialized
  108. //
  109. // Arguments:
  110. // hwndDlg [in] Handle to dialog
  111. // pisdnci [in] Configuration information as read from the
  112. // registry
  113. //
  114. // Returns: Nothing
  115. //
  116. // Author: danielwe 11 Mar 1998
  117. //
  118. // Notes:
  119. //
  120. VOID OnIsdnSwitchTypeInit(HWND hwndDlg, PISDN_CONFIG_INFO pisdnci)
  121. {
  122. // Populate the switch types from the multi-sz that we read
  123. //
  124. PopulateIsdnSwitchTypes(hwndDlg, IDC_CMB_SwitchType, pisdnci);
  125. pisdnci->nOldDChannel = SendDlgItemMessage(hwndDlg, IDC_LBX_Line,
  126. LB_GETCURSEL, 0, 0);
  127. pisdnci->nOldBChannel = SendDlgItemMessage(hwndDlg, IDC_LBX_Variant,
  128. LB_GETCURSEL, 0, 0);
  129. }
  130. //+---------------------------------------------------------------------------
  131. //
  132. // Function: CheckShowPagesFlag
  133. //
  134. // Purpose: Checks a special registry flag to see if a vendor wishes to
  135. // suppress the ISDN wizard from appearing upon installation of
  136. // their device.
  137. //
  138. // Arguments:
  139. // pisdnci [in] Configuration information as read from the
  140. // registry
  141. //
  142. // Returns: Nothing
  143. //
  144. // Author: danielwe 15 Dec 1998
  145. //
  146. // Notes:
  147. //
  148. VOID CheckShowPagesFlag(PISDN_CONFIG_INFO pisdnci)
  149. {
  150. // Open the adapter's driver key
  151. //
  152. HKEY hkeyInstance = NULL;
  153. HRESULT hr = S_OK;
  154. hr = HrSetupDiOpenDevRegKey(pisdnci->hdi, pisdnci->pdeid,
  155. DICS_FLAG_GLOBAL, 0, DIREG_DRV,
  156. KEY_READ, &hkeyInstance);
  157. if (SUCCEEDED(hr))
  158. {
  159. if (!FShowIsdnPages(hkeyInstance))
  160. {
  161. TraceTag(ttidISDNCfg, "Skipping all ISDN wizard pages because"
  162. "the %S value was present and zero", c_szIsdnShowPages);
  163. pisdnci->fSkipToEnd = TRUE;
  164. }
  165. else
  166. {
  167. TraceTag(ttidISDNCfg, "Showing all ISDN wizard pages...");
  168. }
  169. RegCloseKey(hkeyInstance);
  170. }
  171. }
  172. //+---------------------------------------------------------------------------
  173. //
  174. // Function: OnIsdnSwitchTypeSetActive
  175. //
  176. // Purpose: Called when the switch type page is made active.
  177. //
  178. // Arguments:
  179. // hwndDlg [in] Handle to dialog
  180. // pisdnci [in] Configuration information as read from the
  181. // registry
  182. //
  183. // Returns: DWL_MSGRESULT
  184. //
  185. // Author: danielwe 11 Mar 1998
  186. //
  187. // Notes:
  188. //
  189. LONG OnIsdnSwitchTypeSetActive(HWND hwndDlg, PISDN_CONFIG_INFO pisdnci)
  190. {
  191. // For bug #265745: Some vendors will want to suppress the ISDN wizard
  192. // in the case where their card is multifunction. The coinstaller for that
  193. // device will ask the user if they want the card configured for ISDN and
  194. // if they say 'no' then we shouldn't show the ISDN wizard. The following
  195. // function checks the registry to see if the user essentially chose 'no'.
  196. CheckShowPagesFlag(pisdnci);
  197. if (pisdnci->fSkipToEnd)
  198. {
  199. return -1;
  200. }
  201. else
  202. {
  203. // Set the button states.
  204. //
  205. SetWizardButtons(GetParent(hwndDlg),TRUE, pisdnci);
  206. }
  207. return 0;
  208. }
  209. //+---------------------------------------------------------------------------
  210. //
  211. // Function: SetWizardButtons
  212. //
  213. // Purpose: Sets the next, back and cancel buttons depending what property
  214. // page we are in and if we are in GUI mode setup or stand-alone mode.
  215. //
  216. // Arguments:
  217. // hwndDlg [in] Handle to property page
  218. // bFirstPage [in] Indicates if the property page is the first page.
  219. // If it is the first page and we are in stand-alone
  220. // the back button is disabled
  221. //
  222. // Returns: void
  223. //
  224. // Author: omiller 15 May 2000
  225. //
  226. // Notes: Next and Back are enabled in GUI setup mode. The cancel button
  227. // is not displayed in GUI setup mode.
  228. // In stand-alone mode the next button and cancel button are enabled.
  229. //
  230. VOID SetWizardButtons(HWND hwndDlg, BOOLEAN bFirstPage, PISDN_CONFIG_INFO pisdnci)
  231. {
  232. // Determine if we are in GUI mode setup or running stand-alone
  233. //
  234. if( FInSystemSetup() )
  235. {
  236. // We are GUI Setup mode. There is a property page before us and after us.
  237. // Therefore we have to enable the next and/or back buttons. There is no
  238. // cancel button for this property page in GUI setup mode.
  239. //
  240. DWORD dwFlags = PSWIZB_BACK | PSWIZB_NEXT;
  241. int iIndex;
  242. HWND hwndFirstPage;
  243. if ( pisdnci )
  244. {
  245. iIndex = PropSheet_IdToIndex( hwndDlg, IDD_NetDevSelect );
  246. if ( iIndex != -1 )
  247. {
  248. hwndFirstPage = PropSheet_IndexToHwnd( hwndDlg, iIndex );
  249. if ( hwndFirstPage )
  250. {
  251. if (SendMessage(hwndFirstPage, WM_SELECTED_ALL, (WPARAM)0,
  252. (LPARAM)pisdnci->pdeid->DevInst) )
  253. {
  254. dwFlags = PSWIZB_NEXT;
  255. }
  256. }
  257. }
  258. }
  259. PropSheet_SetWizButtons(hwndDlg, dwFlags);
  260. }
  261. else
  262. {
  263. // We are running in stand-alone mode. This means that we are the first property
  264. // sheet. Therefore the back button should be disabled, the next button enabled.
  265. // and the cancel button should be enabled. The cancel button does not appear in
  266. // GUI setup mode.
  267. //
  268. HWND hCancel;
  269. // Get the handle to the cancel button and enable the button.
  270. //
  271. hCancel=GetDlgItem(hwndDlg,IDCANCEL);
  272. EnableWindow(hCancel,TRUE);
  273. if( bFirstPage )
  274. {
  275. // Enable the next button.
  276. PropSheet_SetWizButtons(hwndDlg,PSWIZB_NEXT);
  277. }
  278. else
  279. {
  280. // Enable the next button.
  281. PropSheet_SetWizButtons(hwndDlg,PSWIZB_BACK | PSWIZB_NEXT);
  282. }
  283. }
  284. }
  285. //+---------------------------------------------------------------------------
  286. //
  287. // Function: DwGetSwitchType
  288. //
  289. // Purpose: Takes the selected switch type in the dropdown list and
  290. // returns the actual value that will be stored in the registry.
  291. //
  292. // Arguments:
  293. // hwndDlg [in] HWND of dialog
  294. // pisdnci [in] Configuration information as read from the
  295. // registry
  296. // iDialogItem [in] Item ID of switch type dropdown list
  297. //
  298. // Returns:
  299. //
  300. // Author: danielwe 23 Apr 1998
  301. //
  302. // Notes:
  303. //
  304. DWORD DwGetSwitchType(HWND hwndDlg, PISDN_CONFIG_INFO pisdnci,
  305. INT iDialogItem)
  306. {
  307. INT iCurSel;
  308. INT iSwitchType;
  309. iCurSel = SendDlgItemMessage(hwndDlg, iDialogItem, CB_GETCURSEL, 0, 0);
  310. // Switch type index should be the item data for the selected switch
  311. // type
  312. iSwitchType = SendDlgItemMessage(hwndDlg, iDialogItem, CB_GETITEMDATA,
  313. iCurSel, 0);
  314. AssertSz(iSwitchType >= 0 && iSwitchType < c_cstmi, "Switch type item data"
  315. " is bad!");
  316. return c_astmi[iSwitchType].dwMask;
  317. }
  318. //+---------------------------------------------------------------------------
  319. //
  320. // Function: OnIsdnSwitchTypeWizNext
  321. //
  322. // Purpose: Called when the switch type page is advanced in the forward
  323. // direction.
  324. //
  325. // Arguments:
  326. // hwndDlg [in] Handle to dialog
  327. // pisdnci [in] Configuration information as read from the
  328. // registry
  329. //
  330. // Returns: Nothing.
  331. //
  332. // Author: danielwe 11 Mar 1998
  333. //
  334. // Notes:
  335. //
  336. VOID OnIsdnSwitchTypeWizNext(HWND hwndDlg, PISDN_CONFIG_INFO pisdnci)
  337. {
  338. INT idd = 0;
  339. pisdnci->dwCurSwitchType = DwGetSwitchType(hwndDlg, pisdnci,
  340. IDC_CMB_SwitchType);
  341. switch (pisdnci->dwCurSwitchType)
  342. {
  343. case ISDN_SWITCH_ATT:
  344. case ISDN_SWITCH_NI1:
  345. case ISDN_SWITCH_NI2:
  346. case ISDN_SWITCH_NTI:
  347. if (pisdnci->fIsPri)
  348. {
  349. // PRI adapters use the EAZ page instead
  350. idd = IDW_ISDN_EAZ;
  351. }
  352. else
  353. {
  354. idd = IDW_ISDN_SPIDS;
  355. }
  356. break;
  357. case ISDN_SWITCH_INS64:
  358. idd = IDW_ISDN_JAPAN;
  359. break;
  360. case ISDN_SWITCH_AUTO:
  361. case ISDN_SWITCH_1TR6:
  362. idd = IDW_ISDN_EAZ;
  363. break;
  364. case ISDN_SWITCH_VN3:
  365. case ISDN_SWITCH_VN4:
  366. case ISDN_SWITCH_DSS1:
  367. case ISDN_SWITCH_AUS:
  368. case ISDN_SWITCH_BEL:
  369. case ISDN_SWITCH_SWE:
  370. case ISDN_SWITCH_TWN:
  371. case ISDN_SWITCH_ITA:
  372. idd = IDW_ISDN_MSN;
  373. break;
  374. default:
  375. AssertSz(FALSE, "Where do we go from here.. now that all of our "
  376. "children are growin' up?");
  377. break;
  378. }
  379. // Save away the dialog we used so we can make decisions later on about
  380. // what to call things, etc...
  381. //
  382. pisdnci->idd = idd;
  383. }
  384. //+---------------------------------------------------------------------------
  385. //
  386. // Function: IsdnSwitchTypeProc
  387. //
  388. // Purpose: Dialog proc handler for switch type page.
  389. //
  390. // Arguments:
  391. // hwndDlg []
  392. // uMessage []
  393. // wparam []
  394. // lparam []
  395. //
  396. // Returns:
  397. //
  398. // Author: danielwe 11 Mar 1998
  399. //
  400. // Notes:
  401. //
  402. INT_PTR
  403. CALLBACK
  404. IsdnSwitchTypeProc(HWND hwndDlg, UINT uMessage,
  405. WPARAM wparam, LPARAM lparam)
  406. {
  407. LPNMHDR lpnmhdr = NULL;
  408. PISDN_CONFIG_INFO pisdnci;
  409. PROPSHEETPAGE * ppsp;
  410. pisdnci = (PISDN_CONFIG_INFO)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
  411. switch (uMessage)
  412. {
  413. case WM_INITDIALOG:
  414. PAGE_DATA * pPageData;
  415. ppsp = (PROPSHEETPAGE *) lparam;
  416. // Set the per-page data for this particular page. See the
  417. // comments above about why we use the per-page data.
  418. //
  419. AssertSz(!pisdnci, "This should not have been set yet");
  420. pPageData = (PAGE_DATA *)ppsp->lParam;
  421. pisdnci = pPageData->pisdnci;
  422. // Set this data in the window long for user-data
  423. //
  424. SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) pisdnci);
  425. // Call the init handler function
  426. //
  427. OnIsdnSwitchTypeInit(hwndDlg, pisdnci);
  428. break;
  429. case WM_NOTIFY:
  430. lpnmhdr = (NMHDR FAR *)lparam;
  431. // Handle all of the notification messages
  432. //
  433. switch (lpnmhdr->code)
  434. {
  435. case PSN_SETACTIVE:
  436. {
  437. LONG l = OnIsdnSwitchTypeSetActive(hwndDlg, pisdnci);
  438. SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, l);
  439. return TRUE;
  440. }
  441. case PSN_APPLY:
  442. break;
  443. case PSN_WIZBACK:
  444. break;
  445. case PSN_WIZNEXT:
  446. OnIsdnSwitchTypeWizNext(hwndDlg, pisdnci);
  447. break;
  448. case PSN_WIZFINISH:
  449. AssertSz(FALSE, "You can't finish from this page!");
  450. break;
  451. default:
  452. break;
  453. }
  454. break;
  455. default:
  456. break;
  457. }
  458. return FALSE;
  459. }
  460. //+---------------------------------------------------------------------------
  461. //
  462. // Function: PopulateIsdnSwitchTypes
  463. //
  464. // Purpose: Fills in the drop-down list for the switch type page
  465. //
  466. // Arguments:
  467. // hwndDlg [in] Handle to page
  468. // iDialogItem [in] Item ID of drop-down list
  469. // pisdnci [in] Configuration information as read from the
  470. // registry
  471. //
  472. // Returns: Nothing.
  473. //
  474. // Author: danielwe 11 Mar 1998
  475. //
  476. // Notes:
  477. //
  478. VOID PopulateIsdnSwitchTypes(HWND hwndDlg, INT iDialogItem,
  479. PISDN_CONFIG_INFO pisdnci)
  480. {
  481. INT iCurrentIndex = 0;
  482. INT iSetItemData = 0;
  483. DWORD dwSwitchType = 0;
  484. DWORD nCountry;
  485. INT istmi;
  486. Assert(hwndDlg);
  487. Assert(pisdnci);
  488. Assert(pisdnci->dwSwitchTypes);
  489. nCountry = DwGetCurrentCountryCode();
  490. // Loop through the list of switch types and add them to the combo box
  491. //
  492. for (istmi = 0; istmi < c_cstmi; istmi++)
  493. {
  494. if (pisdnci->dwSwitchTypes & c_astmi[istmi].dwMask)
  495. {
  496. // Add the string
  497. //
  498. iCurrentIndex = SendDlgItemMessage(hwndDlg, iDialogItem,
  499. CB_ADDSTRING,
  500. 0, (LPARAM) SzLoadIds(c_astmi[istmi].idsSwitchType));
  501. Assert(iCurrentIndex != CB_ERR);
  502. // Set the item data, so we know the index into the switch type
  503. // array that we're dealing with.
  504. //
  505. iSetItemData = SendDlgItemMessage(hwndDlg, iDialogItem,
  506. CB_SETITEMDATA, iCurrentIndex,
  507. istmi);
  508. if (FIsDefaultForLocale(nCountry, c_astmi[istmi].dwMask))
  509. {
  510. // Save index to find default item to select later
  511. dwSwitchType = c_astmi[istmi].dwMask;
  512. }
  513. else if (!dwSwitchType)
  514. {
  515. // If no default has been set, set one now.
  516. dwSwitchType = c_astmi[istmi].dwMask;
  517. }
  518. Assert(iSetItemData != CB_ERR);
  519. }
  520. }
  521. SetSwitchType(hwndDlg, IDC_CMB_SwitchType, dwSwitchType);
  522. }
  523. //+---------------------------------------------------------------------------
  524. //
  525. // Function: SetSwitchType
  526. //
  527. // Purpose: Given a switch type mask, selects the item in the combo box
  528. // that corresponds to that switch type.
  529. //
  530. // Arguments:
  531. // hwndDlg [in] Dialog handle.
  532. // iItemSwitchType [in] Item ID of switch type combo box.
  533. // dwSwitchType [in] Switch type mask to select.
  534. //
  535. // Returns: Nothin'
  536. //
  537. // Author: danielwe 11 Mar 1998
  538. //
  539. // Notes:
  540. //
  541. VOID SetSwitchType(HWND hwndDlg, INT iItemSwitchType, DWORD dwSwitchType)
  542. {
  543. INT iItem;
  544. INT cItems;
  545. cItems = SendDlgItemMessage(hwndDlg, iItemSwitchType, CB_GETCOUNT, 0, 0);
  546. for (iItem = 0; iItem < cItems; iItem++)
  547. {
  548. INT istmiCur;
  549. istmiCur = SendDlgItemMessage(hwndDlg, iItemSwitchType,
  550. CB_GETITEMDATA, iItem, 0);
  551. if (c_astmi[istmiCur].dwMask == dwSwitchType)
  552. {
  553. // Select switch type
  554. //
  555. SendDlgItemMessage(hwndDlg, iItemSwitchType, CB_SETCURSEL,
  556. iItem, 0);
  557. break;
  558. }
  559. }
  560. }
  561. //
  562. // Info page functions
  563. //
  564. //+---------------------------------------------------------------------------
  565. //
  566. // Function: OnIsdnInfoPageInit
  567. //
  568. // Purpose: Called when the info (second) page of the wizard is
  569. // initialized.
  570. //
  571. // Arguments:
  572. // hwndDlg [in] Handle to dialog
  573. // pisdnci [in] Configuration information as read from the
  574. // registry
  575. //
  576. // Returns: Nothing.
  577. //
  578. // Author: danielwe 11 Mar 1998
  579. //
  580. // Notes:
  581. //
  582. VOID OnIsdnInfoPageInit(HWND hwndDlg, PISDN_CONFIG_INFO pisdnci)
  583. {
  584. // Populate the channels from the array of B-Channels stored in our
  585. // config info for the first D-Channel
  586. //
  587. PopulateIsdnChannels(hwndDlg, IDC_EDT_SPID, IDC_EDT_PhoneNumber,
  588. IDC_LBX_Line, IDC_LBX_Variant, pisdnci);
  589. SetFocus(GetDlgItem(hwndDlg, IDC_EDT_PhoneNumber));
  590. }
  591. //+---------------------------------------------------------------------------
  592. //
  593. // Function: OnIsdnInfoPageSetActive
  594. //
  595. // Purpose: Called when the second page of the wizard is activated
  596. //
  597. // Arguments:
  598. // hwndDlg [in] Handle to dialog
  599. // pisdnci [in] Configuration information as read from the
  600. // registry
  601. //
  602. // Returns: Nothing
  603. //
  604. // Author: danielwe 11 Mar 1998
  605. //
  606. // Notes:
  607. //
  608. LONG OnIsdnInfoPageSetActive(HWND hwndDlg, PISDN_CONFIG_INFO pisdnci)
  609. {
  610. if (pisdnci->idd == (UINT)GetWindowLongPtr(hwndDlg, DWLP_USER) &&
  611. !pisdnci->fSkipToEnd)
  612. {
  613. // Set the button states.
  614. //
  615. SetWizardButtons(GetParent(hwndDlg),FALSE, NULL);
  616. SetFocus(GetDlgItem(hwndDlg, IDC_EDT_PhoneNumber));
  617. // Note the current selections
  618. //
  619. pisdnci->nOldBChannel = SendDlgItemMessage(hwndDlg, IDC_LBX_Variant,
  620. LB_GETCURSEL, 0, 0);
  621. pisdnci->nOldDChannel = SendDlgItemMessage(hwndDlg, IDC_LBX_Line,
  622. LB_GETCURSEL, 0, 0);
  623. }
  624. else
  625. {
  626. return -1;
  627. }
  628. return 0;
  629. }
  630. //+---------------------------------------------------------------------------
  631. //
  632. // Function: OnIsdnInfoPageApply
  633. //
  634. // Purpose: Called when the info (second) page is applied
  635. //
  636. // Arguments:
  637. // hwndDlg [in] Handle to dialog
  638. // pisdnci [in] Configuration information as read from the
  639. // registry
  640. //
  641. // Returns: Nothing
  642. //
  643. // Author: danielwe 11 Mar 1998
  644. //
  645. // Notes:
  646. //
  647. VOID OnIsdnInfoPageApply(HWND hwndDlg, PISDN_CONFIG_INFO pisdnci)
  648. {
  649. // Open the adapter's driver key and store the info
  650. //
  651. HRESULT hr;
  652. HKEY hkey;
  653. hr = HrSetupDiOpenDevRegKey(pisdnci->hdi, pisdnci->pdeid, DICS_FLAG_GLOBAL,
  654. 0, DIREG_DRV, KEY_ALL_ACCESS, &hkey);
  655. if (SUCCEEDED(hr))
  656. {
  657. // Write the parameters back out into the registry.
  658. //
  659. hr = HrWriteIsdnPropertiesInfo(hkey, pisdnci);
  660. if (SUCCEEDED(hr))
  661. {
  662. hr = HrSetupDiSendPropertyChangeNotification(pisdnci->hdi,
  663. pisdnci->pdeid,
  664. DICS_PROPCHANGE,
  665. DICS_FLAG_GLOBAL,
  666. 0);
  667. }
  668. RegCloseKey(hkey);
  669. }
  670. }
  671. //+---------------------------------------------------------------------------
  672. //
  673. // Function: OnIsdnInfoPageWizNext
  674. //
  675. // Purpose: Called when the info (second) page is advanced in the
  676. // forward direction.
  677. //
  678. // Arguments:
  679. // hwndDlg [in] Handle to dialog
  680. // pisdnci [in] Configuration information as read from the
  681. // registry
  682. //
  683. // Returns: Nothing
  684. //
  685. // Author: danielwe 11 Mar 1998
  686. //
  687. // Notes:
  688. //
  689. VOID OnIsdnInfoPageWizNext(HWND hwndDlg, PISDN_CONFIG_INFO pisdnci)
  690. {
  691. if (pisdnci->idd == (UINT)GetWindowLongPtr(hwndDlg, DWLP_USER))
  692. {
  693. OnIsdnInfoPageTransition(hwndDlg, pisdnci);
  694. OnIsdnInfoPageApply(hwndDlg, pisdnci);
  695. }
  696. }
  697. //+---------------------------------------------------------------------------
  698. //
  699. // Function: OnIsdnInfoPageTransition
  700. //
  701. // Purpose: Called when the info (second) page is advanced in either the
  702. // forward or backward directions.
  703. //
  704. // Arguments:
  705. // hwndDlg [in] Handle to dialog
  706. // pisdnci [in] Configuration information as read from the
  707. // registry
  708. //
  709. // Returns: Nothing
  710. //
  711. // Author: danielwe 5 May 1998
  712. //
  713. // Notes:
  714. //
  715. VOID OnIsdnInfoPageTransition(HWND hwndDlg, PISDN_CONFIG_INFO pisdnci)
  716. {
  717. Assert(hwndDlg);
  718. if (pisdnci->idd == IDW_ISDN_MSN)
  719. {
  720. INT iCurSel;
  721. iCurSel = SendDlgItemMessage(hwndDlg, IDC_LBX_Line, LB_GETCURSEL, 0, 0);
  722. if (iCurSel != LB_ERR)
  723. {
  724. GetDataFromListBox(iCurSel, hwndDlg, pisdnci);
  725. }
  726. }
  727. else
  728. {
  729. DWORD dwDChannel;
  730. DWORD dwBChannel;
  731. Assert(pisdnci);
  732. Assert(pisdnci->pDChannel);
  733. dwDChannel = SendDlgItemMessage(hwndDlg, IDC_LBX_Line,
  734. LB_GETCURSEL, 0, 0);
  735. Assert(pisdnci->dwNumDChannels >= dwDChannel);
  736. dwBChannel = SendDlgItemMessage(hwndDlg, IDC_LBX_Variant,
  737. LB_GETCURSEL, 0, 0);
  738. // Update the channel info for the currently selected channel from
  739. // the SPID/Phone Number edit controls
  740. //
  741. SetModifiedIsdnChannelInfo(hwndDlg, IDC_EDT_SPID, IDC_EDT_PhoneNumber,
  742. IDC_LBX_Variant, dwBChannel, pisdnci);
  743. // Retrieve all of the ISDN B-Channel info from the listbox item-data,
  744. // and update the config info.
  745. //
  746. RetrieveIsdnChannelInfo(hwndDlg, IDC_EDT_SPID, IDC_EDT_PhoneNumber,
  747. IDC_LBX_Variant, pisdnci, dwDChannel,
  748. dwBChannel);
  749. }
  750. }
  751. //+---------------------------------------------------------------------------
  752. //
  753. // Function: OnIsdnInfoPageWizBack
  754. //
  755. // Purpose: Called when the info (second) page is advanced in the reverse
  756. // direction.
  757. //
  758. // Arguments:
  759. // hwndDlg [in] Handle to dialog
  760. // pisdnci [in] Configuration information as read from the
  761. // registry
  762. //
  763. // Returns: Nothing
  764. //
  765. // Author: danielwe 11 Mar 1998
  766. //
  767. // Notes:
  768. //
  769. VOID OnIsdnInfoPageWizBack(HWND hwndDlg, PISDN_CONFIG_INFO pisdnci)
  770. {
  771. OnIsdnInfoPageTransition(hwndDlg, pisdnci);
  772. }
  773. //+---------------------------------------------------------------------------
  774. //
  775. // Function: OnIsdnInfoPageSelChange
  776. //
  777. // Purpose: Called when the selection changes in either the D-channel or
  778. // B-channel listboxes.
  779. //
  780. // Arguments:
  781. // hwndDlg [in] Handle to dialog
  782. // pisdnci [in] Configuration information as read from the
  783. // registry
  784. //
  785. // Returns: Nothing.
  786. //
  787. // Author: danielwe 11 Mar 1998
  788. //
  789. // Notes:
  790. //
  791. VOID OnIsdnInfoPageSelChange(HWND hwndDlg, PISDN_CONFIG_INFO pisdnci)
  792. {
  793. INT nDChannel;
  794. INT nBChannel;
  795. Assert(hwndDlg);
  796. Assert(pisdnci);
  797. Assert(pisdnci->pDChannel);
  798. nDChannel = SendDlgItemMessage(hwndDlg, IDC_LBX_Line,
  799. LB_GETCURSEL, 0, 0);
  800. Assert(LB_ERR != nDChannel);
  801. Assert(pisdnci->dwNumDChannels >= (DWORD)nDChannel);
  802. nBChannel = SendDlgItemMessage(hwndDlg, IDC_LBX_Variant,
  803. LB_GETCURSEL, 0, 0);
  804. Assert(LB_ERR != nBChannel);
  805. if ((LB_ERR != nDChannel) &&
  806. (LB_ERR != nBChannel) &&
  807. ((nBChannel != pisdnci->nOldBChannel) ||
  808. (nDChannel != pisdnci->nOldDChannel)))
  809. {
  810. PISDN_D_CHANNEL pisdndc;
  811. // Get the channel info for the selection that's going away, and update
  812. // it's listbox item data.
  813. //
  814. SetModifiedIsdnChannelInfo(hwndDlg, IDC_EDT_SPID, IDC_EDT_PhoneNumber,
  815. IDC_LBX_Variant, pisdnci->nOldBChannel,
  816. pisdnci);
  817. pisdndc = &(pisdnci->pDChannel[nDChannel]);
  818. Assert(pisdndc);
  819. // Update item data to reflect new line (d channel)
  820. //
  821. for (DWORD dwChannel = 0;
  822. dwChannel < pisdndc->dwNumBChannels;
  823. dwChannel++)
  824. {
  825. SendDlgItemMessage(hwndDlg, IDC_LBX_Variant, LB_SETITEMDATA,
  826. dwChannel,
  827. (LPARAM) (&pisdndc->pBChannel[dwChannel]));
  828. }
  829. // Update the edit controls for the newly selected listbox item (channel)
  830. //
  831. SetCurrentIsdnChannelSelection(hwndDlg, IDC_EDT_SPID,
  832. IDC_EDT_PhoneNumber, IDC_LBX_Variant,
  833. pisdnci, nDChannel, &nBChannel);
  834. pisdnci->nOldBChannel = nBChannel;
  835. pisdnci->nOldDChannel = nDChannel;
  836. SetFocus(GetDlgItem(hwndDlg, IDC_EDT_PhoneNumber));
  837. }
  838. }
  839. //+---------------------------------------------------------------------------
  840. //
  841. // Function: GetDataFromListBox
  842. //
  843. // Purpose: On the MSN page, this takes the contents of the listbox and
  844. // saves it in memory.
  845. //
  846. // Arguments:
  847. // iItem [in] Selected item in channel listbox
  848. // hwndDlg [in] HWND of dialog
  849. // pisdnci [in] Configuration information as read from the
  850. // registry
  851. //
  852. // Returns: Nothing
  853. //
  854. // Author: danielwe 23 Apr 1998
  855. //
  856. // Notes:
  857. //
  858. VOID GetDataFromListBox(INT iItem, HWND hwndDlg, PISDN_CONFIG_INFO pisdnci)
  859. {
  860. INT cItems;
  861. INT iItemCur;
  862. PISDN_D_CHANNEL pisdndc;
  863. INT cchText = 0;
  864. Assert(pisdnci);
  865. Assert(pisdnci->pDChannel);
  866. pisdndc = &(pisdnci->pDChannel[iItem]);
  867. Assert(pisdndc);
  868. cItems = SendDlgItemMessage(hwndDlg, IDC_LBX_MSN, LB_GETCOUNT, 0, 0);
  869. // First calculate length of multi-sz
  870. //
  871. for (iItemCur = 0; iItemCur < cItems; iItemCur++)
  872. {
  873. cchText += (INT)SendDlgItemMessage(hwndDlg, IDC_LBX_MSN, LB_GETTEXTLEN,
  874. iItemCur, 0) + 1;
  875. }
  876. // Include final Null
  877. cchText++;
  878. // Free the old one
  879. delete [] pisdndc->mszMsnNumbers;
  880. pisdndc->mszMsnNumbers = new WCHAR[cchText];
  881. if (pisdndc->mszMsnNumbers == NULL)
  882. {
  883. return;
  884. }
  885. WCHAR * pchMsn = pisdndc->mszMsnNumbers;
  886. for (iItemCur = 0; iItemCur < cItems; iItemCur++)
  887. {
  888. AssertSz(pchMsn - pisdndc->mszMsnNumbers < cchText, "Bad buffer for "
  889. "MSN string!");
  890. SendDlgItemMessage(hwndDlg, IDC_LBX_MSN, LB_GETTEXT, iItemCur,
  891. (LPARAM)pchMsn);
  892. pchMsn += lstrlenW(pchMsn) + 1;
  893. }
  894. *pchMsn = 0;
  895. }
  896. //+---------------------------------------------------------------------------
  897. //
  898. // Function: SetDataToListBox
  899. //
  900. // Purpose: Sets the contents of the MSN listbox based on the passed in
  901. // selected item from the channel listbox.
  902. //
  903. // Arguments:
  904. // iItem [in] Selected item in channel listbox
  905. // hwndDlg [in] HWND of dialog
  906. // pisdnci [in] Configuration information as read from the
  907. // registry
  908. //
  909. // Returns: Nothing
  910. //
  911. // Author: danielwe 23 Apr 1998
  912. //
  913. // Notes:
  914. //
  915. VOID SetDataToListBox(INT iItem, HWND hwndDlg, PISDN_CONFIG_INFO pisdnci)
  916. {
  917. PISDN_D_CHANNEL pisdndc;
  918. Assert(pisdnci);
  919. Assert(pisdnci->pDChannel);
  920. pisdndc = &(pisdnci->pDChannel[iItem]);
  921. Assert(pisdndc);
  922. SendDlgItemMessage(hwndDlg, IDC_LBX_MSN, LB_RESETCONTENT, 0, 0);
  923. WCHAR * szMsn = pisdndc->mszMsnNumbers;
  924. while (*szMsn)
  925. {
  926. SendDlgItemMessage(hwndDlg, IDC_LBX_MSN, LB_ADDSTRING, 0,
  927. (LPARAM)szMsn);
  928. szMsn += lstrlenW(szMsn) + 1;
  929. }
  930. // Select first item
  931. SendDlgItemMessage(hwndDlg, IDC_LBX_MSN, LB_SETCURSEL, 0, 0);
  932. }
  933. //+---------------------------------------------------------------------------
  934. //
  935. // Function: OnMsnPageInitDialog
  936. //
  937. // Purpose: Called on initialization of the MSN dialog
  938. //
  939. // Arguments:
  940. // hwndDlg [in] HWND of dialog
  941. // pisdnci [in] Configuration information as read from the
  942. // registry
  943. //
  944. // Returns: Nothing
  945. //
  946. // Author: danielwe 23 Apr 1998
  947. //
  948. // Notes:
  949. //
  950. VOID OnMsnPageInitDialog(HWND hwndDlg, PISDN_CONFIG_INFO pisdnci)
  951. {
  952. INT cItems;
  953. // Populate the channels from the array of B-Channels stored in our
  954. // config info for the first D-Channel
  955. //
  956. PopulateIsdnChannels(hwndDlg, IDC_EDT_SPID, IDC_EDT_PhoneNumber,
  957. IDC_LBX_Line, IDC_LBX_Variant, pisdnci);
  958. SetDataToListBox(0, hwndDlg, pisdnci);
  959. EnableWindow(GetDlgItem(hwndDlg, IDC_PSB_ADD), FALSE);
  960. SendDlgItemMessage(hwndDlg, IDC_EDT_MSN, EM_LIMITTEXT,
  961. RAS_MaxPhoneNumber, 0);
  962. cItems = SendDlgItemMessage(hwndDlg, IDC_LBX_MSN, LB_GETCOUNT , 0, 0);
  963. EnableWindow(GetDlgItem(hwndDlg, IDC_PSB_REMOVE), !!cItems);
  964. SetFocus(GetDlgItem(hwndDlg, IDC_EDT_MSN));
  965. SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_EDT_MSN), GWLP_USERDATA, 0);
  966. }
  967. //+---------------------------------------------------------------------------
  968. //
  969. // Function: OnMsnPageSelChange
  970. //
  971. // Purpose: Called when the listbox selection changes
  972. //
  973. // Arguments:
  974. // hwndDlg [in] HWND of dialog
  975. // pisdnci [in] Configuration information as read from the
  976. // registry
  977. //
  978. // Returns: Nothing
  979. //
  980. // Author: danielwe 23 Apr 1998
  981. //
  982. // Notes:
  983. //
  984. VOID OnMsnPageSelChange(HWND hwndDlg, PISDN_CONFIG_INFO pisdnci)
  985. {
  986. INT iItemNew;
  987. INT iItemOld = GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_EDT_MSN),
  988. GWLP_USERDATA);
  989. iItemNew = SendDlgItemMessage(hwndDlg, IDC_LBX_Line, LB_GETCURSEL, 0, 0);
  990. if ((iItemNew != LB_ERR) && (iItemNew != iItemOld))
  991. {
  992. GetDataFromListBox(iItemOld, hwndDlg, pisdnci);
  993. SetDataToListBox(iItemNew, hwndDlg, pisdnci);
  994. SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_EDT_MSN), GWLP_USERDATA,
  995. iItemNew);
  996. }
  997. }
  998. //+---------------------------------------------------------------------------
  999. //
  1000. // Function: OnMsnPageAdd
  1001. //
  1002. // Purpose: Called when the Add button is pressed
  1003. //
  1004. // Arguments:
  1005. // hwndDlg [in] HWND of dialog
  1006. // pisdnci [in] Configuration information as read from the
  1007. // registry
  1008. //
  1009. // Returns: Nothing
  1010. //
  1011. // Author: danielwe 23 Apr 1998
  1012. //
  1013. // Notes:
  1014. //
  1015. VOID OnMsnPageAdd(HWND hwndDlg, PISDN_CONFIG_INFO pisdnci)
  1016. {
  1017. WCHAR szItem[RAS_MaxPhoneNumber + 1];
  1018. INT iItem;
  1019. GetDlgItemText(hwndDlg, IDC_EDT_MSN, szItem, celems(szItem));
  1020. iItem = SendDlgItemMessage(hwndDlg, IDC_LBX_MSN, LB_ADDSTRING, 0,
  1021. (LPARAM)szItem);
  1022. // Select the item after adding it
  1023. SendDlgItemMessage(hwndDlg, IDC_LBX_MSN, LB_SETCURSEL, iItem, 0);
  1024. EnableWindow(GetDlgItem(hwndDlg, IDC_PSB_REMOVE), TRUE);
  1025. SetDlgItemText(hwndDlg, IDC_EDT_MSN, c_szEmpty);
  1026. SetFocus(GetDlgItem(hwndDlg, IDC_EDT_MSN));
  1027. }
  1028. //+---------------------------------------------------------------------------
  1029. //
  1030. // Function: OnMsnPageRemove
  1031. //
  1032. // Purpose: Called when the remove button is pressed
  1033. //
  1034. // Arguments:
  1035. // hwndDlg [in] HWND of dialog
  1036. // pisdnci [in] Configuration information as read from the
  1037. // registry
  1038. //
  1039. // Returns: Nothing
  1040. //
  1041. // Author: danielwe 23 Apr 1998
  1042. //
  1043. // Notes:
  1044. //
  1045. VOID OnMsnPageRemove(HWND hwndDlg, PISDN_CONFIG_INFO pisdnci)
  1046. {
  1047. INT iSel;
  1048. iSel = SendDlgItemMessage(hwndDlg, IDC_LBX_MSN, LB_GETCURSEL, 0, 0);
  1049. if (iSel != LB_ERR)
  1050. {
  1051. INT cItems;
  1052. cItems = SendDlgItemMessage(hwndDlg, IDC_LBX_MSN, LB_DELETESTRING,
  1053. iSel, 0);
  1054. if (cItems)
  1055. {
  1056. if (iSel == cItems)
  1057. {
  1058. iSel--;
  1059. }
  1060. SendDlgItemMessage(hwndDlg, IDC_LBX_MSN, LB_SETCURSEL, iSel, 0);
  1061. }
  1062. else
  1063. {
  1064. ::EnableWindow(GetDlgItem(hwndDlg, IDC_PSB_REMOVE), FALSE);
  1065. ::SetFocus(GetDlgItem(hwndDlg, IDC_EDT_MSN));
  1066. }
  1067. }
  1068. }
  1069. //+---------------------------------------------------------------------------
  1070. //
  1071. // Function: OnMsnPageEditSelChange
  1072. //
  1073. // Purpose: Called when the edit control contents change
  1074. //
  1075. // Arguments:
  1076. // hwndDlg [in] HWND of dialog
  1077. // pisdnci [in] Configuration information as read from the
  1078. // registry
  1079. //
  1080. // Returns: Nothing
  1081. //
  1082. // Author: danielwe 23 Apr 1998
  1083. //
  1084. // Notes:
  1085. //
  1086. VOID OnMsnPageEditSelChange(HWND hwndDlg, PISDN_CONFIG_INFO pisdnci)
  1087. {
  1088. LRESULT lres;
  1089. // Make the old default button normal again
  1090. lres = SendMessage(hwndDlg, DM_GETDEFID, 0, 0);
  1091. if (HIWORD(lres) == DC_HASDEFID)
  1092. {
  1093. SendDlgItemMessage(hwndDlg, LOWORD(lres), BM_SETSTYLE,
  1094. BS_PUSHBUTTON, TRUE);
  1095. }
  1096. // Disable Add button based on whether text is present in the edit control
  1097. //
  1098. if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_EDT_MSN)))
  1099. {
  1100. EnableWindow(GetDlgItem(hwndDlg, IDC_PSB_ADD), TRUE);
  1101. // Make this the default button as well
  1102. SendMessage(hwndDlg, DM_SETDEFID, IDC_PSB_ADD, 0);
  1103. SendDlgItemMessage(hwndDlg, IDC_PSB_ADD, BM_SETSTYLE,
  1104. BS_DEFPUSHBUTTON, TRUE);
  1105. }
  1106. else
  1107. {
  1108. EnableWindow(GetDlgItem(hwndDlg, IDC_PSB_ADD), FALSE);
  1109. // Make the OK button the default
  1110. SendMessage(hwndDlg, DM_SETDEFID, IDOK, 0);
  1111. SendDlgItemMessage(hwndDlg, IDOK, BM_SETSTYLE,
  1112. BS_DEFPUSHBUTTON, TRUE);
  1113. }
  1114. }
  1115. //+---------------------------------------------------------------------------
  1116. //
  1117. // Function: IsdnInfoPageProc
  1118. //
  1119. // Purpose: Dialog proc handler for info (second) page.
  1120. //
  1121. // Arguments:
  1122. // hwndDlg [in]
  1123. // uMessage [in]
  1124. // wparam [in]
  1125. // lparam [in]
  1126. //
  1127. // Returns:
  1128. //
  1129. // Author: danielwe 11 Mar 1998
  1130. //
  1131. // Notes:
  1132. //
  1133. INT_PTR CALLBACK
  1134. IsdnInfoPageProc(HWND hwndDlg, UINT uMessage, WPARAM wparam, LPARAM lparam)
  1135. {
  1136. LPNMHDR lpnmhdr = NULL;
  1137. PISDN_CONFIG_INFO pisdnci;
  1138. PROPSHEETPAGE * ppsp;
  1139. // We have to do this in this fashion because it's very likely that we'll
  1140. // have multiple instances of this dlg proc active at one time. This means
  1141. // that we can't use the single pipipd as a static, as it would get
  1142. // overwritten everytime we hit the WM_INITDIALOG on a new instance.
  1143. //
  1144. pisdnci = (PISDN_CONFIG_INFO)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
  1145. switch (uMessage)
  1146. {
  1147. case WM_INITDIALOG:
  1148. PAGE_DATA * pPageData;
  1149. ppsp = (PROPSHEETPAGE *) lparam;
  1150. // Set the per-page data for this particular page. See the
  1151. // comments above about why we use the per-page data.
  1152. //
  1153. AssertSz(!pisdnci, "This should not have been set yet");
  1154. pPageData = (PAGE_DATA *)ppsp->lParam;
  1155. pisdnci = pPageData->pisdnci;
  1156. // Set this data in the window long for user-data
  1157. //
  1158. SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) pisdnci);
  1159. SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR) pPageData->idd);
  1160. Assert(pisdnci);
  1161. // Call the init handler function
  1162. //
  1163. if (pisdnci->idd == IDW_ISDN_MSN)
  1164. {
  1165. OnMsnPageInitDialog(hwndDlg, pisdnci);
  1166. }
  1167. else
  1168. {
  1169. OnIsdnInfoPageInit(hwndDlg, pisdnci);
  1170. }
  1171. // Limit text in the edit controls
  1172. switch (pisdnci->idd)
  1173. {
  1174. case IDW_ISDN_SPIDS:
  1175. SendDlgItemMessage(hwndDlg, IDC_EDT_SPID, EM_LIMITTEXT,
  1176. c_cchMaxSpid, 0);
  1177. SendDlgItemMessage(hwndDlg, IDC_EDT_PhoneNumber, EM_LIMITTEXT,
  1178. c_cchMaxOther, 0);
  1179. break;
  1180. case IDW_ISDN_MSN:
  1181. SendDlgItemMessage(hwndDlg, IDC_EDT_MSN, EM_LIMITTEXT,
  1182. c_cchMaxOther, 0);
  1183. break;
  1184. case IDW_ISDN_JAPAN:
  1185. SendDlgItemMessage(hwndDlg, IDC_EDT_SPID, EM_LIMITTEXT,
  1186. c_cchMaxOther, 0);
  1187. SendDlgItemMessage(hwndDlg, IDC_EDT_PhoneNumber, EM_LIMITTEXT,
  1188. c_cchMaxOther, 0);
  1189. break;
  1190. case IDW_ISDN_EAZ:
  1191. SendDlgItemMessage(hwndDlg, IDC_EDT_PhoneNumber, EM_LIMITTEXT,
  1192. c_cchMaxOther, 0);
  1193. break;
  1194. }
  1195. break;
  1196. case WM_NOTIFY:
  1197. lpnmhdr = (NMHDR FAR *)lparam;
  1198. // Handle all of the notification messages
  1199. //
  1200. switch (lpnmhdr->code)
  1201. {
  1202. case PSN_SETACTIVE:
  1203. {
  1204. LONG l = OnIsdnInfoPageSetActive(hwndDlg, pisdnci);
  1205. SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, l);
  1206. return TRUE;
  1207. }
  1208. case PSN_APPLY:
  1209. OnIsdnInfoPageApply(hwndDlg, pisdnci);
  1210. break;
  1211. case PSN_WIZBACK:
  1212. OnIsdnInfoPageWizBack(hwndDlg, pisdnci);
  1213. break;
  1214. case PSN_WIZNEXT:
  1215. OnIsdnInfoPageWizNext(hwndDlg, pisdnci);
  1216. break;
  1217. default:
  1218. break;
  1219. }
  1220. break;
  1221. case WM_COMMAND:
  1222. switch (LOWORD(wparam))
  1223. {
  1224. case IDC_PSB_ADD:
  1225. OnMsnPageAdd(hwndDlg, pisdnci);
  1226. break;
  1227. case IDC_PSB_REMOVE:
  1228. OnMsnPageRemove(hwndDlg, pisdnci);
  1229. break;
  1230. case IDC_EDT_MSN:
  1231. if (HIWORD(wparam) == EN_CHANGE)
  1232. {
  1233. OnMsnPageEditSelChange(hwndDlg, pisdnci);
  1234. }
  1235. break;
  1236. case IDC_LBX_Variant:
  1237. case IDC_LBX_Line:
  1238. if (HIWORD(wparam) == LBN_SELCHANGE)
  1239. {
  1240. if (pisdnci->idd == IDW_ISDN_MSN)
  1241. {
  1242. OnMsnPageSelChange(hwndDlg, pisdnci);
  1243. }
  1244. else
  1245. {
  1246. OnIsdnInfoPageSelChange(hwndDlg, pisdnci);
  1247. }
  1248. }
  1249. break;
  1250. }
  1251. }
  1252. return FALSE;
  1253. }
  1254. //+---------------------------------------------------------------------------
  1255. //
  1256. // Function: RetrieveIsdnChannelInfo
  1257. //
  1258. // Purpose: Stores the state of the edit controls into the in-memory
  1259. // state for the currently selected D-channel and B-channel.
  1260. //
  1261. // Arguments:
  1262. // hwndDlg [in] Handle to dialog.
  1263. // iSpidControl [in] Item ID of "spid" edit control
  1264. // iPhoneControl [in] Item ID of "Phone number" edit control
  1265. // iChannelLB [in] Item ID of "Channel" or "Terminal" listbox
  1266. // pisdnci [in] Configuration information as read from the
  1267. // registry
  1268. // dwDChannel [in] Currently selected D-channel in listbox
  1269. // iCurrentChannel [in] Currently selected B-channel in listbox
  1270. //
  1271. // Returns:
  1272. //
  1273. // Author: danielwe 11 Mar 1998
  1274. //
  1275. // Notes:
  1276. //
  1277. VOID RetrieveIsdnChannelInfo(HWND hwndDlg, INT iSpidControl,
  1278. INT iPhoneControl, INT iChannelLB,
  1279. PISDN_CONFIG_INFO pisdnci, DWORD dwDChannel,
  1280. INT iCurrentChannel)
  1281. {
  1282. DWORD dwItemCount = 0;
  1283. DWORD dwItemLoop = 0;
  1284. INT iCharsReturned = 0;
  1285. WCHAR szBChannelName[c_iMaxChannelName+1];
  1286. Assert(hwndDlg);
  1287. Assert(iSpidControl);
  1288. Assert(iPhoneControl);
  1289. Assert(iChannelLB);
  1290. Assert(pisdnci);
  1291. Assert(pisdnci->pDChannel);
  1292. Assert(pisdnci->dwNumDChannels >= dwDChannel);
  1293. // Make sure that the current selection has been propogated back to the
  1294. // channel data
  1295. //
  1296. SetModifiedIsdnChannelInfo(hwndDlg, iSpidControl, iPhoneControl,
  1297. iChannelLB, iCurrentChannel, pisdnci);
  1298. // Get the item from from the listbox
  1299. //
  1300. dwItemCount = SendDlgItemMessage(hwndDlg, iChannelLB, LB_GETCOUNT, 0, 0L);
  1301. if (dwItemCount != pisdnci->pDChannel[dwDChannel].dwNumBChannels)
  1302. {
  1303. AssertSz(FALSE, "Count of items in LB != number of B Channels");
  1304. goto Exit;
  1305. }
  1306. // Loop through the items and get the channel names. Convert those to channel
  1307. // numbers, and propogate the data back to the appropriate B Channel in the
  1308. // config info.
  1309. //
  1310. for (dwItemLoop = 0; dwItemLoop < dwItemCount; dwItemLoop++)
  1311. {
  1312. DWORD dwChannelNumber = 0;
  1313. PISDN_B_CHANNEL pisdnbc = NULL;
  1314. INT_PTR iItemData = 0;
  1315. // Get the length of the channel name.
  1316. //
  1317. iCharsReturned = SendDlgItemMessage(hwndDlg, iChannelLB,
  1318. LB_GETTEXTLEN, dwItemLoop, 0L);
  1319. AssertSz(iCharsReturned != LB_ERR,
  1320. "No reason that we should have gotten a failure for LB_GETTEXTLEN "
  1321. "on the Channel LB");
  1322. if (iCharsReturned > c_iMaxChannelName)
  1323. {
  1324. AssertSz(iCharsReturned <= c_iMaxChannelName, "Channel name too long for buffer");
  1325. goto Exit;
  1326. }
  1327. // Get the channel name.
  1328. //
  1329. iCharsReturned = SendDlgItemMessage(hwndDlg, iChannelLB, LB_GETTEXT,
  1330. dwItemLoop, (LPARAM) szBChannelName);
  1331. AssertSz(iCharsReturned != LB_ERR,
  1332. "Failed on LB_GETTEXT on the Channel LB. Strange");
  1333. // Convert to a channel num from display # (using radix 10), then subtract 1 (base 0)
  1334. //
  1335. dwChannelNumber = wcstoul(szBChannelName, NULL, 10) - 1;
  1336. if (dwChannelNumber >= pisdnci->pDChannel[dwDChannel].dwNumBChannels)
  1337. {
  1338. AssertSz(FALSE, "dwChannelNumber out of the range of valid B Channels");
  1339. goto Exit;
  1340. }
  1341. // Get the item data for that particular channel. This will be the stored SPID and
  1342. // phone numbers (a PISDN_B_CHANNEL).
  1343. //
  1344. iItemData = SendDlgItemMessage(hwndDlg, iChannelLB, LB_GETITEMDATA,
  1345. dwItemLoop, (LPARAM)0);
  1346. AssertSz(iItemData != (INT_PTR)LB_ERR, "LB_ERR returned from LB_GETITEMDATA on Channel LB. Bogus.");
  1347. // It's valid data, so cast it to the struct form.
  1348. //
  1349. pisdnbc = reinterpret_cast<PISDN_B_CHANNEL>(iItemData);
  1350. // Copy the phone number and spid data between the saved list box data and the
  1351. // full config info
  1352. //
  1353. lstrcpyW(pisdnci->pDChannel[dwDChannel].pBChannel[dwChannelNumber].szSpid,
  1354. pisdnbc->szSpid);
  1355. lstrcpyW(pisdnci->pDChannel[dwDChannel].pBChannel[dwChannelNumber].szPhoneNumber,
  1356. pisdnbc->szPhoneNumber);
  1357. }
  1358. Exit:
  1359. return;
  1360. }
  1361. //+---------------------------------------------------------------------------
  1362. //
  1363. // Function: SetCurrentIsdnChannelSelection
  1364. //
  1365. // Purpose: Retrives the information from the in-memory representation of
  1366. // the current D-channel and B-channel information and sets
  1367. // the edit controls with this information.
  1368. //
  1369. // Arguments:
  1370. // hwndDlg [in] Handle to dialog.
  1371. // iSpidControl [in] Item ID of "spid" edit control
  1372. // iPhoneControl [in] Item ID of "Phone number" edit control
  1373. // iChannelLB [in] Item ID of "Channel" or "Terminal" listbox
  1374. // pisdnci [in] Configuration information as read from the
  1375. // registry
  1376. // dwDChannel [in] Currently selected D-channel in listbox
  1377. // pnBChannel [out] Returns currently selected B-channel in list
  1378. //
  1379. // Returns: Nothing
  1380. //
  1381. // Author: danielwe 11 Mar 1998
  1382. //
  1383. // Notes:
  1384. //
  1385. VOID SetCurrentIsdnChannelSelection(HWND hwndDlg, INT iSpidControl,
  1386. INT iPhoneControl, INT iChannelLB,
  1387. PISDN_CONFIG_INFO pisdnci,
  1388. DWORD dwDChannel, INT *pnBChannel)
  1389. {
  1390. INT iIndex = 0;
  1391. INT_PTR iItemData = 0;
  1392. PISDN_B_CHANNEL pisdnbc = NULL;
  1393. // Get the current selection
  1394. //
  1395. iIndex = SendDlgItemMessage(hwndDlg, iChannelLB, LB_GETCURSEL, 0, 0L);
  1396. AssertSz(iIndex != LB_ERR,
  1397. "Should have been able to get a selection in SetCurrentIsdnChannelSelection");
  1398. *pnBChannel = iIndex;
  1399. // Get the item data for the current selection
  1400. //
  1401. iItemData = SendDlgItemMessage(hwndDlg, iChannelLB,
  1402. LB_GETITEMDATA, iIndex, (LPARAM)0);
  1403. AssertSz(iItemData != (INT_PTR)LB_ERR, "LB_ERR returned from LB_GETITEMDATA on "
  1404. "Channel LB. Bogus.");
  1405. // It's valid data, so cast it to the struct form.
  1406. // Note: Use the cost new casting operators.
  1407. //
  1408. pisdnbc = (PISDN_B_CHANNEL) iItemData;
  1409. // Populate the edit controls with the newly selected data.
  1410. //
  1411. SetDataToEditControls(hwndDlg, iPhoneControl, iSpidControl, pisdnci,
  1412. pisdnbc);
  1413. }
  1414. //+---------------------------------------------------------------------------
  1415. //
  1416. // Function: PopulateIsdnChannels
  1417. //
  1418. // Purpose: Fills in the channel listboxes and edit controls for the
  1419. // second page of the wizard.
  1420. //
  1421. // Arguments:
  1422. // hwndDlg [in] Handle to dialog
  1423. // iSpidControl [in] Item ID of "spid" edit control
  1424. // iPhoneControl [in] Item ID of "Phone number" edit control
  1425. // iLineLB [in] Item ID of "Line" listbox
  1426. // iChannelLB [in] Item ID of "Channel" or "Terminal" listbox
  1427. // pisdnci [in] Configuration information as read from the
  1428. // registry
  1429. //
  1430. // Returns: Nothing.
  1431. //
  1432. // Author: danielwe 11 Mar 1998
  1433. //
  1434. // Notes:
  1435. //
  1436. VOID PopulateIsdnChannels(HWND hwndDlg, INT iSpidControl, INT iPhoneControl,
  1437. INT iLineLB, INT iChannelLB,
  1438. PISDN_CONFIG_INFO pisdnci)
  1439. {
  1440. DWORD iBChannel = 0;
  1441. PISDN_D_CHANNEL pisdndc = NULL;
  1442. DWORD iDChannel;
  1443. WCHAR szChannelName[c_iMaxChannelName + 1];
  1444. Assert(hwndDlg);
  1445. Assert(iSpidControl);
  1446. Assert(iPhoneControl);
  1447. Assert(iLineLB);
  1448. Assert(iChannelLB);
  1449. Assert(pisdnci);
  1450. // Set the maximum lengths of the SPID and Phone number controls
  1451. //
  1452. SendDlgItemMessage(hwndDlg, iSpidControl, EM_SETLIMITTEXT,
  1453. RAS_MaxPhoneNumber, 0L);
  1454. SendDlgItemMessage(hwndDlg, iPhoneControl, EM_SETLIMITTEXT,
  1455. RAS_MaxPhoneNumber, 0L);
  1456. SendDlgItemMessage(hwndDlg, iLineLB, LB_RESETCONTENT, 0, 0);
  1457. // Loop thru the D channels (lines)
  1458. for (iDChannel = 0; iDChannel < pisdnci->dwNumDChannels; iDChannel++)
  1459. {
  1460. // Create the string for the channel display. The user will see them
  1461. // enumerated from 1, even though in memory and in the registry, they are
  1462. // enumerated from 0.
  1463. //
  1464. wsprintfW(szChannelName, L"%d", iDChannel + 1);
  1465. // Insert the text
  1466. //
  1467. SendDlgItemMessage(hwndDlg, iLineLB, LB_ADDSTRING, 0,
  1468. (LPARAM) szChannelName);
  1469. }
  1470. // Get the pointer to the first D Channel's data
  1471. //
  1472. pisdndc = &(pisdnci->pDChannel[0]);
  1473. // Loop through the B channels, and fill the listbox with the channel numbers.
  1474. // Also, fill the channel information for the first B Channel
  1475. //
  1476. SendDlgItemMessage(hwndDlg, iChannelLB, LB_RESETCONTENT, 0, 0);
  1477. for (iBChannel = 0; iBChannel < pisdndc->dwNumBChannels; iBChannel++)
  1478. {
  1479. INT iInsertionIndex = 0;
  1480. PISDN_B_CHANNEL pisdnbc;
  1481. // Create the string for the channel display. The user will see them
  1482. // enumerated from 1, even though in memory and in the registry, they are
  1483. // enumerated from 0.
  1484. //
  1485. wsprintfW(szChannelName, L"%d", iBChannel + 1);
  1486. // Insert the text
  1487. //
  1488. iInsertionIndex = SendDlgItemMessage(hwndDlg, iChannelLB,
  1489. LB_ADDSTRING, 0,
  1490. (LPARAM) szChannelName);
  1491. if (iInsertionIndex == LB_ERR)
  1492. {
  1493. AssertSz(FALSE, "Unable to add channel name to listbox in "
  1494. "PopulateIsdnChannels");
  1495. goto Exit;
  1496. }
  1497. pisdnbc = &pisdndc->pBChannel[iBChannel];
  1498. // Init the item data with the first D channel's information
  1499. //
  1500. SendDlgItemMessage(hwndDlg, iChannelLB, LB_SETITEMDATA,
  1501. iInsertionIndex, (LPARAM) pisdnbc);
  1502. // If we're on the 0'th member, then we want to fill in the edit controls
  1503. // for that particular channel,
  1504. //
  1505. if (iBChannel == 0)
  1506. {
  1507. SetDataToEditControls(hwndDlg, iPhoneControl, iSpidControl,
  1508. pisdnci, pisdnbc);
  1509. }
  1510. }
  1511. // Select first item in each list box
  1512. //
  1513. SendDlgItemMessage(hwndDlg, iChannelLB, LB_SETCURSEL, 0, 0L);
  1514. SendDlgItemMessage(hwndDlg, iLineLB, LB_SETCURSEL, 0, 0L);
  1515. Exit:
  1516. return;
  1517. }
  1518. //+---------------------------------------------------------------------------
  1519. //
  1520. // Function: SetDataToEditControls
  1521. //
  1522. // Purpose: Sets the in-memory state information to the page's edit
  1523. // controls.
  1524. //
  1525. // Arguments:
  1526. // hwndDlg [in] Handle to dialog
  1527. // iSpidControl [in] Item ID of "spid" edit control
  1528. // iPhoneControl [in] Item ID of "Phone number" edit control
  1529. // pisdnci [in] Configuration information as read from the
  1530. // registry
  1531. // pisdnbc [in] Currently selected B-channel's data
  1532. //
  1533. // Returns: Nothing
  1534. //
  1535. // Author: danielwe 16 Mar 1998
  1536. //
  1537. // Notes:
  1538. //
  1539. VOID SetDataToEditControls(HWND hwndDlg, INT iPhoneControl, INT iSpidControl,
  1540. PISDN_CONFIG_INFO pisdnci, PISDN_B_CHANNEL pisdnbc)
  1541. {
  1542. switch (pisdnci->idd)
  1543. {
  1544. case IDW_ISDN_SPIDS:
  1545. case IDD_ISDN_SPIDS:
  1546. SetDlgItemText(hwndDlg, iSpidControl, pisdnbc->szSpid);
  1547. SetDlgItemText(hwndDlg, iPhoneControl, pisdnbc->szPhoneNumber);
  1548. break;
  1549. case IDW_ISDN_EAZ:
  1550. case IDD_ISDN_EAZ:
  1551. SetDlgItemText(hwndDlg, iPhoneControl, pisdnbc->szPhoneNumber);
  1552. break;
  1553. case IDW_ISDN_JAPAN:
  1554. case IDD_ISDN_JAPAN:
  1555. SetDlgItemText(hwndDlg, iSpidControl, pisdnbc->szSubaddress);
  1556. SetDlgItemText(hwndDlg, iPhoneControl, pisdnbc->szPhoneNumber);
  1557. break;
  1558. }
  1559. }
  1560. //+---------------------------------------------------------------------------
  1561. //
  1562. // Function: GetDataFromEditControls
  1563. //
  1564. // Purpose: Retrieves contents of the edit controls into the in-memory
  1565. // state for the given B-channel.
  1566. //
  1567. // Arguments:
  1568. // hwndDlg [in] Handle to dialog
  1569. // iSpidControl [in] Item ID of "spid" edit control
  1570. // iPhoneControl [in] Item ID of "Phone number" edit control
  1571. // pisdnci [in] Configuration information as read from the
  1572. // registry
  1573. // pisdnbc [in] Currently selected B-channel's data
  1574. //
  1575. // Returns: Nothing
  1576. //
  1577. // Author: danielwe 16 Mar 1998
  1578. //
  1579. // Notes:
  1580. //
  1581. VOID GetDataFromEditControls(HWND hwndDlg, INT iPhoneControl, INT iSpidControl,
  1582. PISDN_CONFIG_INFO pisdnci,
  1583. PISDN_B_CHANNEL pisdnbc)
  1584. {
  1585. switch (pisdnci->idd)
  1586. {
  1587. case IDW_ISDN_SPIDS:
  1588. case IDD_ISDN_SPIDS:
  1589. GetDlgItemText(hwndDlg, iSpidControl, pisdnbc->szSpid,
  1590. celems(pisdnbc->szSpid));
  1591. GetDlgItemText(hwndDlg, iPhoneControl, pisdnbc->szPhoneNumber,
  1592. celems(pisdnbc->szPhoneNumber));
  1593. break;
  1594. case IDW_ISDN_EAZ:
  1595. case IDD_ISDN_EAZ:
  1596. GetDlgItemText(hwndDlg, iPhoneControl, pisdnbc->szPhoneNumber,
  1597. celems(pisdnbc->szPhoneNumber));
  1598. break;
  1599. case IDW_ISDN_JAPAN:
  1600. case IDD_ISDN_JAPAN:
  1601. GetDlgItemText(hwndDlg, iSpidControl, pisdnbc->szSubaddress,
  1602. celems(pisdnbc->szSubaddress));
  1603. GetDlgItemText(hwndDlg, iPhoneControl, pisdnbc->szPhoneNumber,
  1604. celems(pisdnbc->szPhoneNumber));
  1605. break;
  1606. }
  1607. }
  1608. //+---------------------------------------------------------------------------
  1609. //
  1610. // Function: SetModifiedIsdnChannelInfo
  1611. //
  1612. // Purpose: Stores the contents of the
  1613. //
  1614. // Arguments:
  1615. // hwndDlg [in] Handle to dialog.
  1616. // iSpidControl [in] Item ID of "spid" edit control
  1617. // iPhoneControl [in] Item ID of "Phone number" edit control
  1618. // iChannelLB [in] Item ID of "Channel" or "Terminal" listbox
  1619. // iCurrentChannel [in] Currently selected B-channel
  1620. // pisdnci [in] ISDN config info
  1621. //
  1622. // Returns: Nothing
  1623. //
  1624. // Author: danielwe 11 Mar 1998
  1625. //
  1626. // Notes:
  1627. //
  1628. VOID SetModifiedIsdnChannelInfo(HWND hwndDlg, INT iSpidControl,
  1629. INT iPhoneControl, INT iChannelLB,
  1630. INT iCurrentChannel,
  1631. PISDN_CONFIG_INFO pisdnci)
  1632. {
  1633. INT_PTR iSelectionData = 0;
  1634. PISDN_B_CHANNEL pisdnbc = NULL;
  1635. // Get the item data from the current selection
  1636. //
  1637. iSelectionData = SendDlgItemMessage(hwndDlg, iChannelLB, LB_GETITEMDATA,
  1638. iCurrentChannel, (LPARAM)0);
  1639. AssertSz(iSelectionData != (INT_PTR)LB_ERR,
  1640. "We should not have failed to get the item data from the Channel LB");
  1641. // Convert the item data to the real structure
  1642. //
  1643. pisdnbc = (PISDN_B_CHANNEL) iSelectionData;
  1644. AssertSz(pisdnbc,
  1645. "Someone forgot to set the item data. Bad someone!...Bad!");
  1646. GetDataFromEditControls(hwndDlg, iPhoneControl, iSpidControl, pisdnci,
  1647. pisdnbc);
  1648. }
  1649. //
  1650. // Helper functions
  1651. //
  1652. //+---------------------------------------------------------------------------
  1653. //
  1654. // Function: DwGetCurrentCountryCode
  1655. //
  1656. // Purpose: Returns current country code for the system
  1657. //
  1658. // Arguments:
  1659. // (none)
  1660. //
  1661. // Returns: Country code from winnls.h (CTRY_*)
  1662. //
  1663. // Author: danielwe 11 Mar 1998
  1664. //
  1665. // Notes:
  1666. //
  1667. DWORD DwGetCurrentCountryCode()
  1668. {
  1669. WCHAR szCountry[10];
  1670. GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_ICOUNTRY, szCountry,
  1671. celems(szCountry));
  1672. return wcstoul(szCountry, NULL, 10);
  1673. }
  1674. //+---------------------------------------------------------------------------
  1675. //
  1676. // Function: FIsDefaultForLocale
  1677. //
  1678. // Purpose: Determines if the given switch type is the default switch
  1679. // type for the given locale.
  1680. //
  1681. // Arguments:
  1682. // nCountry [in] Country code from winnls.h (CTRY_*)
  1683. // dwSwitchType [in] Switch type mask ISDN_SWITCH_* (from above)
  1684. //
  1685. // Returns: TRUE if switch type is the default, FALSE if not
  1686. //
  1687. // Author: danielwe 11 Mar 1998
  1688. //
  1689. // Notes:
  1690. //
  1691. BOOL FIsDefaultForLocale(DWORD nCountry, DWORD dwSwitchType)
  1692. {
  1693. switch (nCountry)
  1694. {
  1695. case CTRY_UNITED_STATES:
  1696. return ((dwSwitchType == ISDN_SWITCH_NI1) ||
  1697. (dwSwitchType == ISDN_SWITCH_NI2));
  1698. case CTRY_JAPAN:
  1699. return (dwSwitchType == ISDN_SWITCH_INS64);
  1700. case CTRY_TAIWAN:
  1701. case CTRY_PRCHINA:
  1702. case CTRY_NEW_ZEALAND:
  1703. case CTRY_AUSTRALIA:
  1704. case CTRY_ARMENIA:
  1705. case CTRY_AUSTRIA:
  1706. case CTRY_BELGIUM:
  1707. case CTRY_BULGARIA:
  1708. case CTRY_CROATIA:
  1709. case CTRY_CZECH:
  1710. case CTRY_DENMARK:
  1711. case CTRY_FINLAND:
  1712. case CTRY_FRANCE:
  1713. case CTRY_GERMANY:
  1714. case CTRY_GREECE:
  1715. case CTRY_HONG_KONG:
  1716. case CTRY_HUNGARY:
  1717. case CTRY_ICELAND:
  1718. case CTRY_IRELAND:
  1719. case CTRY_ITALY:
  1720. case CTRY_LITHUANIA:
  1721. case CTRY_LUXEMBOURG:
  1722. case CTRY_MACEDONIA:
  1723. case CTRY_NETHERLANDS:
  1724. case CTRY_NORWAY:
  1725. case CTRY_ROMANIA:
  1726. case CTRY_SERBIA:
  1727. case CTRY_SLOVAK:
  1728. case CTRY_SLOVENIA:
  1729. case CTRY_SPAIN:
  1730. case CTRY_SWEDEN:
  1731. case CTRY_SWITZERLAND:
  1732. case CTRY_UNITED_KINGDOM:
  1733. return (dwSwitchType == ISDN_SWITCH_DSS1);
  1734. default:
  1735. return FALSE;
  1736. }
  1737. }
  1738. //+---------------------------------------------------------------------------
  1739. //
  1740. // Function: DestroyWizardData
  1741. //
  1742. // Purpose: Callback for the all wizard pages. Cleans up when page is
  1743. // being destroyed.
  1744. //
  1745. // Arguments:
  1746. // hwnd [in] See win32 SDK for property page callback
  1747. // uMsg [in]
  1748. // ppsp [in]
  1749. //
  1750. // Returns: 1 (See win32 sdk)
  1751. //
  1752. // Author: BillBe 22 Apr 1998
  1753. //
  1754. // Notes:
  1755. //
  1756. UINT CALLBACK
  1757. DestroyWizardData(HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp)
  1758. {
  1759. if (PSPCB_RELEASE == uMsg)
  1760. {
  1761. PAGE_DATA * pPageData;
  1762. pPageData = (PAGE_DATA *)ppsp->lParam;
  1763. if (pPageData->idd == IDW_ISDN_SWITCH_TYPE)
  1764. {
  1765. PISDN_CONFIG_INFO pisdnci;
  1766. // If this is the switch type dialog being destroyed, we'll
  1767. // destroy the ISDN info. Since it's shared among all pages,
  1768. // we should only do this for one of the pages.
  1769. //
  1770. pisdnci = pPageData->pisdnci;
  1771. FreeIsdnPropertiesInfo(pisdnci);
  1772. }
  1773. delete pPageData;
  1774. }
  1775. return 1;
  1776. }
  1777. static const CONTEXTIDMAP c_adwContextIdMap[] =
  1778. {
  1779. { IDC_LBX_Line, 2003230, 2003230 },
  1780. { IDC_LBX_Variant, 2003240, 2003240 },
  1781. { IDC_EDT_PhoneNumber, 2003250, 2003255 },
  1782. { IDC_EDT_SPID, 2003265, 2003260 },
  1783. { IDC_EDT_MSN, 2003270, 2003270 },
  1784. { IDC_PSB_ADD, 2003280, 2003280 },
  1785. { IDC_LBX_MSN, 2003290, 2003290 },
  1786. { IDC_PSB_REMOVE, 2003300, 2003300 },
  1787. { IDC_CMB_SwitchType, 2003310, 2003310 },
  1788. { IDC_PSB_Configure, 2003320, 2003320 },
  1789. };
  1790. static const DWORD c_cdwContextIdMap = celems(c_adwContextIdMap);
  1791. //+---------------------------------------------------------------------------
  1792. //
  1793. // Function: DwContextIdFromIdc
  1794. //
  1795. // Purpose: Converts the given control ID to a context help ID
  1796. //
  1797. // Arguments:
  1798. // idControl [in] Control ID to convert
  1799. //
  1800. // Returns: Context help ID for that control (mapping comes from help
  1801. // authors)
  1802. //
  1803. // Author: danielwe 27 May 1998
  1804. //
  1805. // Notes:
  1806. //
  1807. DWORD DwContextIdFromIdc(PISDN_CONFIG_INFO pisdnci, INT idControl)
  1808. {
  1809. DWORD idw;
  1810. for (idw = 0; idw < c_cdwContextIdMap; idw++)
  1811. {
  1812. if (idControl == c_adwContextIdMap[idw].idControl)
  1813. {
  1814. if (pisdnci->idd == IDD_ISDN_JAPAN)
  1815. {
  1816. return c_adwContextIdMap[idw].dwContextIdJapan;
  1817. }
  1818. else
  1819. {
  1820. return c_adwContextIdMap[idw].dwContextId;
  1821. }
  1822. }
  1823. }
  1824. // Not found, just return 0
  1825. return 0;
  1826. }
  1827. //+---------------------------------------------------------------------------
  1828. //
  1829. // Function: OnHelpGeneric
  1830. //
  1831. // Purpose: Handles help generically
  1832. //
  1833. // Arguments:
  1834. // hwnd [in] HWND of parent window
  1835. // lParam [in] lParam of the WM_HELP message
  1836. //
  1837. // Returns: Nothing
  1838. //
  1839. // Author: danielwe 27 May 1998
  1840. //
  1841. // Notes:
  1842. //
  1843. VOID OnHelpGeneric(PISDN_CONFIG_INFO pisdnci, HWND hwnd, LPARAM lParam)
  1844. {
  1845. LPHELPINFO lphi;
  1846. static const WCHAR c_szIsdnHelpFile[] = L"devmgr.hlp";
  1847. lphi = reinterpret_cast<LPHELPINFO>(lParam);
  1848. Assert(lphi);
  1849. if (lphi->iContextType == HELPINFO_WINDOW)
  1850. {
  1851. if (lphi->iCtrlId != IDC_STATIC)
  1852. {
  1853. WinHelp(hwnd, c_szIsdnHelpFile, HELP_CONTEXTPOPUP,
  1854. DwContextIdFromIdc(pisdnci, lphi->iCtrlId));
  1855. }
  1856. }
  1857. }