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.

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