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.

986 lines
26 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. // All rights reserved.
  5. //
  6. // File Name:
  7. // tcpip.c
  8. //
  9. // Description:
  10. // This file contains the dialog procedure for the base TCP/IP page
  11. // (IDD_TCP_IPADDR). Let's the user set DHCP or specific IPs or go to
  12. // Advanced TCP/IP settings.
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #include "resource.h"
  17. BOOL Create_TCPIPProp_PropertySheet( HWND hwndParent );
  18. BOOL ValidateIPAddress( IN TCHAR szIPAddress[] );
  19. BOOL ValidateSubnetMask( IN TCHAR szIPAddress[] );
  20. UINT CALLBACK TCPIP_PropertiesPageProc( HWND hwnd,
  21. UINT uMsg,
  22. LPPROPSHEETPAGE ppsp );
  23. INT_PTR CALLBACK TCPIP_PropertiesDlgProc( IN HWND hwnd,
  24. IN UINT uMsg,
  25. IN WPARAM wParam,
  26. IN LPARAM lParam );
  27. static PROPSHEETHEADER pshead;
  28. static PROPSHEETPAGE pspage;
  29. static const TCHAR Period = _T('.');
  30. //----------------------------------------------------------------------------
  31. //
  32. // Function: ValidatePage
  33. //
  34. // Purpose: tests to see if the contents of the TCP/IP page are valid ( to
  35. // see if it is safe to move off this page )
  36. //
  37. // Arguments: IN HWND hwnd - handle to the dialog
  38. //
  39. // Returns: BOOL - TRUE if all fields are valid
  40. // False if some are not valid
  41. //
  42. //----------------------------------------------------------------------------
  43. BOOL
  44. ValidatePage( IN HWND hwnd )
  45. {
  46. INT_PTR iNumBlankFields;
  47. DWORD dwIpValue;
  48. //
  49. // If using DHCP, then no need to check any of the settings
  50. //
  51. if( IsDlgButtonChecked( hwnd, IDC_IP_DHCP ) )
  52. {
  53. return( TRUE );
  54. }
  55. else
  56. {
  57. //
  58. // Check that the IP and Subnet mask fields are completely
  59. // filled-out. I only check these 2 fields because that is all the
  60. // system checks to get off this dialog.
  61. //
  62. iNumBlankFields = 4 - SendDlgItemMessage( hwnd,
  63. IDC_IPADDR_IP,
  64. IPM_GETADDRESS,
  65. (WPARAM) 0,
  66. (LPARAM) &dwIpValue );
  67. if( iNumBlankFields > 0 )
  68. {
  69. ReportErrorId( hwnd,
  70. MSGTYPE_ERR,
  71. IDS_ERROR_NEED_IP_ADDRESS );
  72. return( FALSE );
  73. }
  74. iNumBlankFields = 4 - SendDlgItemMessage( hwnd,
  75. IDC_IPADDR_SUB,
  76. IPM_GETADDRESS,
  77. (WPARAM) 0,
  78. (LPARAM) &dwIpValue );
  79. if( iNumBlankFields > 0 )
  80. {
  81. ReportErrorId( hwnd,
  82. MSGTYPE_ERR,
  83. IDS_ERROR_NEED_SUB_ADDRESS );
  84. return( FALSE );
  85. }
  86. }
  87. return( TRUE );
  88. }
  89. //----------------------------------------------------------------------------
  90. //
  91. // Function: StoreIPSettings
  92. //
  93. // Purpose: takes the values currently in the IP edit boxes and stores them
  94. // into the NetSettings global variable
  95. //
  96. // Arguments: IN HWND hwnd - handle to the dialog
  97. //
  98. // Returns: BOOL - TRUE if all the IP address are valid and they get stored
  99. // FALSE if there was an error
  100. //
  101. //----------------------------------------------------------------------------
  102. BOOL
  103. StoreIPSettings( IN HWND hwnd )
  104. {
  105. INT_PTR iIsBlank;
  106. INT iFoundStatus;
  107. if( IsDlgButtonChecked( hwnd, IDC_IP_DHCP ) == BST_CHECKED )
  108. {
  109. NetSettings.pCurrentAdapter->bObtainIPAddressAutomatically = TRUE;
  110. }
  111. else
  112. {
  113. TCHAR szIpBuffer[IPSTRINGLENGTH + 1];
  114. HWND hIPEditBox = GetDlgItem( hwnd, IDC_IPADDR_IP );
  115. HWND hSubnetEditBox = GetDlgItem( hwnd, IDC_IPADDR_SUB );
  116. HWND hGatewayEditBox = GetDlgItem( hwnd, IDC_IPADDR_GATE );
  117. NetSettings.pCurrentAdapter->bObtainIPAddressAutomatically = FALSE;
  118. //
  119. // Only store the data if the IP isn't blank
  120. // - if it's not blank then grab it and store it in a buffer
  121. // - if the IP is not already in the list then add it to the front
  122. // - if it is already in the list, remove it and add it to the front
  123. //
  124. iIsBlank = SendMessage( hIPEditBox, IPM_ISBLANK, 0, 0 );
  125. if( ! iIsBlank )
  126. {
  127. GetWindowText( hIPEditBox,
  128. szIpBuffer,
  129. IPSTRINGLENGTH + 1 ); // +1 for null character
  130. iFoundStatus = FindNameInNameList( &NetSettings.pCurrentAdapter->Tcpip_IpAddresses,
  131. szIpBuffer );
  132. if( iFoundStatus != NOT_FOUND )
  133. {
  134. RemoveNameFromNameListIdx( &NetSettings.pCurrentAdapter->Tcpip_IpAddresses,
  135. iFoundStatus );
  136. RemoveNameFromNameListIdx( &NetSettings.pCurrentAdapter->Tcpip_SubnetMaskAddresses,
  137. iFoundStatus );
  138. }
  139. AddNameToNameListIdx( &NetSettings.pCurrentAdapter->Tcpip_IpAddresses,
  140. szIpBuffer,
  141. 0 );
  142. }
  143. iIsBlank = SendMessage( hSubnetEditBox, IPM_ISBLANK, 0, 0 );
  144. if( ! iIsBlank )
  145. {
  146. GetWindowText( hSubnetEditBox,
  147. szIpBuffer,
  148. IPSTRINGLENGTH + 1 ); // +1 for null character
  149. AddNameToNameListIdx( &NetSettings.pCurrentAdapter->Tcpip_SubnetMaskAddresses,
  150. szIpBuffer,
  151. 0 );
  152. }
  153. iIsBlank = SendMessage( hGatewayEditBox, IPM_ISBLANK, 0, 0 );
  154. if( ! iIsBlank )
  155. {
  156. GetWindowText( hGatewayEditBox,
  157. szIpBuffer,
  158. IPSTRINGLENGTH + 1 ); // +1 for null character
  159. iFoundStatus = FindNameInNameList( &NetSettings.pCurrentAdapter->Tcpip_GatewayAddresses,
  160. szIpBuffer );
  161. if( iFoundStatus != NOT_FOUND )
  162. {
  163. RemoveNameFromNameListIdx( &NetSettings.pCurrentAdapter->Tcpip_GatewayAddresses,
  164. iFoundStatus );
  165. }
  166. AddNameToNameListIdx( &NetSettings.pCurrentAdapter->Tcpip_GatewayAddresses,
  167. szIpBuffer,
  168. 0 );
  169. }
  170. }
  171. if( IsDlgButtonChecked(hwnd, IDC_DNS_DHCP) == BST_CHECKED )
  172. {
  173. NetSettings.bObtainDNSServerAutomatically = TRUE;
  174. }
  175. else
  176. {
  177. TCHAR szDnsBuffer[IPSTRINGLENGTH + 1];
  178. HWND hPrimaryDNSEditBox = GetDlgItem( hwnd, IDC_DNS_PRIMARY );
  179. HWND hSecondaryDNSEditBox = GetDlgItem( hwnd, IDC_DNS_SECONDARY );
  180. NetSettings.bObtainDNSServerAutomatically = FALSE;
  181. //
  182. // Only store the data if the IP isn't blank
  183. //
  184. iIsBlank = SendMessage( hSecondaryDNSEditBox, IPM_ISBLANK, 0, 0 );
  185. if( ! iIsBlank )
  186. {
  187. GetWindowText( hSecondaryDNSEditBox,
  188. szDnsBuffer,
  189. IPSTRINGLENGTH + 1 ); // +1 for null character
  190. TcpipNameListInsertIdx( &NetSettings.pCurrentAdapter->Tcpip_DnsAddresses,
  191. szDnsBuffer,
  192. 0 );
  193. }
  194. iIsBlank = SendMessage( hPrimaryDNSEditBox, IPM_ISBLANK, 0, 0 );
  195. if( ! iIsBlank )
  196. {
  197. GetWindowText( hPrimaryDNSEditBox,
  198. szDnsBuffer,
  199. IPSTRINGLENGTH + 1 ); // +1 for null character
  200. TcpipNameListInsertIdx( &NetSettings.pCurrentAdapter->Tcpip_DnsAddresses,
  201. szDnsBuffer,
  202. 0 );
  203. }
  204. }
  205. return( TRUE );
  206. }
  207. //----------------------------------------------------------------------------
  208. //
  209. // Function: EnableIPAddressControls
  210. //
  211. // Purpose: Greys or ungreys the IP Address text and edit boxes
  212. //
  213. // Arguments: IN HWND hwnd - handle to the dialog
  214. // IN BOOL bVisible - TRUE to enable the IP address controls
  215. // FALSE to grey them
  216. //
  217. // Returns: VOID
  218. //
  219. //----------------------------------------------------------------------------
  220. VOID
  221. EnableIPAddressControls( IN HWND hwnd, IN BOOL bVisible )
  222. {
  223. EnableWindow( GetDlgItem( hwnd, IDC_IPADDR_IPTEXT ),
  224. bVisible );
  225. EnableWindow( GetDlgItem( hwnd, IDC_IPADDR_SUBTEXT ),
  226. bVisible );
  227. EnableWindow( GetDlgItem( hwnd, IDC_IPADDR_GATETEXT ),
  228. bVisible );
  229. EnableWindow( GetDlgItem( hwnd, IDC_IPADDR_IP ),
  230. bVisible );
  231. EnableWindow( GetDlgItem( hwnd, IDC_IPADDR_SUB ),
  232. bVisible );
  233. EnableWindow( GetDlgItem( hwnd, IDC_IPADDR_GATE ),
  234. bVisible );
  235. }
  236. //----------------------------------------------------------------------------
  237. //
  238. // Function: EnableServerAddressControls
  239. //
  240. // Purpose: Greys or ungreys the Server Address text and edit boxes
  241. //
  242. // Arguments: IN HWND hwnd - handle to the dialog
  243. // IN BOOL bVisible - TRUE to enable the Server address controls
  244. // FALSE to grey them
  245. //
  246. // Returns: VOID
  247. //
  248. //----------------------------------------------------------------------------
  249. VOID
  250. EnableServerAddressControls( IN HWND hwnd, IN BOOL bVisible )
  251. {
  252. EnableWindow( GetDlgItem( hwnd, IDC_DNS_PRIMARY_TEXT ),
  253. bVisible );
  254. EnableWindow( GetDlgItem( hwnd, IDC_DNS_SECONDARY_TEXT ),
  255. bVisible );
  256. EnableWindow( GetDlgItem( hwnd, IDC_DNS_PRIMARY ),
  257. bVisible );
  258. EnableWindow( GetDlgItem( hwnd, IDC_DNS_SECONDARY ),
  259. bVisible );
  260. }
  261. //----------------------------------------------------------------------------
  262. //
  263. // Function: SetTCPIPControls
  264. //
  265. // Purpose: uses settings in global variable NetSettings to set the TCP/IP
  266. // window states appropriately and fill the edit boxes with data
  267. // where appropriate
  268. //
  269. // Arguments: IN HWND hwnd - handle to the dialog
  270. //
  271. // Returns: VOID
  272. //
  273. //----------------------------------------------------------------------------
  274. VOID
  275. SetTCPIPControls( IN HWND hwnd )
  276. {
  277. //
  278. // Set the button and window states for IP
  279. //
  280. if( NetSettings.pCurrentAdapter->bObtainIPAddressAutomatically )
  281. {
  282. CheckRadioButton( hwnd, IDC_IP_DHCP, IDC_IP_FIXED, IDC_IP_DHCP );
  283. //
  284. // Gray out the IP address strings and boxes
  285. //
  286. EnableIPAddressControls( hwnd, FALSE );
  287. }
  288. else
  289. {
  290. CheckRadioButton( hwnd, IDC_IP_DHCP, IDC_IP_FIXED, IDC_IP_FIXED );
  291. //
  292. // Fill in the IP, Subnet Mask and Gateway data
  293. //
  294. SetWindowText( GetDlgItem( hwnd, IDC_IPADDR_IP ),
  295. GetNameListName( &NetSettings.pCurrentAdapter->Tcpip_IpAddresses, 0 ) );
  296. SetWindowText( GetDlgItem( hwnd, IDC_IPADDR_SUB ),
  297. GetNameListName( &NetSettings.pCurrentAdapter->Tcpip_SubnetMaskAddresses, 0 ) );
  298. SetWindowText( GetDlgItem( hwnd, IDC_IPADDR_GATE ),
  299. GetNameListName( &NetSettings.pCurrentAdapter->Tcpip_GatewayAddresses, 0 ) );
  300. }
  301. //
  302. // Set the button and window states for DNS
  303. //
  304. if( NetSettings.bObtainDNSServerAutomatically )
  305. {
  306. CheckRadioButton( hwnd, IDC_DNS_DHCP, IDC_DNS_FIXED, IDC_DNS_DHCP );
  307. //
  308. // Gray out the IP address strings and boxes
  309. //
  310. EnableServerAddressControls( hwnd, FALSE );
  311. }
  312. else
  313. {
  314. TCHAR *szDns;
  315. CheckRadioButton( hwnd, IDC_DNS_DHCP, IDC_DNS_FIXED, IDC_DNS_FIXED );
  316. //
  317. // Ensure the controls are visible and fill in the strings for
  318. // Primary and Secondary DNS
  319. //
  320. EnableServerAddressControls( hwnd, TRUE );
  321. szDns = GetNameListName( &NetSettings.pCurrentAdapter->Tcpip_DnsAddresses,
  322. 0 );
  323. SetWindowText( GetDlgItem( hwnd, IDC_DNS_PRIMARY ), szDns );
  324. szDns = GetNameListName( &NetSettings.pCurrentAdapter->Tcpip_DnsAddresses,
  325. 1 );
  326. SetWindowText( GetDlgItem( hwnd, IDC_DNS_SECONDARY ), szDns );
  327. }
  328. }
  329. //----------------------------------------------------------------------------
  330. //
  331. // Function: OnAdvancedClicked
  332. //
  333. // Purpose: Creates the Advanced TCP/IP property sheet for the user to specify
  334. // additional TCP/IP settings.
  335. //
  336. // Arguments: standard Win32 dialog proc arguments passed through from the
  337. // dialog proc
  338. //
  339. // Returns: VOID
  340. //
  341. //----------------------------------------------------------------------------
  342. VOID
  343. OnAdvancedClicked( IN HWND hwnd,
  344. IN UINT uMsg,
  345. IN WPARAM wParam,
  346. IN LPARAM lParam )
  347. {
  348. HWND hGatewayEditBox = GetDlgItem( hwnd, IDC_IPADDR_GATE );
  349. //
  350. // store the IP settings in the NetSettings global variable so the
  351. // advanced pages can access data in it
  352. //
  353. StoreIPSettings( hwnd );
  354. Create_TCPIPProp_PropertySheet( hwnd );
  355. //
  356. // Fill boxes with (potentially) new data from the TCP/IP Advanced screens
  357. //
  358. SetTCPIPControls( hwnd );
  359. //
  360. // always set the gateway because a user can still set this even if they
  361. // have DHCP enabled
  362. //
  363. SetWindowText( hGatewayEditBox,
  364. GetNameListName( &NetSettings.pCurrentAdapter->Tcpip_GatewayAddresses, 0 ) );
  365. }
  366. //----------------------------------------------------------------------------
  367. //
  368. // Function: OnDNSRadioButtonsClicked
  369. //
  370. // Purpose: Grey/Ungrey the DNS controls appropriately and clear DNS entries,
  371. // as necessary.
  372. //
  373. // Arguments: standard Win32 dialog proc arguments passed through from the
  374. // dialog proc
  375. //
  376. // Returns: VOID
  377. //
  378. //----------------------------------------------------------------------------
  379. VOID
  380. OnDNSRadioButtonsClicked( IN HWND hwnd,
  381. IN UINT uMsg,
  382. IN WPARAM wParam,
  383. IN LPARAM lParam )
  384. {
  385. INT nButtonId = LOWORD( wParam );
  386. if ( HIWORD( wParam ) == BN_CLICKED )
  387. {
  388. CheckRadioButton( hwnd, IDC_DNS_DHCP, IDC_DNS_FIXED, nButtonId );
  389. if( nButtonId == IDC_DNS_FIXED )
  390. {
  391. //
  392. // User clicked the radio button to have fixed DNS servers so
  393. // Un-grey the DNS strings and boxes so the user can
  394. // edit them
  395. //
  396. EnableServerAddressControls( hwnd, TRUE );
  397. }
  398. else
  399. {
  400. //
  401. // User clicked the radio button to have assigned DNS servers so
  402. // Grey the DNS strings and boxes so the user can not
  403. // edit them
  404. //
  405. EnableServerAddressControls( hwnd, FALSE );
  406. //
  407. // clear the DNS Address list
  408. //
  409. ResetNameList( &NetSettings.pCurrentAdapter->Tcpip_DnsAddresses );
  410. //
  411. // clear the contents of the Primary and Secondary edit boxes
  412. //
  413. SetWindowText( GetDlgItem( hwnd, IDC_DNS_PRIMARY ), _T("") );
  414. SetWindowText( GetDlgItem( hwnd, IDC_DNS_SECONDARY ), _T("") );
  415. }
  416. }
  417. }
  418. //----------------------------------------------------------------------------
  419. //
  420. // Function: OnIPRadioButtonsClicked
  421. //
  422. // Purpose: Grey/Ungrey the IP controls appropriately and clear the IP data
  423. // structures, as necessary.
  424. //
  425. // Arguments: standard Win32 dialog proc arguments passed through from the
  426. // dialog proc
  427. //
  428. // Returns: VOID
  429. //
  430. //----------------------------------------------------------------------------
  431. VOID
  432. OnIPRadioButtonsClicked( IN HWND hwnd,
  433. IN UINT uMsg,
  434. IN WPARAM wParam,
  435. IN LPARAM lParam )
  436. {
  437. INT nButtonId = LOWORD(wParam);
  438. if ( HIWORD(wParam) == BN_CLICKED )
  439. {
  440. CheckRadioButton( hwnd,
  441. IDC_IP_DHCP,
  442. IDC_IP_FIXED,
  443. nButtonId );
  444. if ( nButtonId == IDC_IP_FIXED )
  445. {
  446. //
  447. // User chose the radio button to specify and IP, Subnet Mask
  448. // and Gateway
  449. //
  450. // Un-grey the IP address strings and boxes
  451. // so the user can specify them
  452. //
  453. EnableIPAddressControls( hwnd, TRUE );
  454. //
  455. // If the user is going to specify their IP addresses then
  456. // they must specify their DNS server addresses so force
  457. // the manual radio box to be checked and un-grey the boxes
  458. //
  459. CheckRadioButton( hwnd,
  460. IDC_DNS_DHCP,
  461. IDC_DNS_FIXED,
  462. IDC_DNS_FIXED );
  463. EnableServerAddressControls( hwnd, TRUE );
  464. //
  465. // clear the list to avoid the string "DHCP enabled" from being
  466. // placed in the IP edit box
  467. //
  468. ResetNameList( &NetSettings.pCurrentAdapter->Tcpip_IpAddresses );
  469. //
  470. // Don't allow user to click the 'obtain DNS server automatically'
  471. //
  472. EnableWindow( GetDlgItem( hwnd, IDC_DNS_DHCP ),
  473. FALSE );
  474. }
  475. else
  476. {
  477. //
  478. // User to chose DHCP (have an IP assigned automatically)
  479. //
  480. // Grey out the IP address strings and boxes because they are
  481. // using DHCP
  482. //
  483. EnableIPAddressControls( hwnd, FALSE );
  484. //
  485. // clear the contents of the IP, Subnet and Gateway edit boxes
  486. // because using DHCP
  487. //
  488. SetWindowText( GetDlgItem( hwnd, IDC_IPADDR_IP ), _T("") );
  489. SetWindowText( GetDlgItem( hwnd, IDC_IPADDR_SUB ), _T("") );
  490. SetWindowText( GetDlgItem( hwnd, IDC_IPADDR_GATE ), _T("") );
  491. //
  492. // Clear the lists that contain the IP, Subnet and
  493. // Gateway data
  494. //
  495. ResetNameList( &NetSettings.pCurrentAdapter->Tcpip_IpAddresses );
  496. ResetNameList( &NetSettings.pCurrentAdapter->Tcpip_SubnetMaskAddresses );
  497. ResetNameList( &NetSettings.pCurrentAdapter->Tcpip_GatewayAddresses );
  498. //
  499. // Allow the user to be able to select 'obtain DNS server
  500. // automatically'
  501. //
  502. EnableWindow( GetDlgItem( hwnd, IDC_DNS_DHCP ), TRUE );
  503. }
  504. }
  505. }
  506. //----------------------------------------------------------------------------
  507. //
  508. // Function: OnTcpipInitDialog
  509. //
  510. // Purpose: Sets the text limits on the edit boxes and fills in initial data
  511. // and greys controls appropriately.
  512. //
  513. // Arguments: IN HWND hwnd - handle to the dialog box
  514. //
  515. // Returns: VOID
  516. //
  517. //----------------------------------------------------------------------------
  518. VOID
  519. OnTcpipInitDialog( IN HWND hwnd )
  520. {
  521. //
  522. // Set the text limit on the edit boxes to IPSTRINGLENGTH
  523. //
  524. SendDlgItemMessage( hwnd,
  525. IDC_IPADDR_IP,
  526. EM_LIMITTEXT,
  527. (WPARAM) IPSTRINGLENGTH,
  528. (LPARAM) 0 );
  529. SendDlgItemMessage( hwnd,
  530. IDC_IPADDR_SUB,
  531. EM_LIMITTEXT,
  532. (WPARAM) IPSTRINGLENGTH,
  533. (LPARAM) 0 );
  534. SendDlgItemMessage( hwnd,
  535. IDC_IPADDR_GATE,
  536. EM_LIMITTEXT,
  537. (WPARAM) IPSTRINGLENGTH,
  538. (LPARAM) 0 );
  539. SendDlgItemMessage( hwnd,
  540. IDC_DNS_PRIMARY,
  541. EM_LIMITTEXT,
  542. (WPARAM) IPSTRINGLENGTH,
  543. (LPARAM) 0 );
  544. SendDlgItemMessage( hwnd,
  545. IDC_DNS_SECONDARY,
  546. EM_LIMITTEXT,
  547. (WPARAM) IPSTRINGLENGTH,
  548. (LPARAM) 0 );
  549. SetTCPIPControls( hwnd );
  550. }
  551. //----------------------------------------------------------------------------
  552. //
  553. // Function: TCPIP_PropertiesDlgProc
  554. //
  555. // Purpose:
  556. //
  557. // Arguments: standard Win32 dialog proc arguments
  558. //
  559. // Returns:
  560. //
  561. //----------------------------------------------------------------------------
  562. INT_PTR CALLBACK
  563. TCPIP_PropertiesDlgProc( IN HWND hwnd,
  564. IN UINT uMsg,
  565. IN WPARAM wParam,
  566. IN LPARAM lParam )
  567. {
  568. BOOL bStatus = TRUE;
  569. switch( uMsg )
  570. {
  571. case WM_INITDIALOG:
  572. OnTcpipInitDialog( hwnd );
  573. break;
  574. case WM_NOTIFY:
  575. {
  576. LPNMHDR pnmh = (LPNMHDR) lParam;
  577. switch( pnmh->code )
  578. {
  579. case PSN_APPLY:
  580. {
  581. //
  582. // store the IP settings in the NetSettings global variable
  583. //
  584. if( ValidatePage( hwnd ) )
  585. {
  586. StoreIPSettings( hwnd );
  587. }
  588. else
  589. {
  590. //
  591. // if the validation fails then stay on this page
  592. //
  593. SetWindowLongPtr( hwnd, DWLP_MSGRESULT, -1 );
  594. return( PSNRET_INVALID_NOCHANGEPAGE );
  595. }
  596. }
  597. }
  598. } // end case WM_NOTIFY
  599. case WM_COMMAND:
  600. {
  601. int nButtonId;
  602. switch ( nButtonId = LOWORD(wParam) )
  603. {
  604. case IDC_IP_DHCP:
  605. case IDC_IP_FIXED:
  606. OnIPRadioButtonsClicked( hwnd,
  607. uMsg,
  608. wParam,
  609. lParam );
  610. break;
  611. case IDC_DNS_DHCP:
  612. case IDC_DNS_FIXED:
  613. OnDNSRadioButtonsClicked( hwnd,
  614. uMsg,
  615. wParam,
  616. lParam );
  617. break;
  618. case IDC_IPADDR_ADVANCED:
  619. {
  620. OnAdvancedClicked( hwnd,
  621. uMsg,
  622. wParam,
  623. lParam );
  624. break;
  625. }
  626. default:
  627. bStatus = FALSE;
  628. break;
  629. }
  630. break;
  631. }
  632. default:
  633. bStatus = FALSE;
  634. break;
  635. }
  636. return( bStatus );
  637. }
  638. //----------------------------------------------------------------------------
  639. //
  640. // Function: TCPIP_PropertySheetProc
  641. //
  642. // Purpose: Standard Property Sheet dialog proc. Very boring.
  643. //
  644. //----------------------------------------------------------------------------
  645. int CALLBACK
  646. TCPIP_PropertySheetProc( HWND hwndDlg, UINT uMsg, LPARAM lParam )
  647. {
  648. switch( uMsg ) {
  649. case PSCB_INITIALIZED :
  650. // Process PSCB_INITIALIZED
  651. break;
  652. case PSCB_PRECREATE :
  653. // Process PSCB_PRECREATE
  654. break;
  655. default :
  656. // Unknown message
  657. break;
  658. }
  659. return( 0 );
  660. }
  661. //----------------------------------------------------------------------------
  662. //
  663. // Function: TCPIP_PropertiesPageProc
  664. //
  665. // Purpose: Standard Property Page dialog proc.
  666. //
  667. //----------------------------------------------------------------------------
  668. UINT CALLBACK
  669. TCPIP_PropertiesPageProc( HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp )
  670. {
  671. switch( uMsg ) {
  672. case PSPCB_CREATE :
  673. return( TRUE );
  674. case PSPCB_RELEASE :
  675. return( 0 );
  676. }
  677. return( 0 );
  678. }
  679. //----------------------------------------------------------------------------
  680. //
  681. // Function: Create_TCPIP_PropertySheet
  682. //
  683. // Purpose: Sets up settings for the property sheet and the TCP/IP page (in
  684. // this case the property sheet is just 1 page). Lastly, calls the
  685. // PropertySheet function to display the property sheet, the return
  686. // value of this function is what is passed back as the return value
  687. //
  688. // Arguments: IN HWND hwndParent - handle to the dialog that is spawning the
  689. // property sheet
  690. //
  691. // Returns: BOOL - the returned value from the Property Sheet
  692. //
  693. //----------------------------------------------------------------------------
  694. BOOL
  695. Create_TCPIP_PropertySheet( IN HWND hwndParent )
  696. {
  697. INT i;
  698. // Initialize property sheet HEADER data
  699. ZeroMemory (&pshead, sizeof (PROPSHEETHEADER)) ;
  700. pshead.dwSize = sizeof (PROPSHEETHEADER) ;
  701. pshead.dwFlags = PSH_PROPSHEETPAGE |
  702. PSH_USECALLBACK |
  703. PSH_USEHICON |
  704. PSH_NOAPPLYNOW;
  705. pshead.hwndParent = hwndParent ;
  706. pshead.hInstance = FixedGlobals.hInstance;
  707. pshead.pszCaption = g_StrTcpipTitle;
  708. pshead.nPages = 1 ;
  709. pshead.nStartPage = 0 ;
  710. pshead.ppsp = &pspage ;
  711. pshead.pfnCallback = TCPIP_PropertySheetProc ;
  712. // Zero out property PAGE data
  713. ZeroMemory (&pspage, 1 * sizeof (PROPSHEETPAGE)) ;
  714. pspage.dwSize = sizeof (PROPSHEETPAGE) ;
  715. pspage.dwFlags = PSP_USECALLBACK ;
  716. pspage.hInstance = FixedGlobals.hInstance;
  717. pspage.pszTemplate = MAKEINTRESOURCE(IDD_TCP_IPADDR) ;
  718. pspage.pfnDlgProc = TCPIP_PropertiesDlgProc ;
  719. pspage.pfnCallback = TCPIP_PropertiesPageProc ;
  720. // --------- Create & display property sheet ---------
  721. return( PropertySheet( &pshead ) ? TRUE : FALSE);
  722. }