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.

103 lines
2.5 KiB

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