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.

257 lines
9.0 KiB

  1. //-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: T C P D N S . H
  7. //
  8. // Contents: CTcpDnsPage, CServerDialog and CSuffixDialog declaration
  9. //
  10. // Notes: The DNS page and related dialogs
  11. //
  12. // Author: tongl 11 Nov 1997
  13. //
  14. //-----------------------------------------------------------------------
  15. #pragma once
  16. #include <ncxbase.h>
  17. #include <ncatlps.h>
  18. #include "ipctrl.h"
  19. // maximum number of characters in the suffix edit control
  20. const int SUFFIX_LIMIT = 255;
  21. //maximum length of domain name
  22. const int DOMAIN_LIMIT = 255;
  23. class CTcpDnsPage : public CPropSheetPage
  24. {
  25. public:
  26. // Declare the message map
  27. BEGIN_MSG_MAP(CTcpDnsPage)
  28. // Initialize dialog
  29. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  30. MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu)
  31. MESSAGE_HANDLER(WM_HELP, OnHelp)
  32. // Property page notification message handlers
  33. NOTIFY_CODE_HANDLER(PSN_APPLY, OnApply)
  34. NOTIFY_CODE_HANDLER(PSN_KILLACTIVE, OnKillActive)
  35. NOTIFY_CODE_HANDLER(PSN_SETACTIVE, OnActive)
  36. NOTIFY_CODE_HANDLER(PSN_RESET, OnCancel)
  37. // Control message handlers
  38. // Push button message handlers
  39. COMMAND_ID_HANDLER(IDC_DNS_SERVER_ADD, OnAddServer)
  40. COMMAND_ID_HANDLER(IDC_DNS_SERVER_EDIT, OnEditServer)
  41. COMMAND_ID_HANDLER(IDC_DNS_SERVER_REMOVE, OnRemoveServer)
  42. COMMAND_ID_HANDLER(IDC_DNS_SERVER_UP, OnServerUp)
  43. COMMAND_ID_HANDLER(IDC_DNS_SERVER_DOWN, OnServerDown)
  44. COMMAND_ID_HANDLER(IDC_DNS_DOMAIN, OnDnsDomain)
  45. COMMAND_ID_HANDLER(IDC_DNS_SEARCH_DOMAIN, OnSearchDomain)
  46. COMMAND_ID_HANDLER(IDC_DNS_SEARCH_PARENT_DOMAIN, OnSearchParentDomain)
  47. COMMAND_ID_HANDLER(IDC_DNS_USE_SUFFIX_LIST, OnUseSuffix)
  48. COMMAND_ID_HANDLER(IDC_DNS_ADDR_REG, OnAddressRegister)
  49. COMMAND_ID_HANDLER(IDC_DNS_NAME_REG, OnDomainNameRegister)
  50. COMMAND_ID_HANDLER(IDC_DNS_SUFFIX_ADD, OnAddSuffix)
  51. COMMAND_ID_HANDLER(IDC_DNS_SUFFIX_EDIT, OnEditSuffix)
  52. COMMAND_ID_HANDLER(IDC_DNS_SUFFIX_REMOVE, OnRemoveSuffix)
  53. COMMAND_ID_HANDLER(IDC_DNS_SUFFIX_UP, OnSuffixUp)
  54. COMMAND_ID_HANDLER(IDC_DNS_SUFFIX_DOWN, OnSuffixDown)
  55. // Notification handlers
  56. COMMAND_ID_HANDLER(IDC_DNS_SERVER_LIST, OnServerList)
  57. COMMAND_ID_HANDLER(IDC_DNS_SUFFIX_LIST, OnSuffixList)
  58. END_MSG_MAP()
  59. // Constructors/Destructors
  60. CTcpDnsPage(CTcpAddrPage * pTcpAddrPage,
  61. ADAPTER_INFO * pAdapterDlg,
  62. GLOBAL_INFO * pGlbDlg,
  63. const DWORD * adwHelpIDs = NULL);
  64. ~CTcpDnsPage();
  65. // Interface
  66. public:
  67. // message map functions
  68. LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  69. LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  70. LRESULT OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  71. // notify handlers for the property page
  72. LRESULT OnApply(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  73. LRESULT OnKillActive(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  74. LRESULT OnActive(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  75. LRESULT OnCancel(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  76. // DNS server list
  77. LRESULT OnAddServer(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  78. LRESULT OnEditServer(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  79. LRESULT OnRemoveServer(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  80. LRESULT OnServerUp(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  81. LRESULT OnServerDown(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  82. // DNS domain
  83. LRESULT OnDnsDomain(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  84. // Search order radio buttons
  85. LRESULT OnSearchDomain(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  86. LRESULT OnSearchParentDomain(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  87. LRESULT OnUseSuffix(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  88. // DNS suffix list
  89. LRESULT OnAddSuffix(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  90. LRESULT OnEditSuffix(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  91. LRESULT OnRemoveSuffix(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  92. LRESULT OnSuffixUp(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  93. LRESULT OnSuffixDown(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  94. LRESULT OnServerList(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  95. LRESULT OnSuffixList(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  96. // ip address and name dynamic registration
  97. LRESULT OnAddressRegister(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  98. LRESULT OnDomainNameRegister(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  99. // Handlers
  100. public:
  101. void OnServerChange();
  102. void OnSuffixChange();
  103. // Attributes
  104. public:
  105. tstring m_strNewIpAddress; // server: either the one added, or edited
  106. tstring m_strNewSuffix;
  107. // server: used as work space for moving entries in the listboxes
  108. tstring m_strMovingEntry;
  109. tstring m_strAddServer; // OK or Add button server dialog
  110. tstring m_strAddSuffix; // OK or Add button suffix dialog
  111. BOOL m_fEditState;
  112. HANDLES m_hServers;
  113. HANDLES m_hSuffix;
  114. private:
  115. CTcpAddrPage * m_pParentDlg;
  116. ADAPTER_INFO * m_pAdapterInfo;
  117. GLOBAL_INFO * m_pglb;
  118. BOOL m_fModified;
  119. const DWORD* m_adwHelpIDs;
  120. // Inlines
  121. BOOL IsModified() {return m_fModified;}
  122. void SetModifiedTo(BOOL bState) {m_fModified = bState;}
  123. void PageModified() { m_fModified = TRUE; PropSheet_Changed(GetParent(), m_hWnd);}
  124. // help functions
  125. void EnableSuffixGroup(BOOL fEnable);
  126. };
  127. class CServerDialog : public CDialogImpl<CServerDialog>
  128. {
  129. public:
  130. enum { IDD = IDD_DNS_SERVER };
  131. BEGIN_MSG_MAP(CServerDialog)
  132. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
  133. MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu);
  134. MESSAGE_HANDLER(WM_HELP, OnHelp);
  135. MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor);
  136. COMMAND_ID_HANDLER(IDOK, OnOk);
  137. COMMAND_ID_HANDLER(IDCANCEL, OnCancel);
  138. COMMAND_ID_HANDLER(IDC_DNS_CHANGE_SERVER, OnChange);
  139. NOTIFY_CODE_HANDLER(IPN_FIELDCHANGED, OnIpFieldChange)
  140. END_MSG_MAP()
  141. public:
  142. CServerDialog(CTcpDnsPage * pTcpDnsPage, const DWORD* pamhidsHelp = NULL, int iIndex = -1);
  143. ~CServerDialog(){};
  144. LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  145. LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  146. LRESULT OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  147. LRESULT OnSetCursor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  148. LRESULT OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  149. LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  150. LRESULT OnChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  151. LRESULT OnIpFieldChange(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  152. // Dialog creation overides
  153. public:
  154. IpControl m_ipAddress;
  155. private:
  156. HWND m_hButton; // this is the IDOK button, the text of the button changes
  157. // with the context.
  158. CTcpDnsPage * m_pParentDlg;
  159. const DWORD * m_adwHelpIDs;
  160. int m_iIndex;
  161. };
  162. class CSuffixDialog : public CDialogImpl<CSuffixDialog>
  163. {
  164. public:
  165. enum { IDD = IDD_DNS_SUFFIX };
  166. BEGIN_MSG_MAP(CSuffixDialog)
  167. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
  168. MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu);
  169. MESSAGE_HANDLER(WM_HELP, OnHelp);
  170. MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor);
  171. COMMAND_ID_HANDLER(IDOK, OnOk);
  172. COMMAND_ID_HANDLER(IDCANCEL, OnCancel);
  173. COMMAND_ID_HANDLER(IDC_DNS_CHANGE_SUFFIX, OnChange);
  174. END_MSG_MAP()
  175. //
  176. public:
  177. CSuffixDialog(CTcpDnsPage * pTcpDnsPage, const DWORD* pamhidsHelp = NULL, int iIndex = -1);
  178. ~CSuffixDialog(){};
  179. LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  180. LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  181. LRESULT OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  182. LRESULT OnSetCursor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  183. LRESULT OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  184. LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  185. LRESULT OnChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  186. private:
  187. HWND m_hEdit; //
  188. HWND m_hButton; // this is the IDOK button, the text of the button changes
  189. // with the context.
  190. CTcpDnsPage * m_pParentDlg;
  191. const DWORD * m_adwHelpIDs;
  192. int m_iIndex;
  193. };