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.

966 lines
23 KiB

  1. /*
  2. File nettab.c
  3. Implementation of the ui behind the networking tab in the dialup server
  4. ui.
  5. Paul Mayfield 10/8/97.
  6. */
  7. #include <rassrv.h>
  8. // Help maps
  9. static const DWORD phmNetTab[] =
  10. {
  11. CID_NetTab_LV_Components, IDH_NetTab_LV_Components,
  12. CID_NetTab_PB_Add, IDH_NetTab_PB_Add,
  13. CID_NetTab_PB_Remove, IDH_NetTab_PB_Remove,
  14. CID_NetTab_PB_Properties, IDH_NetTab_PB_Properties,
  15. 0, 0
  16. };
  17. //
  18. // Fills in the property sheet structure with the information
  19. // required to display the networking tab.
  20. //
  21. DWORD
  22. NetTabGetPropertyPage(
  23. IN LPPROPSHEETPAGE ppage,
  24. IN LPARAM lpUserData)
  25. {
  26. // Initialize
  27. ZeroMemory(ppage, sizeof(PROPSHEETPAGE));
  28. // Fill in the values
  29. ppage->dwSize = sizeof(PROPSHEETPAGE);
  30. ppage->hInstance = Globals.hInstDll;
  31. ppage->pszTemplate = MAKEINTRESOURCE(PID_NetTab);
  32. ppage->pfnDlgProc = NetTabDialogProc;
  33. ppage->pfnCallback = RasSrvInitDestroyPropSheetCb;
  34. ppage->dwFlags = PSP_USECALLBACK;
  35. ppage->lParam = lpUserData;
  36. return NO_ERROR;
  37. }
  38. // Error reporting
  39. VOID
  40. NetTabDisplayError(
  41. IN HWND hwnd,
  42. IN DWORD dwErr)
  43. {
  44. ErrDisplayError(
  45. hwnd,
  46. dwErr,
  47. ERR_ADVANCEDTAB_CATAGORY,
  48. 0,
  49. Globals.dwErrorData);
  50. }
  51. //
  52. // Returns the index of an to display icon based on the
  53. // type of incoming connection.
  54. //
  55. INT
  56. NetTabGetIconIndex(
  57. IN DWORD dwType)
  58. {
  59. switch (dwType)
  60. {
  61. case NETCFGDB_SERVICE:
  62. return NI_Service;
  63. case NETCFGDB_CLIENT:
  64. return NI_Client;
  65. case NETCFGDB_PROTOCOL:
  66. return NI_Protocol;
  67. }
  68. return 0;
  69. }
  70. //
  71. // Sets up the UI so that the user is forced to complete the
  72. // config they've started. Triggered when a non-reversable option
  73. // is taken such as adding/removing a networking component.
  74. //
  75. DWORD
  76. NetTabDisableRollback(
  77. IN HWND hwndDlg)
  78. {
  79. DWORD dwErr, dwId = 0;
  80. do
  81. {
  82. dwErr = RasSrvGetPageId (hwndDlg, &dwId);
  83. if (dwErr != NO_ERROR)
  84. {
  85. break;
  86. }
  87. if (dwId == RASSRVUI_ADVANCED_TAB)
  88. {
  89. PropSheet_CancelToClose(GetParent(hwndDlg));
  90. }
  91. } while (FALSE);
  92. // Cleanup
  93. {
  94. }
  95. return dwErr;
  96. }
  97. //
  98. // Fills in the given list view with the names of the components
  99. // stored in the database provided.
  100. //
  101. DWORD
  102. NetTabFillComponentList(
  103. IN HWND hwndLV,
  104. IN HANDLE hNetCompDatabase)
  105. {
  106. LV_ITEM lvi;
  107. DWORD dwCount, i, dwErr, dwProtCount, dwType;
  108. PWCHAR pszName;
  109. BOOL bManip, bEnabled;
  110. // Get the count of all the components
  111. //
  112. dwErr = netDbGetCompCount (hNetCompDatabase, &dwCount);
  113. if (dwErr != NO_ERROR)
  114. {
  115. return dwErr;
  116. }
  117. // Initialize the list item
  118. ZeroMemory(&lvi, sizeof(LV_ITEM));
  119. lvi.mask = LVIF_TEXT | LVIF_IMAGE;
  120. // Looop through all of the network components
  121. // adding their names as we go
  122. for (i = 0; i < dwCount; i++)
  123. {
  124. netDbGetType (hNetCompDatabase, i, &dwType);
  125. netDbIsRasManipulatable (hNetCompDatabase, i, &bManip);
  126. netDbGetEnable (hNetCompDatabase, i, &bEnabled);
  127. // Fill in the data
  128. //
  129. netDbGetName (hNetCompDatabase, i, &pszName);
  130. lvi.iImage = NetTabGetIconIndex(dwType);
  131. lvi.iItem = i;
  132. lvi.pszText = pszName;
  133. lvi.cchTextMax = wcslen(pszName)+1;
  134. ListView_InsertItem(hwndLV,&lvi);
  135. ListView_SetCheck(hwndLV, i, bEnabled);
  136. // If this is not a ras manipulateable component,
  137. // disable the check since it can't be set anyway.
  138. if (!bManip)
  139. {
  140. ListView_DisableCheck(hwndLV, i);
  141. }
  142. }
  143. return NO_ERROR;
  144. }
  145. //
  146. // Updates the description of the currently selected protocol
  147. //
  148. DWORD
  149. NetTabUpdateDescription(
  150. IN HWND hwndDlg,
  151. IN DWORD i)
  152. {
  153. HANDLE hNetCompDatabase = NULL, hProt = NULL;
  154. PWCHAR pszDesc;
  155. DWORD dwErr = NO_ERROR;
  156. // Get handles to the databases we're interested in
  157. RasSrvGetDatabaseHandle(
  158. hwndDlg,
  159. ID_NETCOMP_DATABASE,
  160. &hNetCompDatabase);
  161. do
  162. {
  163. dwErr = netDbGetDesc(hNetCompDatabase, i, &pszDesc);
  164. if (dwErr != NO_ERROR)
  165. {
  166. break;
  167. }
  168. // Set the description
  169. SetDlgItemTextW(
  170. hwndDlg,
  171. CID_NetTab_ST_Description,
  172. pszDesc);
  173. } while (FALSE);
  174. // Cleanup
  175. {
  176. if (dwErr != NO_ERROR)
  177. {
  178. SetDlgItemTextW(
  179. hwndDlg,
  180. CID_NetTab_ST_Description,
  181. L"");
  182. }
  183. }
  184. return dwErr;
  185. }
  186. //
  187. //When an Item in the listview is selected, check if the user can Uninstall it
  188. //for whistler bug 347355 gangz
  189. //
  190. DWORD
  191. NetTabEnableDisableRemoveButton (
  192. IN HWND hwndDlg,
  193. IN DWORD iItem)
  194. {
  195. HANDLE hNetCompDatabase = NULL;
  196. DWORD dwErr;
  197. HWND hwndRemove = NULL;
  198. BOOL bHasPermit = FALSE;
  199. if ( !hwndDlg )
  200. {
  201. return ERROR_INVALID_PARAMETER;
  202. }
  203. hwndRemove = GetDlgItem(hwndDlg, CID_NetTab_PB_Remove);
  204. dwErr = RasSrvGetDatabaseHandle(
  205. hwndDlg,
  206. ID_NETCOMP_DATABASE,
  207. &hNetCompDatabase);
  208. if ( NO_ERROR != dwErr ||
  209. NULL == hwndRemove )
  210. {
  211. return ERROR_CAN_NOT_COMPLETE;
  212. }
  213. dwErr = netDbHasRemovePermission(
  214. hNetCompDatabase,
  215. iItem,
  216. &bHasPermit);
  217. if( NO_ERROR == dwErr )
  218. {
  219. EnableWindow( hwndRemove, bHasPermit);
  220. }
  221. return dwErr;
  222. }
  223. //
  224. // Enables or disables the properties button based on whether
  225. // the index of the given item in the list view can have properties
  226. // invoked on it. Currently, only non-ras-manaipulatable protocols
  227. // can not have their properties invoked.
  228. //
  229. DWORD
  230. NetTabEnableDisablePropButton(
  231. IN HWND hwndDlg,
  232. IN INT iItem)
  233. {
  234. HANDLE hNetCompDatabase = NULL;
  235. DWORD dwErr;
  236. BOOL bHasUi;
  237. HWND hwndProps;
  238. // Get a reference to the network component database
  239. //
  240. RasSrvGetDatabaseHandle(
  241. hwndDlg,
  242. ID_NETCOMP_DATABASE,
  243. &hNetCompDatabase);
  244. // Get the type and whether it is manipulatable
  245. //
  246. dwErr = netDbHasPropertiesUI (hNetCompDatabase, iItem, &bHasUi);
  247. if (dwErr != NO_ERROR)
  248. {
  249. return dwErr;
  250. }
  251. // Enable or disable properties
  252. hwndProps = GetDlgItem(hwndDlg, CID_NetTab_PB_Properties);
  253. if (hwndProps)
  254. {
  255. EnableWindow(hwndProps, bHasUi);
  256. }
  257. return NO_ERROR;
  258. }
  259. //
  260. // Refreshes the list view
  261. //
  262. DWORD
  263. NetTabRefreshListView(
  264. IN HWND hwndLV,
  265. IN HANDLE hNetCompDatabase)
  266. {
  267. DWORD dwCount, dwErr;
  268. HWND hwndDlg = GetParent(hwndLV);
  269. // For whistler bug 440167 gangz
  270. //
  271. int iSelect = -1;
  272. iSelect = ListView_GetSelectionMark(
  273. GetDlgItem(hwndDlg, CID_NetTab_LV_Components)
  274. );
  275. // Get rid of all of the old elements in the list view
  276. //
  277. ListView_DeleteAllItems(hwndLV);
  278. // Re-stock the list views
  279. //
  280. dwErr = NetTabFillComponentList(hwndLV, hNetCompDatabase);
  281. if (dwErr != NO_ERROR)
  282. {
  283. return dwErr;
  284. }
  285. // Select the first protocol in the list view if any items exist.
  286. // Also in this case, make sure that "remove" is enabled/disabled
  287. // according to the the first item in the list view
  288. //
  289. netDbGetCompCount(hNetCompDatabase, &dwCount);
  290. if (dwCount)
  291. {
  292. // For whistler bug 440167 gangz
  293. //
  294. if ( 0 > iSelect ||
  295. dwCount <= (DWORD)iSelect )
  296. {
  297. iSelect = 0;
  298. }
  299. ListView_SetItemState(
  300. hwndLV,
  301. iSelect,
  302. LVIS_SELECTED | LVIS_FOCUSED,
  303. LVIS_SELECTED | LVIS_FOCUSED);
  304. ListView_EnsureVisible(hwndLV,
  305. iSelect,
  306. FALSE
  307. );
  308. //for whistler bug 406698 gangz
  309. //
  310. NetTabEnableDisableRemoveButton (
  311. hwndDlg,
  312. iSelect); // For whistler bug 440167
  313. }
  314. // If there are no components, disable the properties
  315. // and remove buttons
  316. else
  317. {
  318. HWND hwndControl = GetDlgItem(hwndDlg, CID_NetTab_PB_Properties);
  319. if (hwndControl)
  320. {
  321. EnableWindow(hwndControl, FALSE);
  322. }
  323. hwndControl = GetDlgItem(hwndDlg, CID_NetTab_PB_Remove);
  324. if (hwndControl)
  325. {
  326. EnableWindow(hwndControl, FALSE);
  327. }
  328. }
  329. return NO_ERROR;
  330. }
  331. //
  332. // Initializes the networking tab. By now a handle to the advanced
  333. // database has been placed in the user data of the dialog
  334. //
  335. DWORD
  336. NetTabInitializeDialog(
  337. HWND hwndDlg,
  338. WPARAM wParam)
  339. {
  340. DWORD dwErr, dwCount, i;
  341. BOOL bFlag;
  342. HANDLE hNetCompDatabase = NULL, hMiscDatabase = NULL;
  343. HWND hwndLV;
  344. LV_COLUMN lvc;
  345. BOOL bExpose = FALSE, bIsServer;
  346. // Get handles to the databases we're interested in
  347. //
  348. RasSrvGetDatabaseHandle(
  349. hwndDlg,
  350. ID_MISC_DATABASE,
  351. &hMiscDatabase);
  352. RasSrvGetDatabaseHandle(
  353. hwndDlg,
  354. ID_NETCOMP_DATABASE,
  355. &hNetCompDatabase);
  356. // Fill in the list view will all available protocols followed
  357. // by all of the installed network components.
  358. //
  359. hwndLV = GetDlgItem(hwndDlg, CID_NetTab_LV_Components);
  360. if (hwndLV)
  361. {
  362. ListView_InstallChecks(hwndLV, Globals.hInstDll);
  363. ListView_SetNetworkComponentImageList(hwndLV, Globals.hInstDll);
  364. // Fill the list view
  365. NetTabRefreshListView(hwndLV, hNetCompDatabase);
  366. }
  367. //for whistler bug 347355 gangz
  368. //
  369. NetTabEnableDisablePropButton(
  370. hwndDlg,
  371. 0);
  372. NetTabEnableDisableRemoveButton (
  373. hwndDlg,
  374. 0);
  375. if (hwndLV)
  376. {
  377. // Add a colum so that we'll display in report view
  378. lvc.mask = LVCF_FMT;
  379. lvc.fmt = LVCFMT_LEFT;
  380. ListView_InsertColumn(hwndLV,0,&lvc);
  381. ListView_SetColumnWidth(hwndLV, 0, LVSCW_AUTOSIZE_USEHEADER);
  382. }
  383. return NO_ERROR;
  384. }
  385. // Handles a check being made
  386. DWORD
  387. NetTabHandleProtCheck(
  388. IN HWND hwndDlg,
  389. IN DWORD dwIndex)
  390. {
  391. BOOL bEnable = FALSE, bEnabled = FALSE;
  392. DWORD dwErr = NO_ERROR, dwId = 0;
  393. HANDLE hNetCompDatabase = NULL;
  394. HWND hwndLV =
  395. GetDlgItem(hwndDlg, CID_NetTab_LV_Components);
  396. MSGARGS MsgArgs;
  397. INT iRet;
  398. PWCHAR pszName = NULL;
  399. // Initailize the message arguments
  400. //
  401. ZeroMemory(&MsgArgs, sizeof(MsgArgs));
  402. // Find out whether the component is being enabled or
  403. // disabled
  404. if (hwndLV)
  405. {
  406. bEnable = !!ListView_GetCheck(hwndLV, dwIndex);
  407. }
  408. // Get the handle for the Prot database
  409. //
  410. RasSrvGetDatabaseHandle(
  411. hwndDlg,
  412. ID_NETCOMP_DATABASE,
  413. &hNetCompDatabase);
  414. // Get component id
  415. //
  416. dwErr = netDbGetId(
  417. hNetCompDatabase,
  418. dwIndex,
  419. &dwId);
  420. if (dwErr != NO_ERROR)
  421. {
  422. return dwErr;
  423. }
  424. // Get component name
  425. //
  426. dwErr = netDbGetName(
  427. hNetCompDatabase,
  428. dwIndex,
  429. &pszName);
  430. if (dwErr != NO_ERROR)
  431. {
  432. return dwErr;
  433. }
  434. // Get component enabling
  435. //
  436. dwErr = netDbGetEnable(
  437. hNetCompDatabase,
  438. dwIndex,
  439. &bEnabled);
  440. if (dwErr != NO_ERROR)
  441. {
  442. return dwErr;
  443. }
  444. // If F&P is being unchecked, then popup the mmc warning
  445. //
  446. if ((dwId == NETCFGDB_ID_FILEPRINT) &&
  447. (bEnable == FALSE) &&
  448. (bEnabled == TRUE))
  449. {
  450. // Ask the user whether we should bring up the
  451. // mmc console to allow him/her to stop FPS.
  452. //
  453. MsgArgs.apszArgs[0] = pszName;
  454. MsgArgs.dwFlags = MB_YESNO;
  455. iRet = MsgDlgUtil(
  456. GetActiveWindow(),
  457. SID_STOP_FP_SERVICE,
  458. &MsgArgs,
  459. Globals.hInstDll,
  460. WRN_TITLE);
  461. // If the user agrees, bring up the console
  462. //
  463. if (iRet == IDYES)
  464. {
  465. dwErr = RassrvLaunchMMC(RASSRVUI_SERVICESCONSOLE);
  466. if (dwErr != NO_ERROR)
  467. {
  468. return dwErr;
  469. }
  470. }
  471. }
  472. // If F&P is not being unchecked, treat the component
  473. // normally.
  474. //
  475. else
  476. {
  477. // Update the check
  478. dwErr = netDbSetEnable(hNetCompDatabase, dwIndex, bEnable);
  479. if (dwErr != NO_ERROR)
  480. {
  481. return dwErr;
  482. }
  483. }
  484. return NO_ERROR;
  485. }
  486. //
  487. // Adds networking components
  488. //
  489. DWORD
  490. NetTabAddComponent(
  491. IN HWND hwndDlg)
  492. {
  493. HANDLE hNetCompDatabase = NULL;
  494. DWORD dwErr;
  495. RasSrvGetDatabaseHandle(
  496. hwndDlg,
  497. ID_NETCOMP_DATABASE,
  498. &hNetCompDatabase);
  499. dwErr = netDbRaiseInstallDialog(hNetCompDatabase, hwndDlg);
  500. if (dwErr == NO_ERROR || dwErr == NETCFG_S_REBOOT)
  501. {
  502. HWND hwndLVComp = GetDlgItem(hwndDlg, CID_NetTab_LV_Components);
  503. if (hwndLVComp)
  504. {
  505. NetTabRefreshListView(hwndLVComp, hNetCompDatabase);
  506. }
  507. NetTabDisableRollback(hwndDlg);
  508. }
  509. if (dwErr == NETCFG_S_REBOOT)
  510. {
  511. RasSrvReboot(hwndDlg);
  512. }
  513. return dwErr;
  514. }
  515. //
  516. // Removes networking components
  517. //
  518. DWORD
  519. NetTabRemoveComponent(
  520. IN HWND hwndDlg,
  521. IN DWORD dwIndex)
  522. {
  523. HANDLE hNetCompDatabase = NULL;
  524. DWORD dwCount, dwErr;
  525. RasSrvGetDatabaseHandle(
  526. hwndDlg,
  527. ID_NETCOMP_DATABASE,
  528. &hNetCompDatabase);
  529. // or else, remove the requested component
  530. //
  531. dwErr = netDbRaiseRemoveDialog(
  532. hNetCompDatabase,
  533. dwIndex,
  534. hwndDlg);
  535. if (dwErr == NO_ERROR || dwErr == NETCFG_S_REBOOT)
  536. {
  537. HWND hwndLVComp = GetDlgItem(hwndDlg, CID_NetTab_LV_Components);
  538. if (hwndLVComp)
  539. {
  540. NetTabRefreshListView(hwndLVComp, hNetCompDatabase);
  541. }
  542. NetTabDisableRollback(hwndDlg);
  543. }
  544. if (dwErr == NETCFG_S_REBOOT)
  545. {
  546. RasSrvReboot(hwndDlg);
  547. }
  548. return dwErr;
  549. }
  550. // Edits network component properties
  551. //
  552. DWORD
  553. NetTabEditProperties(
  554. IN HWND hwndDlg,
  555. IN DWORD dwIndex)
  556. {
  557. HANDLE hNetCompDatabase = NULL;
  558. DWORD dwCount, dwErr;
  559. RasSrvGetDatabaseHandle(
  560. hwndDlg,
  561. ID_NETCOMP_DATABASE,
  562. &hNetCompDatabase);
  563. dwErr = netDbRaisePropertiesDialog (
  564. hNetCompDatabase,
  565. dwIndex,
  566. hwndDlg);
  567. if (dwErr == NETCFG_S_REBOOT)
  568. {
  569. RasSrvReboot(hwndDlg);
  570. }
  571. return dwErr;
  572. }
  573. //
  574. // Switch to mmc
  575. //
  576. DWORD
  577. NetTabSwitchToMMC(
  578. IN HWND hwndDlg)
  579. {
  580. if (RassrvWarnMMCSwitch(hwndDlg))
  581. {
  582. // Commit the changes to this property sheet
  583. // and close it
  584. PropSheet_PressButton(GetParent(hwndDlg), PSBTN_OK);
  585. return RassrvLaunchMMC(RASSRVUI_NETWORKCONSOLE);
  586. }
  587. return ERROR_CANCELLED;
  588. }
  589. //
  590. // Handles the activation call
  591. //
  592. BOOL
  593. NetTabSetActive(
  594. IN HWND hwndDlg,
  595. IN WPARAM wParam)
  596. {
  597. HANDLE hNetCompDatabase = NULL;
  598. DWORD dwErr;
  599. BOOL bRet = FALSE;
  600. PropSheet_SetWizButtons(GetParent(hwndDlg), 0);
  601. RasSrvGetDatabaseHandle(
  602. hwndDlg,
  603. ID_NETCOMP_DATABASE,
  604. &hNetCompDatabase);
  605. if (! netDbIsLoaded(hNetCompDatabase))
  606. {
  607. dwErr = netDbLoad(hNetCompDatabase);
  608. if (dwErr == NO_ERROR)
  609. {
  610. NetTabInitializeDialog(
  611. hwndDlg,
  612. wParam);
  613. }
  614. else
  615. {
  616. NetTabDisplayError(
  617. hwndDlg,
  618. ERR_CANT_SHOW_NETTAB_INETCFG);
  619. // reject activation
  620. SetWindowLongPtr(
  621. hwndDlg,
  622. DWLP_MSGRESULT,
  623. -1);
  624. bRet = TRUE;
  625. }
  626. }
  627. PropSheet_SetWizButtons(
  628. GetParent(hwndDlg),
  629. PSWIZB_NEXT | PSWIZB_BACK);
  630. return bRet;
  631. }
  632. //
  633. // When the net tab receives WM_ACTIVATE, it means that
  634. // the user left the IC property sheet/wizard and is now coming back
  635. // to it. Since this occurs when switching to MMC update the UI as
  636. // here appropriate.
  637. //
  638. DWORD
  639. NetTabActivate(
  640. IN HWND hwndDlg,
  641. IN WPARAM wParam)
  642. {
  643. HANDLE hNetCompDatabase = NULL;
  644. DWORD dwErr = NO_ERROR;
  645. HWND hwndLVComp;
  646. if (LOWORD(wParam) == WA_INACTIVE)
  647. {
  648. return NO_ERROR;
  649. }
  650. DbgOutputTrace("NetTabActivate: updating components.");
  651. // Get the database handle
  652. //
  653. dwErr = RasSrvGetDatabaseHandle(
  654. hwndDlg,
  655. ID_NETCOMP_DATABASE,
  656. &hNetCompDatabase);
  657. if (dwErr != NO_ERROR)
  658. {
  659. return dwErr;
  660. }
  661. // Update the appropriate components
  662. //
  663. dwErr = netDbReloadComponent(hNetCompDatabase, NETCFGDB_ID_FILEPRINT);
  664. if (dwErr != NO_ERROR)
  665. {
  666. return dwErr;
  667. }
  668. // Refresh the net component list view
  669. //
  670. hwndLVComp = GetDlgItem(hwndDlg, CID_NetTab_LV_Components);
  671. if (hwndLVComp)
  672. {
  673. NetTabRefreshListView(hwndLVComp,hNetCompDatabase);
  674. }
  675. return NO_ERROR;
  676. }
  677. //
  678. // Handles commands
  679. //
  680. DWORD
  681. NetTabCommand(
  682. IN HWND hwndDlg,
  683. IN WPARAM wParam)
  684. {
  685. HWND hwndControl = NULL;
  686. switch (wParam)
  687. {
  688. case CID_NetTab_PB_Properties:
  689. hwndControl = GetDlgItem(hwndDlg, CID_NetTab_LV_Components);
  690. if (hwndControl)
  691. {
  692. NetTabEditProperties(hwndDlg, ListView_GetSelectionMark(hwndControl));
  693. }
  694. break;
  695. case CID_NetTab_PB_Add:
  696. NetTabAddComponent(hwndDlg);
  697. break;
  698. case CID_NetTab_PB_Remove:
  699. hwndControl = GetDlgItem(hwndDlg, CID_NetTab_LV_Components);
  700. if (hwndControl)
  701. {
  702. NetTabRemoveComponent(hwndDlg, ListView_GetSelectionMark(hwndControl));
  703. }
  704. break;
  705. case CID_NetTab_PB_SwitchToMMC:
  706. NetTabSwitchToMMC(hwndDlg);
  707. break;
  708. }
  709. return NO_ERROR;
  710. }
  711. //
  712. // This is the dialog procedure that responds to messages sent
  713. // to the networking tab.
  714. //
  715. INT_PTR
  716. CALLBACK
  717. NetTabDialogProc(
  718. HWND hwndDlg,
  719. UINT uMsg,
  720. WPARAM wParam,
  721. LPARAM lParam)
  722. {
  723. // Filter the customized list view messages
  724. if (ListView_OwnerHandler(
  725. hwndDlg,
  726. uMsg,
  727. wParam,
  728. lParam,
  729. LvDrawInfoCallback )
  730. )
  731. {
  732. return TRUE;
  733. }
  734. // Filter the customized ras server ui page messages.
  735. // By filtering messages through here, we are able to
  736. // call RasSrvGetDatabaseHandle below
  737. //
  738. if (RasSrvMessageFilter(hwndDlg, uMsg, wParam, lParam))
  739. {
  740. return TRUE;
  741. }
  742. switch (uMsg)
  743. {
  744. case WM_INITDIALOG:
  745. return 0;
  746. case WM_HELP:
  747. case WM_CONTEXTMENU:
  748. {
  749. RasSrvHelp (hwndDlg, uMsg, wParam, lParam, phmNetTab);
  750. break;
  751. }
  752. case WM_NOTIFY:
  753. {
  754. NMHDR* pNotifyData;
  755. NM_LISTVIEW* pLvNotifyData;
  756. pNotifyData = (NMHDR*)lParam;
  757. switch (pNotifyData->code)
  758. {
  759. //
  760. // Note: PSN_APPLY and PSN_CANCEL are handled
  761. // by RasSrvMessageFilter
  762. //
  763. // The item focus is changing -- update the
  764. // protocol description
  765. case LVN_ITEMCHANGING:
  766. pLvNotifyData = (NM_LISTVIEW*)lParam;
  767. if (pLvNotifyData->uNewState & LVIS_SELECTED)
  768. {
  769. NetTabUpdateDescription(
  770. hwndDlg,
  771. pLvNotifyData->iItem);
  772. NetTabEnableDisablePropButton(
  773. hwndDlg,
  774. pLvNotifyData->iItem);
  775. //for whistler bug 347355 gangz
  776. //
  777. NetTabEnableDisableRemoveButton (
  778. hwndDlg,
  779. (DWORD)pLvNotifyData->iItem);
  780. }
  781. break;
  782. // The check of an item is changing
  783. case LVXN_SETCHECK:
  784. pLvNotifyData = (NM_LISTVIEW*)lParam;
  785. NetTabHandleProtCheck(
  786. hwndDlg,
  787. (DWORD)pLvNotifyData->iItem);
  788. break;
  789. case LVXN_DBLCLK:
  790. pLvNotifyData = (NM_LISTVIEW*)lParam;
  791. NetTabEditProperties(
  792. hwndDlg,
  793. pLvNotifyData->iItem);
  794. break;
  795. // The networking tab is becoming active.
  796. // Attempt to load the netcfg database at
  797. // this time. If unsuccessful, pop up a
  798. // message and don't allow the activation.
  799. case PSN_SETACTIVE:
  800. return NetTabSetActive(hwndDlg, wParam);
  801. break;
  802. }
  803. }
  804. break;
  805. case WM_ACTIVATE:
  806. NetTabActivate(hwndDlg, wParam);
  807. break;
  808. case WM_COMMAND:
  809. NetTabCommand(hwndDlg, wParam);
  810. break;
  811. }
  812. return FALSE;
  813. }