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.

269 lines
9.0 KiB

  1. //-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: D L G A D D R M . H
  7. //
  8. // Contents: Declaration of CAdvIPAddrPage, CAddressDialog and
  9. // CGatewayDialog
  10. //
  11. // Notes: CAdvIPAddrPage is the IP setting page
  12. //
  13. // Author: tongl 5 Nov 1997
  14. //
  15. //-----------------------------------------------------------------------
  16. #pragma once
  17. #include "ipctrl.h"
  18. #include "tcperror.h"
  19. #include <ncxbase.h>
  20. #include <ncatlps.h>
  21. // Number of columns in the IDS_IPADDRESS_TEXT listview
  22. const int c_nColumns = 2;
  23. class CIpSettingsPage : public CPropSheetPage
  24. {
  25. public:
  26. BEGIN_MSG_MAP(CIpSettingsPage)
  27. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
  28. MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu);
  29. MESSAGE_HANDLER(WM_HELP, OnHelp);
  30. // Property page notification message handlers
  31. NOTIFY_CODE_HANDLER(PSN_APPLY, OnApply)
  32. NOTIFY_CODE_HANDLER(PSN_KILLACTIVE, OnKillActive)
  33. NOTIFY_CODE_HANDLER(PSN_SETACTIVE, OnActive)
  34. NOTIFY_CODE_HANDLER(PSN_RESET, OnCancel)
  35. NOTIFY_CODE_HANDLER(PSN_QUERYCANCEL, OnQueryCancel)
  36. COMMAND_ID_HANDLER(IDC_IPADDR_ADDIP, OnAddIp);
  37. COMMAND_ID_HANDLER(IDC_IPADDR_EDITIP, OnEditIp);
  38. COMMAND_ID_HANDLER(IDC_IPADDR_REMOVEIP, OnRemoveIp);
  39. COMMAND_ID_HANDLER(IDC_IPADDR_ADDGATE, OnAddGate);
  40. COMMAND_ID_HANDLER(IDC_IPADDR_EDITGATE, OnEditGate);
  41. COMMAND_ID_HANDLER(IDC_IPADDR_REMOVEGATE, OnRemoveGate);
  42. COMMAND_ID_HANDLER(IDC_AUTO_METRIC, OnAutoMetric)
  43. END_MSG_MAP()
  44. public:
  45. CIpSettingsPage(CTcpAddrPage * pTcpAddrPage,
  46. ADAPTER_INFO * pAdapterInfo,
  47. const DWORD* pamhidsHelp = NULL);
  48. ~CIpSettingsPage();
  49. // Dialog creation overrides
  50. public:
  51. LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  52. LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  53. LRESULT OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  54. // notify handlers for the property page
  55. LRESULT OnActive(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  56. LRESULT OnKillActive(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  57. LRESULT OnApply(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  58. LRESULT OnCancel(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  59. LRESULT OnQueryCancel(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  60. LRESULT OnAddIp(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  61. LRESULT OnEditIp(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  62. LRESULT OnRemoveIp(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  63. LRESULT OnAddGate(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  64. LRESULT OnEditGate(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  65. LRESULT OnRemoveGate(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  66. LRESULT OnAutoMetric(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  67. LRESULT OnUp(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  68. LRESULT OnDown(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  69. LRESULT OnGatewaySelChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  70. friend class CAddressDialog;
  71. friend class CGatewayDialog;
  72. private:
  73. // functions
  74. void SetIpInfo();
  75. void SetIpButtons();
  76. void UpdateIpList();
  77. void SetGatewayInfo();
  78. void SetGatewayButtons();
  79. void UpdateGatewayList();
  80. void EnableIpButtons(BOOL fState);
  81. // Inlines
  82. BOOL IsModified() {return m_fModified;}
  83. void SetModifiedTo(BOOL bState) {m_fModified = bState;}
  84. void PageModified() { m_fModified = TRUE; PropSheet_Changed(GetParent(), m_hWnd);}
  85. // data members
  86. CTcpAddrPage * m_pParentDlg;
  87. ADAPTER_INFO * m_pAdapterInfo;
  88. const DWORD * m_adwHelpIDs;
  89. BOOL m_fModified;
  90. // are we adding or editting
  91. BOOL m_fEditState;
  92. tstring m_strAdd;
  93. HWND m_hIpListView; // IP/Subnet list view
  94. HWND m_hAddIp; // IP buttons
  95. HWND m_hEditIp;
  96. HWND m_hRemoveIp;
  97. HWND m_hGatewayListView;
  98. HWND m_hAddGateway;
  99. HWND m_hEditGateway;
  100. HWND m_hRemoveGateway;
  101. tstring m_strRemovedIpAddress;
  102. tstring m_strRemovedSubnetMask;
  103. tstring m_strRemovedGateway;
  104. UINT m_uiRemovedMetric;
  105. };
  106. class CAddressDialog : public CDialogImpl<CAddressDialog>
  107. {
  108. public:
  109. enum { IDD = IDD_IPADDR_ADV_CHANGEIP };
  110. BEGIN_MSG_MAP(CAddressDialog)
  111. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
  112. MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu);
  113. MESSAGE_HANDLER(WM_HELP, OnHelp);
  114. MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor);
  115. COMMAND_ID_HANDLER(IDOK, OnOk);
  116. COMMAND_ID_HANDLER(IDCANCEL, OnCancel);
  117. COMMAND_ID_HANDLER(IDC_IPADDR_ADV_CHANGEIP_IP, OnChangeIp)
  118. COMMAND_ID_HANDLER(IDC_IPADDR_ADV_CHANGEIP_SUB, OnChangeSub)
  119. NOTIFY_CODE_HANDLER(IPN_FIELDCHANGED, OnIpFieldChange)
  120. END_MSG_MAP()
  121. //
  122. public:
  123. CAddressDialog( CIpSettingsPage * pDlgAdvanced,
  124. const DWORD* pamhidsHelp = NULL,
  125. int iIndex = -1);
  126. ~CAddressDialog(){};
  127. // Dialog creation overides
  128. public:
  129. LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  130. LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  131. LRESULT OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  132. LRESULT OnSetCursor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  133. LRESULT OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  134. LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  135. LRESULT OnChangeIp(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  136. LRESULT OnChangeSub(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  137. LRESULT OnIpFieldChange(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  138. // Command Handlers
  139. public:
  140. void OnIpChange();
  141. void OnSubnetChange();
  142. void OnEditSetFocus(WORD nId);
  143. public:
  144. IpControl m_ipAddress;
  145. IpControl m_ipSubnetMask;
  146. tstring m_strNewIpAddress; // either the one added, or edited
  147. tstring m_strNewSubnetMask; // either the one added, or edited
  148. private:
  149. // this is the IDOK button, the text of the button changes
  150. // with the context.
  151. HWND m_hButton;
  152. CIpSettingsPage * m_pParentDlg;
  153. const DWORD * m_adwHelpIDs;
  154. int m_iIndex;
  155. };
  156. class CGatewayDialog : public CDialogImpl<CGatewayDialog>
  157. {
  158. public:
  159. enum { IDD = IDD_IPADDR_ADV_CHANGEGATE };
  160. BEGIN_MSG_MAP(CAddressDialog)
  161. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
  162. MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu);
  163. MESSAGE_HANDLER(WM_HELP, OnHelp);
  164. MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor);
  165. COMMAND_ID_HANDLER(IDOK, OnOk);
  166. COMMAND_ID_HANDLER(IDCANCEL, OnCancel);
  167. COMMAND_ID_HANDLER(IDC_IPADDR_ADV_CHANGE_GATEWAY, OnGatewayChange);
  168. COMMAND_ID_HANDLER(IDC_IPADDR_ADV_CHANGE_METRIC, OnMetricChange);
  169. COMMAND_ID_HANDLER(IDC_IPADDR_ADV_CHANGE_AUTOMETRIC, OnAutoMetric)
  170. NOTIFY_CODE_HANDLER(IPN_FIELDCHANGED, OnIpFieldChange)
  171. END_MSG_MAP()
  172. public:
  173. CGatewayDialog( CIpSettingsPage * pDlgAdvanced,
  174. const DWORD* pamhidsHelp = NULL,
  175. int iIndex = -1);
  176. ~CGatewayDialog(){};
  177. public:
  178. LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  179. LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  180. LRESULT OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  181. LRESULT OnSetCursor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  182. LRESULT OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  183. LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  184. LRESULT OnGatewayChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  185. LRESULT OnMetricChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  186. LRESULT OnAutoMetric(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  187. LRESULT OnIpFieldChange(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  188. // Dialog creation overides
  189. public:
  190. IpControl m_ipGateAddress;
  191. tstring m_strNewGate; // either the one added, or edited
  192. UINT m_uiNewMetric;
  193. private:
  194. // this is the IDOK button, the text of the button changes
  195. // with the context.
  196. HWND m_hButton;
  197. CIpSettingsPage * m_pParentDlg;
  198. const DWORD * m_adwHelpIDs;
  199. BOOL m_fValidMetric;
  200. int m_iIndex;
  201. };