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.

220 lines
4.1 KiB

  1. /*++
  2. Copyright (c) 1994-1998 Microsoft Corporation
  3. Module Name :
  4. ipctl.h
  5. Abstract:
  6. IP Address common control MFC wrapper definitions
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. #ifndef _IPCTL_H
  14. #define _IPCTL_H
  15. #if (_WIN32_IE < 0x0400)
  16. //
  17. // Defined in comctrl.h. Defined here because NT 5 MFC42.dll are
  18. // defined with _WIN32_IE 0x300
  19. //
  20. #pragma message("Warning: privately defining _WIN32_IE definitions")
  21. #define IPM_CLEARADDRESS (WM_USER+100)
  22. #define IPM_SETADDRESS (WM_USER+101)
  23. #define IPM_GETADDRESS (WM_USER+102)
  24. #define IPM_SETRANGE (WM_USER+103)
  25. #define IPM_SETFOCUS (WM_USER+104)
  26. #define IPM_ISBLANK (WM_USER+105)
  27. #define WC_IPADDRESSW L"SysIPAddress32"
  28. #define WC_IPADDRESSA "SysIPAddress32"
  29. #ifdef UNICODE
  30. #define WC_IPADDRESS WC_IPADDRESSW
  31. #else
  32. #define WC_IPADDRESS WC_IPADDRESSA
  33. #endif // UNICODE
  34. #endif // _WIN32_IE
  35. class COMDLL CIPAddressCtl : public CWnd
  36. {
  37. /*--
  38. Class Description:
  39. MFC IP Address control wrapper.
  40. Public Interface:
  41. CIPAddressCtl : Constructor
  42. ~CIPAddressCtl : Destructor
  43. Create : Create the control
  44. ClearAddress : Clear the address
  45. SetAddress : Set address to value
  46. GetAddress : Get address from the control
  47. SetRange : Set field to octet range
  48. SetFocus : Set focus on a specifc field
  49. IsBlank : Return true if the control is blank
  50. Notes:
  51. Either create control dynamically with Create method, or put in resource
  52. template as a user control of name "SysIPAddress32". In this case,
  53. common style DWORDs as follows:
  54. WS_BORDER | WS_CHILD | WS_VISIBLE 0x50800000
  55. --*/
  56. DECLARE_DYNAMIC(CIPAddressCtl)
  57. //
  58. // Constructor/Destructor
  59. //
  60. public:
  61. CIPAddressCtl();
  62. ~CIPAddressCtl();
  63. //
  64. // Interface
  65. //
  66. public:
  67. //
  68. // Create the control
  69. //
  70. BOOL Create(
  71. IN LPCTSTR lpszName,
  72. IN DWORD dwStyle,
  73. IN const RECT & rect,
  74. IN CWnd * pParentWnd,
  75. IN UINT nID
  76. );
  77. //
  78. // Clear the address in the control
  79. //
  80. void ClearAddress();
  81. //
  82. // Set the ip address value
  83. //
  84. void SetAddress(
  85. IN DWORD dwIPAddress
  86. );
  87. //
  88. // Get the ip address value.
  89. // Returns the number of non-blank values
  90. //
  91. int GetAddress(
  92. OUT LPDWORD lpdwIPAddress
  93. );
  94. //
  95. // Set the octet range of a field
  96. //
  97. void SetRange(
  98. IN int iField,
  99. IN BYTE bRange
  100. );
  101. //
  102. // Set focus on an octet field within the control
  103. //
  104. void SetFocus(
  105. IN int iField
  106. );
  107. //
  108. // Return TRUE if the control is blank
  109. //
  110. BOOL IsBlank();
  111. protected:
  112. static BOOL m_fClassRegistered;
  113. protected:
  114. static BOOL RegisterClass();
  115. };
  116. //
  117. // Inline Expansion
  118. //
  119. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  120. inline BOOL CIPAddressCtl::Create(
  121. IN LPCTSTR lpszName,
  122. IN DWORD dwStyle,
  123. IN const RECT & rect,
  124. IN CWnd * pParentWnd,
  125. IN UINT nID
  126. )
  127. {
  128. //
  129. // Create the control
  130. //
  131. return CWnd::Create(
  132. WC_IPADDRESS,
  133. lpszName,
  134. dwStyle,
  135. rect,
  136. pParentWnd,
  137. nID
  138. );
  139. }
  140. inline void CIPAddressCtl::ClearAddress()
  141. {
  142. SNDMSG(m_hWnd, IPM_CLEARADDRESS, 0, 0L);
  143. }
  144. inline void CIPAddressCtl::SetAddress(
  145. IN DWORD dwIPAddress
  146. )
  147. {
  148. SNDMSG(m_hWnd, IPM_SETADDRESS, 0, (LPARAM)dwIPAddress);
  149. }
  150. inline int CIPAddressCtl::GetAddress(
  151. OUT LPDWORD lpdwIPAddress
  152. )
  153. {
  154. return (int)SNDMSG(m_hWnd, IPM_GETADDRESS, 0, (LPARAM)lpdwIPAddress);
  155. }
  156. inline void CIPAddressCtl::SetRange(
  157. IN int iField,
  158. IN BYTE bRange
  159. )
  160. {
  161. SNDMSG(m_hWnd, IPM_SETRANGE, (WPARAM)iField, (LPARAM)bRange);
  162. }
  163. inline void CIPAddressCtl::SetFocus(
  164. IN int iField
  165. )
  166. {
  167. SNDMSG(m_hWnd, IPM_SETFOCUS, (WPARAM)iField, 0L);
  168. }
  169. inline BOOL CIPAddressCtl::IsBlank()
  170. {
  171. return (BOOL)SNDMSG(m_hWnd, IPM_ISBLANK, 0, 0L);
  172. }
  173. #endif // _IPCTL_H