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.

887 lines
21 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // IPSubnetPage.cpp
  7. //
  8. // Maintained By:
  9. // Geoffrey Pease (GPease) 12-MAY-2000
  10. //
  11. //////////////////////////////////////////////////////////////////////////////
  12. #include "pch.h"
  13. #include "IPSubnetPage.h"
  14. DEFINE_THISCLASS("CIPSubnetPage");
  15. #define CONVERT_ADDRESS( _addrOut, _addrIn ) \
  16. _addrOut = ( FIRST_IPADDRESS( _addrIn ) ) | ( SECOND_IPADDRESS( _addrIn ) << 8 ) | ( THIRD_IPADDRESS( _addrIn ) << 16 ) | ( FOURTH_IPADDRESS( _addrIn ) << 24 )
  17. //////////////////////////////////////////////////////////////////////////////
  18. //++
  19. //
  20. // CIPSubnetPage::CIPSubnetPage(
  21. // IServiceProvider * pspIn,
  22. // ECreateAddMode ecamCreateAddModeIn
  23. // LONG * pulIPSubnetInout,
  24. // BSTR * pbstrNetworkNameInout,
  25. // ULONG * pulIPAddressIn,
  26. // BSTR * pbstrClusterNameIn
  27. // )
  28. //
  29. //--
  30. //////////////////////////////////////////////////////////////////////////////
  31. CIPSubnetPage::CIPSubnetPage(
  32. IServiceProvider * pspIn,
  33. ECreateAddMode ecamCreateAddModeIn,
  34. ULONG * pulIPSubnetInout,
  35. BSTR * pbstrNetworkNameInout,
  36. ULONG * pulIPAddressIn,
  37. BSTR * pbstrClusterNameIn
  38. )
  39. {
  40. TraceFunc( "" );
  41. Assert( pspIn != NULL );
  42. Assert( pulIPSubnetInout != NULL );
  43. Assert( pbstrNetworkNameInout != NULL );
  44. Assert( pulIPAddressIn != NULL );
  45. Assert( pbstrClusterNameIn != NULL );
  46. // m_hwnd = NULL;
  47. THR( pspIn->TypeSafeQI( IServiceProvider, &m_psp ) );
  48. m_pulIPSubnet = pulIPSubnetInout;
  49. m_pbstrNetworkName = pbstrNetworkNameInout;
  50. m_pulIPAddress = pulIPAddressIn;
  51. m_pbstrClusterName = pbstrClusterNameIn;
  52. TraceFuncExit( );
  53. } //*** CIPSubnetPage::CIPSubnetPage( )
  54. //////////////////////////////////////////////////////////////////////////////
  55. //++
  56. //
  57. // CIPSubnetPage::~CIPSubnetPage( void )
  58. //
  59. //--
  60. //////////////////////////////////////////////////////////////////////////////
  61. CIPSubnetPage::~CIPSubnetPage( void )
  62. {
  63. TraceFunc( "" );
  64. if ( m_psp != NULL )
  65. {
  66. m_psp->Release( );
  67. }
  68. TraceFuncExit( );
  69. } //*** CIPSubnetPage::~CIPSubnetPage( )
  70. //////////////////////////////////////////////////////////////////////////////
  71. //++
  72. //
  73. // LRESULT
  74. // CIPSubnetPage::OnInitDialog( void )
  75. //
  76. //--
  77. //////////////////////////////////////////////////////////////////////////////
  78. LRESULT
  79. CIPSubnetPage::OnInitDialog( void )
  80. {
  81. TraceFunc( "" );
  82. BOOL bRet;
  83. LRESULT lr = FALSE; // Didn't set focus
  84. if ( *m_pulIPSubnet != 0 )
  85. {
  86. ULONG ulIPSubnet;
  87. CONVERT_ADDRESS( ulIPSubnet, *m_pulIPSubnet );
  88. SendDlgItemMessage( m_hwnd, IDC_IP_SUBNETMASK, IPM_SETADDRESS, 0, ulIPSubnet );
  89. }
  90. RETURN( lr );
  91. } //*** CIPSubnetPage::OnInitDialog( )
  92. //////////////////////////////////////////////////////////////////////////////
  93. //++
  94. //
  95. // LRESULT
  96. // CIPSubnetPage::OnCommand(
  97. // UINT idNotificationIn,
  98. // UINT idControlIn,
  99. // HWND hwndSenderIn
  100. // )
  101. //
  102. //--
  103. //////////////////////////////////////////////////////////////////////////////
  104. LRESULT
  105. CIPSubnetPage::OnCommand(
  106. UINT idNotificationIn,
  107. UINT idControlIn,
  108. HWND hwndSenderIn
  109. )
  110. {
  111. TraceFunc( "" );
  112. LRESULT lr = FALSE;
  113. switch ( idControlIn )
  114. {
  115. case IDC_IP_SUBNETMASK:
  116. if ( idNotificationIn == IPN_FIELDCHANGED
  117. || idNotificationIn == EN_CHANGE
  118. )
  119. {
  120. THR( HrUpdateWizardButtons( ) );
  121. lr = TRUE;
  122. }
  123. break;
  124. case IDC_CB_NETWORKS:
  125. if ( idNotificationIn == CBN_SELCHANGE )
  126. {
  127. THR( HrUpdateWizardButtons( ) );
  128. lr = TRUE;
  129. }
  130. break;
  131. }
  132. RETURN( lr );
  133. } //*** CIPSubnetPage::OnCommand( )
  134. //////////////////////////////////////////////////////////////////////////////
  135. //++
  136. //
  137. // HRESULT
  138. // CIPSubnetPage::HrUpdateWizardButtons( void )
  139. //
  140. //--
  141. //////////////////////////////////////////////////////////////////////////////
  142. HRESULT
  143. CIPSubnetPage::HrUpdateWizardButtons( void )
  144. {
  145. TraceFunc( "" );
  146. LRESULT lr;
  147. ULONG ulIPSubnet;
  148. HRESULT hr = S_OK;
  149. DWORD dwFlags = PSWIZB_BACK | PSWIZB_NEXT;
  150. lr = SendDlgItemMessage( m_hwnd, IDC_IP_SUBNETMASK, IPM_ISBLANK, 0, 0 );
  151. if ( lr != 0 )
  152. {
  153. dwFlags &= ~PSWIZB_NEXT;
  154. }
  155. lr = ComboBox_GetCurSel( GetDlgItem( m_hwnd, IDC_CB_NETWORKS ) );
  156. if ( lr == CB_ERR )
  157. {
  158. dwFlags &= ~PSWIZB_NEXT;
  159. }
  160. PropSheet_SetWizButtons( GetParent( m_hwnd ), dwFlags );
  161. HRETURN( hr );
  162. } //*** CIPSubnetPage::HrUpdateWizardButtons( )
  163. //////////////////////////////////////////////////////////////////////////////
  164. //++
  165. //
  166. // LRESULT
  167. // CIPSubnetPage::OnNotify(
  168. // WPARAM idCtrlIn,
  169. // LPNMHDR pnmhdrIn
  170. // )
  171. //
  172. //--
  173. //////////////////////////////////////////////////////////////////////////////
  174. LRESULT
  175. CIPSubnetPage::OnNotify(
  176. WPARAM idCtrlIn,
  177. LPNMHDR pnmhdrIn
  178. )
  179. {
  180. TraceFunc( "" );
  181. LRESULT lr = TRUE;
  182. SetWindowLongPtr( m_hwnd, DWLP_MSGRESULT, 0 );
  183. switch( pnmhdrIn->code )
  184. {
  185. case PSN_SETACTIVE:
  186. lr = OnNotifySetActive( );
  187. break;
  188. case PSN_KILLACTIVE:
  189. lr = OnNotifyKillActive( );
  190. break;
  191. case PSN_WIZNEXT:
  192. lr = OnNotifyWizNext( );
  193. break;
  194. case PSN_QUERYCANCEL:
  195. lr = OnNotifyQueryCancel( );
  196. break;
  197. }
  198. RETURN( lr );
  199. } //*** CIPSubnetPage::OnNotify( )
  200. //////////////////////////////////////////////////////////////////////////////
  201. //++
  202. //
  203. // LRESULT
  204. // CIPSubnetPage::OnNotifyQueryCancel( void )
  205. //
  206. //--
  207. //////////////////////////////////////////////////////////////////////////////
  208. LRESULT
  209. CIPSubnetPage::OnNotifyQueryCancel( void )
  210. {
  211. TraceFunc( "" );
  212. LRESULT lr = TRUE;
  213. int iRet;
  214. iRet = MessageBoxFromStrings( m_hwnd,
  215. IDS_QUERY_CANCEL_TITLE,
  216. IDS_QUERY_CANCEL_TEXT,
  217. MB_YESNO
  218. );
  219. if ( iRet == IDNO )
  220. {
  221. SetWindowLongPtr( m_hwnd, DWLP_MSGRESULT, -1 );
  222. }
  223. RETURN( lr );
  224. } //*** CIPSubnetPage::OnNotifyQueryCancel( )
  225. //////////////////////////////////////////////////////////////////////////////
  226. //++
  227. //
  228. // LRESULT
  229. // CIPSubnetPage::OnNotifySetActive( void )
  230. //
  231. //--
  232. //////////////////////////////////////////////////////////////////////////////
  233. LRESULT
  234. CIPSubnetPage::OnNotifySetActive( void )
  235. {
  236. TraceFunc( "" );
  237. LRESULT lr = TRUE;
  238. HWND hwndIP = GetDlgItem( m_hwnd, IDC_IP_SUBNETMASK );
  239. HWND hwndCB = GetDlgItem( m_hwnd, IDC_CB_NETWORKS );
  240. WCHAR szIPAddress[ ARRAYSIZE( "255 . 255 . 255 . 255" ) ];
  241. LRESULT lrCB;
  242. HRESULT hr;
  243. THR( HrUpdateWizardButtons( ) );
  244. //
  245. // Set the IP address string.
  246. //
  247. wnsprintf( szIPAddress,
  248. ARRAYSIZE( szIPAddress ),
  249. L"%u . %u . %u . %u",
  250. FOURTH_IPADDRESS( *m_pulIPAddress ),
  251. THIRD_IPADDRESS( *m_pulIPAddress ),
  252. SECOND_IPADDRESS( *m_pulIPAddress ),
  253. FIRST_IPADDRESS( *m_pulIPAddress )
  254. );
  255. SetDlgItemText( m_hwnd, IDC_E_IPADDRESS, szIPAddress );
  256. //
  257. // Add networks to the combobox.
  258. //
  259. hr = STHR( HrAddNetworksToComboBox( hwndCB ) );
  260. //
  261. // Set the subnet mask based on what was found from
  262. // the networks added to the combobox.
  263. //
  264. if ( *m_pulIPSubnet != 0 )
  265. {
  266. ULONG ulIPSubnet;
  267. CONVERT_ADDRESS( ulIPSubnet, *m_pulIPSubnet );
  268. SendMessage( hwndIP, IPM_SETADDRESS, 0, ulIPSubnet );
  269. }
  270. //
  271. // If there isn't a selected network, select the first one.
  272. //
  273. lrCB = ComboBox_GetCurSel( hwndCB );
  274. if ( lrCB == CB_ERR )
  275. {
  276. ComboBox_SetCurSel( hwndCB, 0 );
  277. }
  278. //
  279. // Determine if we need to show this page.
  280. //
  281. if ( hr == S_OK )
  282. {
  283. OnNotifyWizNext();
  284. SetWindowLongPtr( m_hwnd, DWLP_MSGRESULT, -1 );
  285. }
  286. RETURN( lr );
  287. } //*** CIPSubnetPage::OnNotifySetActive( )
  288. //////////////////////////////////////////////////////////////////////////////
  289. //++
  290. //
  291. // LRESULT
  292. // CIPSubnetPage::OnNotifyKillActive( void )
  293. //
  294. //--
  295. //////////////////////////////////////////////////////////////////////////////
  296. LRESULT
  297. CIPSubnetPage::OnNotifyKillActive( void )
  298. {
  299. TraceFunc( "" );
  300. LRESULT lr = TRUE;
  301. HWND hwndCB = GetDlgItem( m_hwnd, IDC_CB_NETWORKS );
  302. LRESULT citems;
  303. //
  304. // Release all the network info interfaces stored in the combobox.
  305. //
  306. citems = ComboBox_GetCount( hwndCB );
  307. Assert( citems != CB_ERR );
  308. if ( ( citems != CB_ERR )
  309. && ( citems > 0 ) )
  310. {
  311. LRESULT idx;
  312. LRESULT lrItemData;
  313. IClusCfgNetworkInfo * pccni;
  314. for ( idx = 0 ; idx < citems ; idx++ )
  315. {
  316. lrItemData = ComboBox_GetItemData( hwndCB, idx );
  317. Assert( lrItemData != CB_ERR );
  318. pccni = reinterpret_cast< IClusCfgNetworkInfo * >( lrItemData );
  319. pccni->Release();
  320. } // for: each item in the combobox
  321. } // if: retrieved combobox count and combobox not empty
  322. ComboBox_ResetContent( hwndCB );
  323. RETURN( lr );
  324. } //*** CIPSubnetPage::OnNotifyKillActive( )
  325. //////////////////////////////////////////////////////////////////////////////
  326. //++
  327. //
  328. // LRESULT
  329. // CIPSubnetPage::OnNotifyWizNext( void )
  330. //
  331. //--
  332. //////////////////////////////////////////////////////////////////////////////
  333. LRESULT
  334. CIPSubnetPage::OnNotifyWizNext( void )
  335. {
  336. TraceFunc( "" );
  337. OBJECTCOOKIE cookieDummy;
  338. LRESULT lr = TRUE;
  339. LRESULT lrCB;
  340. HRESULT hr;
  341. ULONG ulIPSubnet;
  342. HWND hwndCB = GetDlgItem( m_hwnd, IDC_CB_NETWORKS );
  343. IUnknown * punk = NULL;
  344. IObjectManager * pom = NULL;
  345. IClusCfgClusterInfo * pccci = NULL;
  346. IClusCfgNetworkInfo * pccni = NULL;
  347. SendDlgItemMessage( m_hwnd, IDC_IP_SUBNETMASK, IPM_GETADDRESS, 0, (LPARAM) &ulIPSubnet );
  348. CONVERT_ADDRESS( *m_pulIPSubnet, ulIPSubnet );
  349. //
  350. // Grab the object manager.
  351. //
  352. hr = THR( m_psp->TypeSafeQS( CLSID_ObjectManager,
  353. IObjectManager,
  354. &pom
  355. ) );
  356. if ( FAILED( hr ) )
  357. goto Error;
  358. //
  359. // Get the cluster configuration info.
  360. //
  361. hr = THR( pom->FindObject( CLSID_ClusterConfigurationType,
  362. NULL,
  363. *m_pbstrClusterName,
  364. DFGUID_ClusterConfigurationInfo,
  365. &cookieDummy,
  366. &punk
  367. ) );
  368. if ( FAILED( hr ) )
  369. goto Error;
  370. hr = THR( punk->TypeSafeQI( IClusCfgClusterInfo, &pccci ) );
  371. if ( FAILED( hr ) )
  372. goto Cleanup;
  373. //
  374. // Set the IP subnet mask.
  375. //
  376. hr = THR( pccci->SetSubnetMask( *m_pulIPSubnet ) );
  377. if ( FAILED( hr ) )
  378. goto Error;
  379. //
  380. // Get the selected network.
  381. //
  382. //
  383. // Set the network.
  384. //
  385. lrCB = ComboBox_GetCurSel( hwndCB );
  386. Assert( lrCB != CB_ERR );
  387. lrCB = ComboBox_GetItemData( hwndCB, lrCB );
  388. Assert( lrCB != CB_ERR );
  389. pccni = reinterpret_cast< IClusCfgNetworkInfo * >( lrCB );
  390. hr = THR( pccci->SetNetworkInfo( pccni ) );
  391. if ( FAILED( hr ) )
  392. goto Error;
  393. Cleanup:
  394. if ( punk != NULL )
  395. {
  396. punk->Release( );
  397. }
  398. if ( pccci != NULL )
  399. {
  400. pccci->Release( );
  401. }
  402. if ( pom != NULL )
  403. {
  404. pom->Release( );
  405. }
  406. RETURN( lr );
  407. Error:
  408. SetWindowLongPtr( m_hwnd, DWLP_MSGRESULT, -1 );
  409. goto Cleanup;
  410. } //*** CIPSubnetPage::OnNotifyWizNext( )
  411. //////////////////////////////////////////////////////////////////////////////
  412. //++
  413. //
  414. // HRESULT
  415. // CIPSubnetPage::HrAddNetworksToComboBox( void )
  416. //
  417. //--
  418. //////////////////////////////////////////////////////////////////////////////
  419. HRESULT
  420. CIPSubnetPage::HrAddNetworksToComboBox(
  421. HWND hwndCBIn
  422. )
  423. {
  424. TraceFunc( "" );
  425. HRESULT hr = S_OK;
  426. IUnknown * punk = NULL;
  427. IObjectManager * pom = NULL;
  428. IEnumCookies * pec = NULL;
  429. IEnumClusCfgNetworks * peccn = NULL;
  430. IClusCfgNetworkInfo * pccni = NULL;
  431. BSTR bstrNetName = NULL;
  432. OBJECTCOOKIE cookieCluster;
  433. OBJECTCOOKIE cookieNode;
  434. OBJECTCOOKIE cookieDummy;
  435. ULONG celtDummy;
  436. bool fFoundNetwork = false;
  437. LRESULT lr;
  438. LRESULT lrIndex;
  439. Assert( hwndCBIn != NULL );
  440. ComboBox_ResetContent( hwndCBIn );
  441. //
  442. // Grab the object manager.
  443. //
  444. hr = THR( m_psp->TypeSafeQS(
  445. CLSID_ObjectManager,
  446. IObjectManager,
  447. &pom
  448. ) );
  449. if ( FAILED( hr ) )
  450. goto Cleanup;
  451. //
  452. // Get the cluster configuration info cookie.
  453. //
  454. hr = THR( pom->FindObject(
  455. CLSID_ClusterConfigurationType,
  456. NULL,
  457. *m_pbstrClusterName,
  458. IID_NULL,
  459. &cookieCluster,
  460. &punk
  461. ) );
  462. Assert( punk == NULL );
  463. if ( FAILED( hr ) )
  464. goto Cleanup;
  465. //
  466. // Get the enumeration of nodes whose parent is this cluster.
  467. // We want the enumeration of cookies (indicated by using
  468. // DFGUID_EnumCookies) because we want to use the cookie of the
  469. // node to search for all networks on that node.
  470. //
  471. hr = THR( pom->FindObject(
  472. CLSID_NodeType,
  473. cookieCluster,
  474. NULL,
  475. DFGUID_EnumCookies,
  476. &cookieDummy,
  477. &punk
  478. ) );
  479. if ( FAILED( hr ) )
  480. goto Cleanup;
  481. hr = THR( punk->TypeSafeQI( IEnumCookies, &pec ) );
  482. if ( FAILED( hr ) )
  483. goto Cleanup;
  484. pec = TraceInterface( L"CIPSubnetPage!IEnumCookies", IEnumCookies, pec, 1 );
  485. punk->Release( );
  486. punk = NULL;
  487. //
  488. // Get the cookie for the first node in the node enumeration.
  489. //
  490. hr = THR( pec->Next( 1, &cookieNode, &celtDummy ) );
  491. if ( FAILED( hr ) )
  492. goto Cleanup;
  493. //
  494. // Get the network enumerator.
  495. //
  496. hr = THR( pom->FindObject(
  497. CLSID_NetworkType,
  498. cookieNode,
  499. NULL,
  500. DFGUID_EnumManageableNetworks,
  501. &cookieDummy,
  502. &punk
  503. ) );
  504. if ( FAILED( hr ) )
  505. goto Cleanup;
  506. hr = THR( punk->TypeSafeQI( IEnumClusCfgNetworks, &peccn ) );
  507. if ( FAILED( hr ) )
  508. goto Cleanup;
  509. punk->Release( );
  510. punk = NULL;
  511. //
  512. // Add each network to the combobox.
  513. //
  514. for ( ;; )
  515. {
  516. // Get the next network.
  517. hr = STHR( peccn->Next( 1, &pccni, &celtDummy ) );
  518. if ( hr == S_FALSE )
  519. break;
  520. if ( FAILED( hr ) )
  521. goto Cleanup;
  522. // Skip this network if it isn't public.
  523. hr = STHR( pccni->IsPublic() );
  524. if ( hr == S_OK )
  525. {
  526. // Get the name of the network.
  527. hr = THR( pccni->GetName( &bstrNetName ) );
  528. if ( SUCCEEDED( hr ) )
  529. {
  530. TraceMemoryAddBSTR( bstrNetName );
  531. // Add the network to the combobox.
  532. lrIndex = ComboBox_AddString( hwndCBIn, bstrNetName );
  533. Assert( ( lrIndex != CB_ERR )
  534. && ( lrIndex != CB_ERRSPACE )
  535. );
  536. // Add the netinfo interface to the combobox as well.
  537. if ( ( lrIndex != CB_ERR )
  538. && ( lrIndex != CB_ERRSPACE ) )
  539. {
  540. pccni->AddRef();
  541. lr = ComboBox_SetItemData( hwndCBIn, lrIndex, pccni );
  542. Assert( lr != CB_ERR );
  543. }
  544. // Determine if this network matches the user's IP address.
  545. // If it is, select it in the combobox.
  546. if ( ! fFoundNetwork )
  547. {
  548. hr = STHR( HrMatchNetwork( pccni, bstrNetName ) );
  549. if ( hr == S_OK )
  550. {
  551. fFoundNetwork = true;
  552. lr = ComboBox_SetCurSel( hwndCBIn, lrIndex );
  553. Assert( lr != CB_ERR );
  554. }
  555. }
  556. // Cleanup.
  557. TraceSysFreeString( bstrNetName );
  558. bstrNetName = NULL;
  559. } // if: name retrieved successfully
  560. } // if: network is public
  561. pccni->Release();
  562. pccni = NULL;
  563. } // forever
  564. if ( fFoundNetwork )
  565. {
  566. hr = S_OK;
  567. }
  568. else
  569. {
  570. hr = S_FALSE;
  571. }
  572. Cleanup:
  573. if ( punk != NULL )
  574. {
  575. punk->Release( );
  576. }
  577. if ( bstrNetName != NULL )
  578. {
  579. SysFreeString( bstrNetName );
  580. }
  581. if ( pccni != NULL )
  582. {
  583. pccni->Release();
  584. }
  585. if ( peccn != NULL )
  586. {
  587. peccn->Release();
  588. }
  589. if ( pec != NULL )
  590. {
  591. pec->Release();
  592. }
  593. if ( pom != NULL )
  594. {
  595. pom->Release();
  596. }
  597. HRETURN( hr );
  598. } //*** CIPSubnetPage::HrAddNetworksToComboBox( )
  599. //////////////////////////////////////////////////////////////////////////////
  600. //++
  601. //
  602. // HRESULT
  603. // CIPSubnetPage::HrMatchNetwork(
  604. // IClusCfgNetworkInfo * pccniIn,
  605. // BSTR bstrNetworkNameIn
  606. // )
  607. //
  608. //--
  609. //////////////////////////////////////////////////////////////////////////////
  610. HRESULT
  611. CIPSubnetPage::HrMatchNetwork(
  612. IClusCfgNetworkInfo * pccniIn,
  613. BSTR bstrNetworkNameIn
  614. )
  615. {
  616. TraceFunc( "" );
  617. HRESULT hr = S_OK;
  618. IClusCfgIPAddressInfo * pccipai = NULL;
  619. ULONG ulIPAddress;
  620. ULONG ulIPSubnet;
  621. Assert( pccniIn != NULL );
  622. Assert( bstrNetworkNameIn != NULL );
  623. //
  624. // Get the IP Address Info for the network.
  625. //
  626. hr = THR( pccniIn->GetPrimaryNetworkAddress( &pccipai ) );
  627. if ( FAILED( hr ) )
  628. goto Cleanup;
  629. //
  630. // Get the address and subnet of the network.
  631. //
  632. hr = THR( pccipai->GetIPAddress( &ulIPAddress ) );
  633. if ( FAILED( hr ) )
  634. goto Cleanup;
  635. hr = THR( pccipai->GetSubnetMask( &ulIPSubnet ) );
  636. if ( FAILED( hr ) )
  637. goto Cleanup;
  638. //
  639. // Determine if these match.
  640. //
  641. if ( ClRtlAreTcpipAddressesOnSameSubnet( *m_pulIPAddress, ulIPAddress, ulIPSubnet) )
  642. {
  643. // Save the subnet mask.
  644. *m_pulIPSubnet = ulIPSubnet;
  645. // Save the name of the network.
  646. if ( *m_pbstrNetworkName == NULL )
  647. {
  648. *m_pbstrNetworkName = TraceSysAllocString( bstrNetworkNameIn );
  649. if ( *m_pbstrNetworkName == NULL )
  650. goto OutOfMemory;
  651. }
  652. else
  653. {
  654. INT iRet = TraceSysReAllocString( m_pbstrNetworkName, bstrNetworkNameIn );
  655. if ( ! iRet )
  656. goto OutOfMemory;
  657. }
  658. } // if: match found
  659. else
  660. {
  661. hr = S_FALSE;
  662. }
  663. Cleanup:
  664. if ( pccipai != NULL )
  665. {
  666. pccipai->Release();
  667. }
  668. HRETURN( hr );
  669. OutOfMemory:
  670. hr = E_OUTOFMEMORY;
  671. goto Cleanup;
  672. } //*** CIPSubnetPage::HrMatchNetwork( )
  673. //////////////////////////////////////////////////////////////////////////////
  674. //++
  675. //
  676. // [static]
  677. // INT_PTR
  678. // CALLBACK
  679. // CIPSubnetPage::S_DlgProc(
  680. // HWND hDlgIn,
  681. // UINT MsgIn,
  682. // WPARAM wParam,
  683. // LPARAM lParam
  684. // )
  685. //
  686. //--
  687. //////////////////////////////////////////////////////////////////////////////
  688. INT_PTR
  689. CALLBACK
  690. CIPSubnetPage::S_DlgProc(
  691. HWND hDlgIn,
  692. UINT MsgIn,
  693. WPARAM wParam,
  694. LPARAM lParam
  695. )
  696. {
  697. // Don't do TraceFunc because every mouse movement
  698. // will cause this function to be called.
  699. WndMsg( hDlgIn, MsgIn, wParam, lParam );
  700. LRESULT lr = FALSE;
  701. CIPSubnetPage * pPage = reinterpret_cast< CIPSubnetPage *> ( GetWindowLongPtr( hDlgIn, GWLP_USERDATA ) );
  702. if ( MsgIn == WM_INITDIALOG )
  703. {
  704. PROPSHEETPAGE * ppage = reinterpret_cast< PROPSHEETPAGE * >( lParam );
  705. SetWindowLongPtr( hDlgIn, GWLP_USERDATA, (LPARAM) ppage->lParam );
  706. pPage = reinterpret_cast< CIPSubnetPage * >( ppage->lParam );
  707. pPage->m_hwnd = hDlgIn;
  708. }
  709. if ( pPage != NULL )
  710. {
  711. Assert( hDlgIn == pPage->m_hwnd );
  712. switch( MsgIn )
  713. {
  714. case WM_INITDIALOG:
  715. lr = pPage->OnInitDialog( );
  716. break;
  717. case WM_NOTIFY:
  718. lr = pPage->OnNotify( wParam, reinterpret_cast< LPNMHDR >( lParam ) );
  719. break;
  720. case WM_COMMAND:
  721. lr= pPage->OnCommand( HIWORD( wParam ), LOWORD( wParam ), (HWND) lParam );
  722. break;
  723. // no default clause needed
  724. }
  725. }
  726. return lr;
  727. } //*** CIPSubnetPage::S_DlgProc( )