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.

133 lines
3.2 KiB

  1. #include "PortsControlPage.h"
  2. #include "Common.h"
  3. #include "wlbsparm.h"
  4. #include "CommonUtils.h"
  5. #include "ResourceString.h"
  6. BEGIN_MESSAGE_MAP( PortsControlPage, CPropertyPage )
  7. ON_WM_HELPINFO()
  8. ON_WM_CONTEXTMENU()
  9. END_MESSAGE_MAP()
  10. void
  11. PortsControlPage::DoDataExchange( CDataExchange* pDX )
  12. {
  13. CPropertyPage::DoDataExchange( pDX );
  14. DDX_Control( pDX, IDC_PORTS, portList );
  15. }
  16. PortsControlPage::PortsControlPage( ClusterData* p_clusterData,
  17. unsigned long* portSelected,
  18. UINT ID )
  19. :
  20. m_clusterData( p_clusterData ),
  21. m_portSelected( portSelected ),
  22. CPropertyPage( ID )
  23. {
  24. }
  25. BOOL
  26. PortsControlPage::OnInitDialog()
  27. {
  28. CPropertyPage::OnInitDialog();
  29. // fill the portList with available ports.
  30. // first is allow user ability to select
  31. // all ports.
  32. portList.AddString( GETRESOURCEIDSTRING( IDS_PORTS_ALL ) );
  33. wchar_t buf[Common::BUF_SIZE];
  34. map< long, PortDataELB>::iterator topELB;
  35. for( topELB = m_clusterData->portELB.begin();
  36. topELB != m_clusterData->portELB.end();
  37. ++topELB )
  38. {
  39. swprintf( buf, L"%d", (*topELB).second._startPort );
  40. portList.AddString( buf );
  41. }
  42. map< long, PortDataULB>::iterator topULB;
  43. for( topULB = m_clusterData->portULB.begin();
  44. topULB != m_clusterData->portULB.end();
  45. ++topULB )
  46. {
  47. swprintf( buf, L"%d", (*topULB).second._startPort );
  48. portList.AddString( buf );
  49. }
  50. map< long, PortDataF>::iterator topF;
  51. for( topF = m_clusterData->portF.begin();
  52. topF != m_clusterData->portF.end();
  53. ++topF )
  54. {
  55. swprintf( buf, L"%d", (*topF).second._startPort );
  56. portList.AddString( buf );
  57. }
  58. map< long, PortDataD>::iterator topD;
  59. for( topD = m_clusterData->portD.begin();
  60. topD != m_clusterData->portD.end();
  61. ++topD )
  62. {
  63. swprintf( buf, L"%d", (*topD).second._startPort );
  64. portList.AddString( buf );
  65. }
  66. // make the all ports selection the
  67. // default selection.
  68. portList.SelectString( -1,
  69. GETRESOURCEIDSTRING( IDS_PORTS_ALL ) );
  70. return TRUE;
  71. }
  72. void
  73. PortsControlPage::OnOK()
  74. {
  75. // get port which needs to be affected.
  76. int currentSelection = portList.GetCurSel();
  77. wchar_t buf[ Common::BUF_SIZE ];
  78. portList.GetLBText( currentSelection, buf );
  79. if( _bstr_t ( buf ) == GETRESOURCEIDSTRING( IDS_PORTS_ALL ) )
  80. {
  81. *m_portSelected = Common::ALL_PORTS;
  82. }
  83. else
  84. {
  85. *m_portSelected = _wtoi( buf );
  86. }
  87. CPropertyPage::OnOK();
  88. }
  89. BOOL
  90. PortsControlPage::OnHelpInfo (HELPINFO* helpInfo )
  91. {
  92. if( helpInfo->iContextType == HELPINFO_WINDOW )
  93. {
  94. ::WinHelp( static_cast<HWND> ( helpInfo->hItemHandle ),
  95. CVY_CTXT_HELP_FILE,
  96. HELP_WM_HELP,
  97. (ULONG_PTR ) g_aHelpIDs_IDD_PORTS_CONTROL_PAGE );
  98. }
  99. return TRUE;
  100. }
  101. void
  102. PortsControlPage::OnContextMenu( CWnd* pWnd, CPoint point )
  103. {
  104. ::WinHelp( m_hWnd,
  105. CVY_CTXT_HELP_FILE,
  106. HELP_CONTEXTMENU,
  107. (ULONG_PTR ) g_aHelpIDs_IDD_PORTS_CONTROL_PAGE );
  108. }