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.

1200 lines
30 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. // All rights reserved.
  5. //
  6. // File Name:
  7. // lanwiz.c
  8. //
  9. // Description:
  10. // This file contains the dialog procedure for the custom networking
  11. // page (IDD_LANWIZ_DLG).
  12. //
  13. // This is the primary page for custom networking, all other networking
  14. // pages come initially from this page.
  15. //
  16. //----------------------------------------------------------------------------
  17. #include "pch.h"
  18. #include "resource.h"
  19. static UINT iCurrentSelection;
  20. static TCHAR *StrNetworkCardNumber;
  21. //----------------------------------------------------------------------------
  22. //
  23. // Function: UpdateListView
  24. //
  25. // Purpose: clears all the entries in the list view and adds the items
  26. // in the Network Component List that have the installed flag on
  27. //
  28. // Arguments: IN HWND hwnd - handle to the dialog box
  29. //
  30. // Returns: VOID
  31. //
  32. //----------------------------------------------------------------------------
  33. VOID
  34. UpdateListView( IN HWND hwnd ) {
  35. NETWORK_COMPONENT *pNetComponent;
  36. SendDlgItemMessage( hwnd,
  37. IDC_LVW_COMPLIST,
  38. LVM_DELETEALLITEMS,
  39. (WPARAM) 0,
  40. (LPARAM) 0 );
  41. for( pNetComponent = NetSettings.NetComponentsList;
  42. pNetComponent;
  43. pNetComponent = pNetComponent->next )
  44. {
  45. if( pNetComponent->bInstalled == TRUE )
  46. {
  47. //
  48. // Make sure we are installing workstation and server components
  49. // correctly. If this isn't one that should be added, continue
  50. // on to the next one.
  51. //
  52. if( WizGlobals.iPlatform == PLATFORM_PERSONAL )
  53. {
  54. if( ! (pNetComponent->dwPlatforms & PERSONAL_INSTALL) )
  55. {
  56. continue;
  57. }
  58. }
  59. else if( WizGlobals.iPlatform == PLATFORM_WORKSTATION )
  60. {
  61. if( ! (pNetComponent->dwPlatforms & WORKSTATION_INSTALL) )
  62. {
  63. continue;
  64. }
  65. }
  66. else if( WizGlobals.iPlatform == PLATFORM_SERVER || WizGlobals.iPlatform == PLATFORM_ENTERPRISE || WizGlobals.iPlatform == PLATFORM_WEBBLADE)
  67. {
  68. if( ! (pNetComponent->dwPlatforms & SERVER_INSTALL) )
  69. {
  70. continue;
  71. }
  72. }
  73. else
  74. {
  75. AssertMsg( FALSE,
  76. "Invalid platform type." );
  77. }
  78. //
  79. // If it is not a sysprep then just go ahead and add it to the
  80. // list view. If we are doing a sysprep, check to see if this
  81. // component is supported by sysprep to see if we should add it
  82. // or not
  83. //
  84. if( WizGlobals.iProductInstall == PRODUCT_SYSPREP )
  85. {
  86. if( pNetComponent->bSysprepSupport )
  87. {
  88. InsertEntryIntoListView( GetDlgItem( hwnd, IDC_LVW_COMPLIST ),
  89. (LPARAM) pNetComponent );
  90. }
  91. else
  92. {
  93. //
  94. // If it is not supported by sysprep, then don't install it
  95. //
  96. pNetComponent->bInstalled = FALSE;
  97. }
  98. }
  99. else
  100. {
  101. InsertEntryIntoListView( GetDlgItem( hwnd, IDC_LVW_COMPLIST ),
  102. (LPARAM) pNetComponent );
  103. }
  104. }
  105. }
  106. }
  107. //----------------------------------------------------------------------------
  108. //
  109. // Function: GetListViewIndex
  110. //
  111. // Purpose: returns the entry in the list view with the controlID specified by
  112. // the index
  113. //
  114. // Arguments: IN HWND hwnd - handle to the dialog the list view is in
  115. // IN WORD controlID - resource ID of the list view
  116. // IN INT index - index in the list view of the item to grab
  117. //
  118. // Returns: a pointer to the item in the list view at the location specified by
  119. // the IN parameter index
  120. //
  121. //----------------------------------------------------------------------------
  122. NETWORK_COMPONENT*
  123. GetListViewIndex( IN HWND hwnd,
  124. IN WORD controlID,
  125. IN INT index ) {
  126. LVITEM lvI;
  127. memset( &lvI, 0, sizeof(LVITEM) );
  128. lvI.iItem = index;
  129. lvI.mask = LVIF_PARAM;
  130. SendDlgItemMessage( hwnd,
  131. controlID,
  132. LVM_GETITEM,
  133. (WPARAM) 0,
  134. (LPARAM) &lvI );
  135. return (NETWORK_COMPONENT *)lvI.lParam ;
  136. }
  137. //----------------------------------------------------------------------------
  138. //
  139. // Function: SetListViewSelection
  140. //
  141. // Purpose: sets the selection in the list view (specified by controlID) to
  142. // the position specified
  143. //
  144. // Arguments: IN HWND hDlg -
  145. // IN WORD controlID -
  146. // IN INT position -
  147. //
  148. // Returns: VOID
  149. //
  150. //----------------------------------------------------------------------------
  151. VOID
  152. SetListViewSelection( IN HWND hDlg, IN WORD controlID, IN INT position ) {
  153. HWND hListViewWnd;
  154. // get a handle to the list view window
  155. hListViewWnd = GetDlgItem( hDlg, controlID );
  156. ListView_SetItemState( hListViewWnd,
  157. position,
  158. LVIS_SELECTED | LVIS_FOCUSED,
  159. LVIS_SELECTED | LVIS_FOCUSED ) ;
  160. }
  161. //----------------------------------------------------------------------------
  162. //
  163. // Function: SetDescription
  164. //
  165. // Purpose:
  166. //
  167. // Arguments:
  168. //
  169. // Returns:
  170. //
  171. //----------------------------------------------------------------------------
  172. VOID
  173. SetDescription( HWND hwnd, INT index ) {
  174. INT_PTR iListViewCount;
  175. NETWORK_COMPONENT* tempEntry;
  176. tempEntry = GetListViewIndex( hwnd, IDC_LVW_COMPLIST, index );
  177. iListViewCount = SendDlgItemMessage( hwnd,
  178. IDC_LVW_COMPLIST,
  179. LVM_GETITEMCOUNT,
  180. 0,
  181. 0 );
  182. //
  183. // if there are no entries, then clear the description box
  184. // else display the description
  185. //
  186. if( iListViewCount == 0 ) {
  187. SendDlgItemMessage( hwnd,
  188. IDC_TXT_COMPDESC,
  189. WM_SETTEXT,
  190. (WPARAM) 0,
  191. (LPARAM) _T("") );
  192. }
  193. else {
  194. SendDlgItemMessage( hwnd,
  195. IDC_TXT_COMPDESC,
  196. WM_SETTEXT,
  197. (WPARAM) 0,
  198. (LPARAM) tempEntry->StrComponentDescription );
  199. }
  200. }
  201. //----------------------------------------------------------------------------
  202. //
  203. // Function: GetSelectedItemFromListView
  204. //
  205. // Purpose: searches through the List View specified by controlID
  206. // returns the found item in the lvI parameter
  207. //
  208. // Arguments:
  209. //
  210. // Returns: function returns TRUE if there was an item selected and it
  211. // found it,
  212. // FALSE if there was no item selected
  213. //
  214. //----------------------------------------------------------------------------
  215. BOOL
  216. GetSelectedItemFromListView( HWND hwndDlg, WORD controlID, LVITEM* lvI )
  217. {
  218. INT i;
  219. INT iCount;
  220. HWND hListView = GetDlgItem( hwndDlg, controlID );
  221. UINT uMask = LVIS_SELECTED | LVIS_FOCUSED;
  222. UINT uState;
  223. BOOL bSelectedItemFound = FALSE;
  224. iCount = ListView_GetItemCount( hListView );
  225. //
  226. // cycle through the list until the selected item is found
  227. //
  228. i = 0;
  229. while( !bSelectedItemFound && i < iCount )
  230. {
  231. uState = ListView_GetItemState( hListView, i, uMask );
  232. if( uState == uMask )
  233. {
  234. //
  235. // found the selected item
  236. //
  237. bSelectedItemFound = TRUE;
  238. memset( lvI, 0, sizeof( LVITEM ) );
  239. lvI->iItem = i;
  240. lvI->mask = LVIF_PARAM;
  241. ListView_GetItem( hListView, lvI );
  242. return( TRUE );
  243. }
  244. i++;
  245. }
  246. return( FALSE );
  247. }
  248. //----------------------------------------------------------------------------
  249. //
  250. // Function: InsertEntryIntoListView
  251. //
  252. // Purpose:
  253. //
  254. // Arguments:
  255. //
  256. // Returns:
  257. //
  258. //----------------------------------------------------------------------------
  259. BOOL
  260. InsertEntryIntoListView( HWND hListViewWnd,
  261. LPARAM lParam )
  262. {
  263. LVITEM lvI;
  264. NETWORK_COMPONENT *pListViewEntry = (NETWORK_COMPONENT *)lParam;
  265. lvI.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE;
  266. lvI.iItem = 0;
  267. lvI.iSubItem = 0;
  268. lvI.pszText = LPSTR_TEXTCALLBACK;
  269. lvI.cchTextMax = MAX_ITEMLEN;
  270. lvI.lParam = lParam;
  271. lvI.state = LVIS_SELECTED | LVIS_FOCUSED;
  272. lvI.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
  273. lvI.iImage = 0;
  274. switch( pListViewEntry->ComponentType ) {
  275. case CLIENT: lvI.iImage = 0; break;
  276. case SERVICE: lvI.iImage = 1; break;
  277. case PROTOCOL: lvI.iImage = 2; break;
  278. }
  279. if ( ListView_InsertItem( hListViewWnd, &lvI ) == -1 )
  280. return( FALSE );
  281. ListView_SortItems( hListViewWnd, ListViewCompareFunc, (LPARAM)NULL );
  282. return( TRUE );
  283. }
  284. //----------------------------------------------------------------------------
  285. //
  286. // Function: InitListView
  287. //
  288. // Purpose:
  289. //
  290. // Arguments:
  291. //
  292. // Returns:
  293. //
  294. //----------------------------------------------------------------------------
  295. BOOL
  296. InitListView( HWND hDlg, HINSTANCE hInst ) {
  297. HICON hIcon1, hIcon2, hIcon3; // handles to icons
  298. HIMAGELIST hSmall; // handle to image list for small icons
  299. LVCOLUMN lvCol;
  300. RECT rect;
  301. //
  302. // Initialize the list view window
  303. // First initialize the image lists you will need:
  304. // create image list for the small icons
  305. //
  306. hSmall = ImageList_Create( BITMAP_WIDTH, BITMAP_HEIGHT, ILC_MASK, 3, 0 );
  307. //
  308. // Load the icons and add them to the image list
  309. //
  310. hIcon1 = LoadIcon( hInst, MAKEINTRESOURCE(IDI_CLIENT) );
  311. hIcon2 = LoadIcon( hInst, MAKEINTRESOURCE(IDI_SERVICE) );
  312. hIcon3 = LoadIcon( hInst, MAKEINTRESOURCE(IDI_PROTOCOL) );
  313. if( ImageList_AddIcon(hSmall, hIcon1) == -1 )
  314. return( FALSE );
  315. if( ImageList_AddIcon(hSmall, hIcon2) == -1 )
  316. return( FALSE );
  317. if( ImageList_AddIcon(hSmall, hIcon3) == -1 )
  318. return( FALSE );
  319. // Be sure that all the icons were added
  320. if ( ImageList_GetImageCount( hSmall ) < 3 )
  321. return( FALSE );
  322. // Associate the image list with the list view control
  323. SendDlgItemMessage( hDlg,
  324. IDC_LVW_COMPLIST,
  325. LVM_SETIMAGELIST,
  326. (WPARAM) LVSIL_SMALL,
  327. (LPARAM) hSmall );
  328. //
  329. // Using a "Report" list view so make it 1 column that is the width of
  330. // the list view
  331. //
  332. GetClientRect( GetDlgItem( hDlg, IDC_LVW_COMPLIST ),
  333. &rect );
  334. SendDlgItemMessage( hDlg,
  335. IDC_LVW_COMPLIST,
  336. LVM_SETCOLUMNWIDTH,
  337. (WPARAM) 0,
  338. (LPARAM) rect.right );
  339. // The mask specifies that the fmt, width and pszText members
  340. // of the structure are valid
  341. lvCol.mask = LVCF_FMT | LVCF_WIDTH;
  342. lvCol.fmt = LVCFMT_LEFT; // left-align column
  343. lvCol.cx = rect.right; // width of column in pixels
  344. SendDlgItemMessage( hDlg,
  345. IDC_LVW_COMPLIST,
  346. LVM_INSERTCOLUMN,
  347. (WPARAM) 0,
  348. (LPARAM) &lvCol );
  349. iCurrentSelection = 0;
  350. return( TRUE );
  351. }
  352. //----------------------------------------------------------------------------
  353. //
  354. // Function: SetNetworkNumberText
  355. //
  356. // Purpose: Changes the caption of Network card # text so the user knows what
  357. // network card he is currently changing settings for
  358. //
  359. // Arguments:
  360. //
  361. // Returns:
  362. //
  363. //----------------------------------------------------------------------------
  364. VOID
  365. SetNetworkNumberText( IN HWND hwnd, IN INT iCmdShow )
  366. {
  367. HWND hNumNetworkCards;
  368. TCHAR szNetNumber[3]; // 3 so it holds up to a 2 digit string
  369. TCHAR szTempString[MAX_STRING_LEN];
  370. HRESULT hrCat;
  371. hNumNetworkCards = GetDlgItem( hwnd, IDC_NETWORKCARDNUM );
  372. //
  373. // Convert network card int to string
  374. //
  375. _itow( NetSettings.iCurrentNetworkCard, szNetNumber, 10 );
  376. //
  377. // copy "Network Adapter #" string into szTempString
  378. // szTempString is the string being built up that will be displayed
  379. // as the new caption
  380. //
  381. lstrcpyn( szTempString, StrNetworkCardNumber, AS(szTempString) );
  382. //
  383. // concat the current network card number to the rest of the string
  384. //
  385. hrCat=StringCchCat( szTempString, AS(szTempString), szNetNumber );
  386. SetWindowText( hNumNetworkCards, szTempString );
  387. ShowWindow( hNumNetworkCards, iCmdShow );
  388. }
  389. //----------------------------------------------------------------------------
  390. //
  391. // Function: ShowPlugAndPlay
  392. //
  393. // Purpose: Displays Plug and Play box, if necessary
  394. // if the box is displayed then it fills it with the proper data
  395. //
  396. // Arguments:
  397. //
  398. // Returns:
  399. //
  400. //----------------------------------------------------------------------------
  401. static VOID
  402. ShowPlugAndPlay( IN HWND hwnd,
  403. IN BOOL bShowNetworkText,
  404. IN BOOL bShowEditBox )
  405. {
  406. HWND hPlugAndPlayText = GetDlgItem( hwnd, IDC_PLUGANDPLAYTEXT );
  407. HWND hPlugAndPlayEditBox = GetDlgItem( hwnd, IDC_PLUGANDPLAY_ID );
  408. AssertMsg( NetSettings.pCurrentAdapter != NULL,
  409. "The current network card is null but there are more network cards left." );
  410. //
  411. // Show or hide the Network adapter text and make sure it is displaying
  412. // the right number for the network card.
  413. //
  414. if( bShowNetworkText )
  415. {
  416. //
  417. // change the text to display which network card the user is
  418. // currently on
  419. //
  420. SetNetworkNumberText( hwnd , SW_SHOW );
  421. SetWindowText( hPlugAndPlayEditBox,
  422. NetSettings.pCurrentAdapter->szPlugAndPlayID );
  423. }
  424. else
  425. {
  426. SetNetworkNumberText( hwnd, SW_HIDE );
  427. }
  428. //
  429. // Show or hide the static Plug and Play text and edit box
  430. //
  431. if( bShowEditBox )
  432. {
  433. ShowWindow(hPlugAndPlayText, SW_SHOW );
  434. ShowWindow(hPlugAndPlayEditBox, SW_SHOW );
  435. }
  436. else
  437. {
  438. ShowWindow( hPlugAndPlayText, SW_HIDE );
  439. ShowWindow( hPlugAndPlayEditBox, SW_HIDE );
  440. }
  441. }
  442. //----------------------------------------------------------------------------
  443. //
  444. // Function: FindNode
  445. //
  446. // Purpose: iterate throught the global net component list until the Node
  447. // where the component position matches the iPosition parameter
  448. // return a pointer to this node
  449. // if the node is not found, return NULL
  450. //
  451. // Arguments: INT iPosition - position to return a pointer to in the list
  452. //
  453. // Returns: Pointer to the NETWORK_COMPONENT if found
  454. // NULL if not found
  455. //
  456. //----------------------------------------------------------------------------
  457. NETWORK_COMPONENT*
  458. FindNode( IN INT iPosition )
  459. {
  460. NETWORK_COMPONENT *pNetComponent;
  461. for( pNetComponent = NetSettings.NetComponentsList;
  462. pNetComponent;
  463. pNetComponent = pNetComponent->next )
  464. {
  465. if( pNetComponent->iPosition == iPosition )
  466. {
  467. return( pNetComponent );
  468. }
  469. }
  470. return( NULL );
  471. }
  472. //----------------------------------------------------------------------------
  473. //
  474. // Function: PropertiesHandler
  475. //
  476. // Purpose: called to handle when either the properties button is pushed or
  477. // an item in the list view is double clicked
  478. //
  479. // Arguments:
  480. //
  481. // Returns: VOID
  482. //
  483. //----------------------------------------------------------------------------
  484. VOID
  485. PropertiesHandler( IN HWND hDlg )
  486. {
  487. LVITEM lvI;
  488. NETWORK_COMPONENT *entry;
  489. if( GetSelectedItemFromListView( hDlg, IDC_LVW_COMPLIST, &lvI ) ) {
  490. entry = (NETWORK_COMPONENT *)lvI.lParam;
  491. // if the dialog box has properties, find the right dialog to pop-up
  492. if( entry->bHasPropertiesTab ) {
  493. switch( entry->iPosition ) {
  494. case TCPIP_POSITION:
  495. Create_TCPIP_PropertySheet( hDlg ); break;
  496. case MS_CLIENT_POSITION:
  497. Create_MSClient_PropertySheet( hDlg ); break;
  498. case IPX_POSITION:
  499. Create_MS_NWIPX_PropertySheet( hDlg ); break;
  500. case APPLETALK_POSITION:
  501. Create_Appletalk_PropertySheet( hDlg ); break;
  502. case NETWARE_CLIENT_POSITION:
  503. case GATEWAY_FOR_NETWARE_POSITION:
  504. DialogBox( FixedGlobals.hInstance,
  505. (LPCTSTR) IDD_NWC_WINNT_DLG,
  506. hDlg,
  507. DlgNetwarePage );
  508. break;
  509. default:
  510. AssertMsg( FALSE,
  511. "Bad Switch Case: Entry has Properties but no corresponding Property Sheet" );
  512. break;
  513. }
  514. }
  515. }
  516. }
  517. //----------------------------------------------------------------------------
  518. //
  519. // Function: ListViewHandler
  520. //
  521. // Purpose:
  522. //
  523. // Arguments:
  524. //
  525. // Returns: VOID
  526. //
  527. //----------------------------------------------------------------------------
  528. VOID
  529. ListViewHandler( IN HWND hwnd, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam )
  530. {
  531. LV_DISPINFO *pLvdi = (LV_DISPINFO *)lParam;
  532. NM_LISTVIEW *pNm = (NM_LISTVIEW *)lParam;
  533. NETWORK_COMPONENT *pListViewEntry;
  534. HWND hPropertiesButton;
  535. pListViewEntry = (NETWORK_COMPONENT *)(pLvdi->item.lParam);
  536. switch( pLvdi->hdr.code )
  537. {
  538. case LVN_GETDISPINFO:
  539. {
  540. pLvdi->item.pszText = pListViewEntry->StrComponentName;
  541. break;
  542. }
  543. }
  544. switch( pNm->hdr.code )
  545. {
  546. case NM_DBLCLK:
  547. {
  548. NMITEMACTIVATE *pNmItemActivate = (NMITEMACTIVATE *) lParam;
  549. //
  550. // see if the user has double clicked inside the list view
  551. //
  552. if( pNm->hdr.idFrom == IDC_LVW_COMPLIST )
  553. {
  554. //
  555. // Make sure they actually clicked on an item and not just
  556. // empty space
  557. //
  558. if( pNmItemActivate->iItem != -1 )
  559. {
  560. PropertiesHandler( hwnd );
  561. }
  562. }
  563. break;
  564. }
  565. case LVN_ITEMCHANGED:
  566. // test to see if a new item in the list has been selected
  567. if( pNm->uNewState == SELECTED )
  568. {
  569. LVITEM lvI;
  570. NETWORK_COMPONENT* currentEntry;
  571. if( ! GetSelectedItemFromListView( hwnd,
  572. IDC_LVW_COMPLIST,
  573. &lvI ) )
  574. {
  575. return;
  576. }
  577. currentEntry = (NETWORK_COMPONENT *)lvI.lParam;
  578. iCurrentSelection = lvI.iItem;
  579. SetDescription( hwnd, lvI.iItem );
  580. // enable or disable the properties button based on their
  581. // selection in the list view
  582. hPropertiesButton = GetDlgItem( hwnd, IDC_PSH_PROPERTIES );
  583. if( currentEntry->bHasPropertiesTab )
  584. {
  585. EnableWindow( hPropertiesButton, TRUE );
  586. }
  587. else
  588. {
  589. EnableWindow( hPropertiesButton, FALSE );
  590. }
  591. }
  592. break;
  593. }
  594. }
  595. //----------------------------------------------------------------------------
  596. //
  597. // Function: OnLANWizNext
  598. //
  599. // Purpose:
  600. //
  601. // Arguments: IN HWND hwnd - handle to the dialog box
  602. //
  603. // Returns: VOID
  604. //
  605. //----------------------------------------------------------------------------
  606. VOID
  607. OnLANWizNext( IN HWND hwnd )
  608. {
  609. if ( IsDlgButtonChecked(hwnd, IDC_CUSTOMNET) == BST_CHECKED )
  610. NetSettings.iNetworkingMethod = CUSTOM_NETWORKING;
  611. else
  612. NetSettings.iNetworkingMethod = TYPICAL_NETWORKING;
  613. }
  614. //----------------------------------------------------------------------------
  615. //
  616. // Function: EnableWindows
  617. //
  618. // Purpose: Enable/Disable windows based on the current selection
  619. //
  620. //
  621. // Arguments: handle to the main window
  622. //
  623. // Returns: none
  624. //
  625. //----------------------------------------------------------------------------
  626. EnableControls( IN HWND hwnd )
  627. {
  628. BOOL fEnable = ( IsDlgButtonChecked(hwnd, IDC_CUSTOMNET) == BST_CHECKED );
  629. EnableWindow(GetDlgItem(hwnd, IDC_LVW_COMPLIST), fEnable);
  630. EnableWindow(GetDlgItem(hwnd, IDC_PSH_ADD), fEnable);
  631. EnableWindow(GetDlgItem(hwnd, IDC_PSH_REMOVE), fEnable);
  632. EnableWindow(GetDlgItem(hwnd, IDC_PSH_PROPERTIES), fEnable);
  633. EnableWindow(GetDlgItem(hwnd, IDC_TXT_COMPDESC), fEnable);
  634. EnableWindow(GetDlgItem(hwnd, IDC_DESCRIPTION), fEnable);
  635. }
  636. //----------------------------------------------------------------------------
  637. //
  638. // Function: OnLANWizSetActive
  639. //
  640. // Purpose:
  641. //
  642. // Arguments: IN HWND hwnd - handle to the dialog box
  643. //
  644. // Returns: VOID
  645. //
  646. //----------------------------------------------------------------------------
  647. VOID
  648. OnLANWizSetActive( IN HWND hwnd )
  649. {
  650. UpdateListView( hwnd );
  651. //
  652. // set the selection in the list view to the first item
  653. //
  654. SetListViewSelection( hwnd, IDC_LVW_COMPLIST, 0 );
  655. //
  656. // set the description because it might have changed with the new item
  657. // being added
  658. //
  659. SetDescription( hwnd, 0 );
  660. // Check to proper default button
  661. //
  662. if ( NetSettings.iNetworkingMethod == CUSTOM_NETWORKING )
  663. CheckRadioButton( hwnd, IDC_TYPICALNET, IDC_CUSTOMNET, IDC_CUSTOMNET );
  664. else
  665. CheckRadioButton( hwnd, IDC_TYPICALNET, IDC_CUSTOMNET, IDC_TYPICALNET );
  666. // Enable the controls
  667. //
  668. EnableControls(hwnd);
  669. WIZ_BUTTONS(hwnd, PSWIZB_BACK | PSWIZB_NEXT );
  670. }
  671. //----------------------------------------------------------------------------
  672. //
  673. // Function: ListViewCompareFunc
  674. //
  675. // Purpose: sorts the list view by component type first
  676. // (Client < Service < Protocol) and within each component type,
  677. // sorts alphabetically
  678. //
  679. // Arguments:
  680. //
  681. // Returns:
  682. //
  683. //----------------------------------------------------------------------------
  684. INT CALLBACK
  685. ListViewCompareFunc( LPARAM lParam1,
  686. LPARAM lParam2,
  687. LPARAM lParamSort ) {
  688. NETWORK_COMPONENT *pEntry1 = (NETWORK_COMPONENT *)lParam1;
  689. NETWORK_COMPONENT *pEntry2 = (NETWORK_COMPONENT *)lParam2;
  690. //
  691. // sort by ComponentType first, and then alphabetically
  692. //
  693. if( pEntry1->ComponentType < pEntry2->ComponentType ) {
  694. return(-1);
  695. }
  696. else if( pEntry1->ComponentType > pEntry2->ComponentType ) {
  697. return(1);
  698. }
  699. // Component Types are equal so sort alphabetically
  700. else {
  701. return lstrcmpi( pEntry1->StrComponentName, pEntry2->StrComponentName ) ;
  702. }
  703. }
  704. //----------------------------------------------------------------------------
  705. //
  706. // Function: OnLANWizAdd
  707. //
  708. // Purpose:
  709. //
  710. // Arguments: standard Win32 dialog proc arguments, passed through from the
  711. // Dialog proc
  712. //
  713. // Returns: VOID
  714. //
  715. //----------------------------------------------------------------------------
  716. VOID
  717. OnLANWizAdd( IN HWND hwnd,
  718. IN UINT uMsg,
  719. IN WPARAM wParam,
  720. IN LPARAM lParam ) {
  721. if ( HIWORD( wParam ) == BN_CLICKED )
  722. {
  723. //
  724. // pop-up the new dialog box and if they actual add
  725. // an item make sure the Uninstall button is enabled
  726. //
  727. if( DialogBox( FixedGlobals.hInstance,
  728. (LPCTSTR) IDD_LAN_COMPONENT_ADD,
  729. hwnd,
  730. AddDeviceDlgProc) )
  731. {
  732. HWND hUninstallButton = GetDlgItem( hwnd, IDC_PSH_REMOVE );
  733. EnableWindow( hUninstallButton, TRUE );
  734. UpdateListView( hwnd );
  735. // set the selection in the list view
  736. // to the first item
  737. SetListViewSelection( hwnd, IDC_LVW_COMPLIST, 0 );
  738. // set the description because it might have
  739. // changed with the new item being added
  740. SetDescription( hwnd, 0 );
  741. }
  742. }
  743. }
  744. //----------------------------------------------------------------------------
  745. //
  746. // Function: OnLANWizRemove
  747. //
  748. // Purpose:
  749. //
  750. // Arguments: standard Win32 dialog proc arguments, passed through from the
  751. // Dialog proc
  752. //
  753. // Returns: VOID
  754. //
  755. //----------------------------------------------------------------------------
  756. VOID
  757. OnLANWizRemove( IN HWND hwnd,
  758. IN UINT uMsg,
  759. IN WPARAM wParam,
  760. IN LPARAM lParam ) {
  761. INT_PTR iListViewCount;
  762. if ( HIWORD( wParam ) == BN_CLICKED ) {
  763. //
  764. // remove the currently selected item from the list view
  765. //
  766. LVITEM lvI;
  767. NETWORK_COMPONENT* pNode;
  768. if( GetSelectedItemFromListView( hwnd,
  769. IDC_LVW_COMPLIST, &lvI ) ) {
  770. pNode = (NETWORK_COMPONENT *)lvI.lParam;
  771. pNode->bInstalled = FALSE;
  772. //
  773. // Update the list view to show the removed
  774. // component is gone
  775. //
  776. UpdateListView( hwnd );
  777. SetListViewSelection( hwnd, IDC_LVW_COMPLIST, 1 );
  778. SetDescription( hwnd, 0 );
  779. }
  780. iListViewCount = SendDlgItemMessage( hwnd,
  781. IDC_LVW_COMPLIST,
  782. LVM_GETITEMCOUNT,
  783. (WPARAM) 0,
  784. (LPARAM) 0 );
  785. // if there are no more items in the list view then grey out
  786. // the uninstall and properties button
  787. if( iListViewCount == 0 ) {
  788. HWND hUninstallButton = GetDlgItem( hwnd, IDC_PSH_REMOVE );
  789. HWND hPropertiesButton = GetDlgItem( hwnd, IDC_PSH_PROPERTIES );
  790. EnableWindow( hUninstallButton, FALSE );
  791. EnableWindow( hPropertiesButton, FALSE );
  792. }
  793. }
  794. }
  795. //----------------------------------------------------------------------------
  796. //
  797. // Function: OnLANWizProperties
  798. //
  799. // Purpose:
  800. //
  801. // Arguments: standard Win32 dialog proc arguments, passed through from the
  802. // Dialog proc
  803. //
  804. // Returns: VOID
  805. //
  806. //----------------------------------------------------------------------------
  807. VOID
  808. OnLANWizProperties( IN HWND hwnd,
  809. IN UINT uMsg,
  810. IN WPARAM wParam,
  811. IN LPARAM lParam ) {
  812. if ( HIWORD( wParam ) == BN_CLICKED ) {
  813. PropertiesHandler( hwnd );
  814. }
  815. }
  816. //----------------------------------------------------------------------------
  817. //
  818. // Function: OnLANWizInitDialog
  819. //
  820. // Purpose:
  821. //
  822. // Arguments: IN HWND hwnd - handle to the dialog box
  823. //
  824. // Returns: VOID
  825. //
  826. //----------------------------------------------------------------------------
  827. VOID
  828. OnLANWizInitDialog( IN HWND hwnd ) {
  829. INITCOMMONCONTROLSEX CommonControlsStruct;
  830. CommonControlsStruct.dwICC = ICC_INTERNET_CLASSES | ICC_LISTVIEW_CLASSES;
  831. CommonControlsStruct.dwSize = sizeof( INITCOMMONCONTROLSEX );
  832. // Ensure that the common control DLL has loaded the window classes
  833. // for the IP control and the ListView control
  834. InitCommonControlsEx( &CommonControlsStruct );
  835. //
  836. // Load strings from resources
  837. //
  838. StrNetworkCardNumber = MyLoadString( IDS_NETADAPTERNUMBER );
  839. InitListView( hwnd, FixedGlobals.hInstance );
  840. // Set the default description
  841. SetDescription( hwnd, 0 );
  842. }
  843. //----------------------------------------------------------------------------
  844. //
  845. // Function: DlgLANWizardPage
  846. //
  847. // Purpose: Dialog procedure for the LAN Wizard page. (The one that shows
  848. // what Client, Services, and Protocols are to be installed)
  849. //
  850. // Arguments: standard Win32 dialog proc arguments
  851. //
  852. // Returns: standard Win32 dialog proc return value
  853. //
  854. //----------------------------------------------------------------------------
  855. INT_PTR CALLBACK DlgLANWizardPage( IN HWND hwnd,
  856. IN UINT uMsg,
  857. IN WPARAM wParam,
  858. IN LPARAM lParam )
  859. {
  860. BOOL bStatus = TRUE;
  861. switch( uMsg ) {
  862. case WM_INITDIALOG: {
  863. OnLANWizInitDialog( hwnd );
  864. break;
  865. }
  866. case WM_COMMAND: {
  867. switch ( LOWORD(wParam) ) {
  868. case IDC_TYPICALNET:
  869. case IDC_CUSTOMNET:
  870. EnableControls(hwnd);
  871. break;
  872. case IDC_PSH_ADD:
  873. OnLANWizAdd( hwnd, uMsg, wParam, lParam );
  874. break;
  875. case IDC_PSH_REMOVE:
  876. OnLANWizRemove( hwnd, uMsg, wParam, lParam );
  877. break;
  878. case IDC_PSH_PROPERTIES:
  879. OnLANWizProperties( hwnd, uMsg, wParam, lParam );
  880. break;
  881. }
  882. break; // WM_COMMAND
  883. }
  884. case WM_NOTIFY: {
  885. LPNMHDR pnmh = (LPNMHDR)lParam;
  886. HWND hwndComponentDescription;
  887. if( wParam == IDC_LVW_COMPLIST ) {
  888. ListViewHandler( hwnd, uMsg, wParam, lParam );
  889. }
  890. else {
  891. switch( pnmh->code ) {
  892. case PSN_QUERYCANCEL:
  893. WIZ_CANCEL(hwnd);
  894. break;
  895. case PSN_SETACTIVE:
  896. g_App.dwCurrentHelp = IDH_NET_COMPS;
  897. OnLANWizSetActive( hwnd );
  898. break;
  899. case PSN_WIZBACK:
  900. break;
  901. case PSN_WIZNEXT:
  902. OnLANWizNext( hwnd );
  903. bStatus = FALSE;
  904. break;
  905. case PSN_HELP:
  906. WIZ_HELP();
  907. break;
  908. }
  909. }
  910. break;
  911. }
  912. default: {
  913. bStatus = FALSE;
  914. break;
  915. }
  916. }
  917. return( bStatus );
  918. }