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.

247 lines
7.3 KiB

  1. //-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: A R P S D L G . H
  7. //
  8. // Contents: CArpsPage declaration
  9. //
  10. // Notes:
  11. //
  12. // Author: tongl 2 Feb 1998
  13. //
  14. //-----------------------------------------------------------------------
  15. #pragma once
  16. #include "ncxbase.h"
  17. #include "ncatlps.h"
  18. #include "ipctrl.h"
  19. const int c_nColumns =2;
  20. const int IPRANGE_LIMIT = 66;
  21. struct HandleGroup
  22. {
  23. HWND m_hListView;
  24. HWND m_hAdd;
  25. HWND m_hEdit;
  26. HWND m_hRemove;
  27. };
  28. void ShowContextHelp(HWND hDlg, UINT uCommand, const DWORD* pdwHelpIDs);
  29. //
  30. // CArpsPage
  31. //
  32. class CArpsPage : public CPropSheetPage
  33. {
  34. public:
  35. // Declare the message map
  36. BEGIN_MSG_MAP(CArpsPage)
  37. // Initialize dialog
  38. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  39. MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu)
  40. MESSAGE_HANDLER(WM_HELP, OnHelp)
  41. // Property page notification message handlers
  42. NOTIFY_CODE_HANDLER(PSN_APPLY, OnApply)
  43. NOTIFY_CODE_HANDLER(PSN_KILLACTIVE, OnKillActive)
  44. NOTIFY_CODE_HANDLER(PSN_SETACTIVE, OnActive)
  45. NOTIFY_CODE_HANDLER(PSN_RESET, OnCancel)
  46. // List view handlers
  47. NOTIFY_CODE_HANDLER(LVN_ITEMCHANGED, OnItemChanged)
  48. // Control message handlers
  49. COMMAND_ID_HANDLER(IDC_PSH_ARPS_REG_ADD, OnAddRegisteredAddr);
  50. COMMAND_ID_HANDLER(IDC_PSH_ARPS_REG_EDT, OnEditRegisteredAddr);
  51. COMMAND_ID_HANDLER(IDC_PSH_ARPS_REG_RMV, OnRemoveRegisteredAddr);
  52. COMMAND_ID_HANDLER(IDC_PSH_ARPS_MUL_ADD, OnAddMulticastAddr);
  53. COMMAND_ID_HANDLER(IDC_PSH_ARPS_MUL_EDT, OnEditMulticastAddr);
  54. COMMAND_ID_HANDLER(IDC_PSH_ARPS_MUL_RMV, OnRemoveMulticastAddr);
  55. END_MSG_MAP()
  56. // Constructors/Destructors
  57. CArpsPage(CArpsCfg * pArpscfg, const DWORD * phelpIDs = NULL);
  58. ~CArpsPage();
  59. // Interface
  60. public:
  61. // message map functions
  62. LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  63. LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  64. LRESULT OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  65. // notify handlers for the property page
  66. LRESULT OnApply(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  67. LRESULT OnKillActive(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  68. LRESULT OnActive(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  69. LRESULT OnCancel(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  70. LRESULT OnItemChanged(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  71. // command ID handlers
  72. LRESULT OnAddRegisteredAddr(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  73. LRESULT OnEditRegisteredAddr(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  74. LRESULT OnRemoveRegisteredAddr(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  75. LRESULT OnAddMulticastAddr(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  76. LRESULT OnEditMulticastAddr(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  77. LRESULT OnRemoveMulticastAddr(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  78. friend class CAtmAddrDlg;
  79. friend class CIpAddrRangeDlg;
  80. // Implementation
  81. private:
  82. CArpsCfg * m_pArpscfg;
  83. BOOL m_fModified;
  84. const DWORD* m_adwHelpIDs;
  85. CArpsAdapterInfo * m_pAdapterInfo;
  86. HandleGroup m_hRegAddrs;
  87. HandleGroup m_hMulAddrs;
  88. BOOL m_fEditState;
  89. tstring m_strRemovedAtmAddr;
  90. tstring m_strRemovedIpRange;
  91. // Inlines
  92. BOOL IsModified() {return m_fModified;}
  93. void SetModifiedTo(BOOL bState) {m_fModified = bState;}
  94. void PageModified() {
  95. m_fModified = TRUE;
  96. PropSheet_Changed(GetParent(), m_hWnd);
  97. }
  98. // help functions
  99. void SetRegisteredAtmAddrInfo();
  100. void SetMulticastIpAddrInfo();
  101. void SetButtons(HandleGroup& handles);
  102. void LvInsertIpRangeInOrder(tstring& strNewIpRange);
  103. void UpdateInfo();
  104. int CheckDupRegAddr();
  105. int CheckOverlappedIpRange();
  106. };
  107. //
  108. // CAtmAddrDlg
  109. //
  110. class CAtmAddrDlg : public CDialogImpl<CAtmAddrDlg>
  111. {
  112. public:
  113. enum { IDD = IDD_ARPS_REG_ADDR };
  114. BEGIN_MSG_MAP(CAtmAddrDlg)
  115. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
  116. MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu);
  117. MESSAGE_HANDLER(WM_HELP, OnHelp);
  118. COMMAND_ID_HANDLER(IDOK, OnOk);
  119. COMMAND_ID_HANDLER(IDCANCEL, OnCancel);
  120. COMMAND_ID_HANDLER(IDC_EDT_ARPS_REG_Address, OnChange);
  121. END_MSG_MAP()
  122. public:
  123. CAtmAddrDlg(CArpsPage * pAtmArpsPage, const DWORD* pamhidsHelp = NULL);
  124. ~CAtmAddrDlg(){};
  125. LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  126. LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  127. LRESULT OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  128. LRESULT OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  129. LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  130. LRESULT OnChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  131. friend class CArpsPage;
  132. private:
  133. HWND m_hOkButton; // this is the IDOK button, the text of the button changes
  134. // with the context.
  135. HWND m_hEditBox; // this is the edit box for the ATM address
  136. CArpsPage * m_pParentDlg;
  137. tstring m_strNewAtmAddr;
  138. const DWORD* m_adwHelpIDs;
  139. // HINSTANCE m_hInstance;
  140. };
  141. //
  142. // CIpAddrRangeDlg
  143. //
  144. class CIpAddrRangeDlg : public CDialogImpl<CIpAddrRangeDlg>
  145. {
  146. public:
  147. enum { IDD = IDD_ARPS_MUL_ADDR };
  148. BEGIN_MSG_MAP(CIpAddrRangeDlg)
  149. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
  150. MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu);
  151. MESSAGE_HANDLER(WM_HELP, OnHelp);
  152. COMMAND_ID_HANDLER(IDOK, OnOk);
  153. COMMAND_ID_HANDLER(IDCANCEL, OnCancel);
  154. COMMAND_ID_HANDLER(IDC_ARPS_MUL_LOWER_IP, OnChangeLowerIp)
  155. COMMAND_ID_HANDLER(IDC_ARPS_MUL_UPPER_IP, OnChangeUpperIp)
  156. NOTIFY_CODE_HANDLER(IPN_FIELDCHANGED, OnIpFieldChange)
  157. END_MSG_MAP()
  158. //
  159. public:
  160. CIpAddrRangeDlg( CArpsPage * pAtmArpsPage,
  161. const DWORD* pamhidsHelp = NULL);
  162. ~CIpAddrRangeDlg(){};
  163. // Dialog creation overides
  164. public:
  165. LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  166. LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  167. LRESULT OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  168. LRESULT OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  169. LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  170. LRESULT OnChangeLowerIp(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  171. LRESULT OnChangeUpperIp(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  172. LRESULT OnIpFieldChange(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  173. BOOL InitDialog();
  174. friend class CArpsPage;
  175. public:
  176. IpControl m_ipLower;
  177. IpControl m_ipUpper;
  178. private:
  179. // this is the IDOK button, the text of the button changes
  180. // with the context.
  181. HWND m_hOkButton;
  182. CArpsPage * m_pParentDlg;
  183. tstring m_strNewIpRange;
  184. tstring m_strNewIpLower;
  185. tstring m_strNewIpUpper;
  186. const DWORD* m_adwHelpIDs;
  187. };