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.

241 lines
7.1 KiB

  1. //#--------------------------------------------------------------
  2. //
  3. // File: staticip.cpp
  4. //
  5. // Synopsis: This file holds the declaration of the
  6. // of CStaticIp class
  7. //
  8. // History: 12/15/2000 serdarun Created
  9. //
  10. // Copyright (C) 1999-2000 Microsoft Corporation
  11. // All rights reserved.
  12. //
  13. //#--------------------------------------------------------------
  14. #ifndef __STATICIP_H_
  15. #define __STATICIP_H_
  16. #include "resource.h" // main symbols
  17. #include <atlctl.h>
  18. #include "LocalUIControlsCP.h"
  19. #include "salocmgr.h"
  20. #include "satrace.h"
  21. #define IpAddressSize 16
  22. #define IPHASFOCUS 1
  23. #define SUBNETHASFOCUS 2
  24. #define GATEWAYHASFOCUS 3
  25. #define LASTPOSITION 15
  26. #define FIRSTPOSITION 1
  27. #define NUMBEROFENTRIES 3
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CStaticIp
  30. class ATL_NO_VTABLE CStaticIp :
  31. public CComObjectRootEx<CComSingleThreadModel>,
  32. public IDispatchImpl<IStaticIp, &IID_IStaticIp, &LIBID_LOCALUICONTROLSLib>,
  33. public CComControl<CStaticIp>,
  34. public IPersistStreamInitImpl<CStaticIp>,
  35. public IOleControlImpl<CStaticIp>,
  36. public IOleObjectImpl<CStaticIp>,
  37. public IOleInPlaceActiveObjectImpl<CStaticIp>,
  38. public IViewObjectExImpl<CStaticIp>,
  39. public IOleInPlaceObjectWindowlessImpl<CStaticIp>,
  40. public IConnectionPointContainerImpl<CStaticIp>,
  41. public IPersistStorageImpl<CStaticIp>,
  42. public ISpecifyPropertyPagesImpl<CStaticIp>,
  43. public IQuickActivateImpl<CStaticIp>,
  44. public IDataObjectImpl<CStaticIp>,
  45. public IProvideClassInfo2Impl<&CLSID_StaticIp, &DIID__IStaticIpEvents, &LIBID_LOCALUICONTROLSLib>,
  46. public IPropertyNotifySinkCP<CStaticIp>,
  47. public CComCoClass<CStaticIp, &CLSID_StaticIp>,
  48. public CProxy_IStaticIpEvents< CStaticIp >,
  49. public IObjectSafetyImpl<CStaticIp,INTERFACESAFE_FOR_UNTRUSTED_CALLER>
  50. {
  51. public:
  52. CStaticIp()
  53. {
  54. wcscpy(m_strIpAddress,L"000.000.000.000");
  55. wcscpy(m_strSubnetMask,L"000.000.000.000");
  56. wcscpy(m_strGateway,L"000.000.000.000");
  57. m_iEntryFocus = IPHASFOCUS;
  58. m_iPositionFocus = 0;
  59. m_bstrIpHeader = L"";
  60. m_bstrSubnetHeader = L"";
  61. m_bstrDefaultGatewayHeader = L"";
  62. m_hFont = NULL;
  63. }
  64. DECLARE_REGISTRY_RESOURCEID(IDR_STATICIP)
  65. DECLARE_PROTECT_FINAL_CONSTRUCT()
  66. DECLARE_CLASSFACTORY_SINGLETON (CStaticIp)
  67. BEGIN_COM_MAP(CStaticIp)
  68. COM_INTERFACE_ENTRY(IStaticIp)
  69. COM_INTERFACE_ENTRY(IDispatch)
  70. COM_INTERFACE_ENTRY(IViewObjectEx)
  71. COM_INTERFACE_ENTRY(IViewObject2)
  72. COM_INTERFACE_ENTRY(IViewObject)
  73. COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
  74. COM_INTERFACE_ENTRY(IOleInPlaceObject)
  75. COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
  76. COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
  77. COM_INTERFACE_ENTRY(IOleControl)
  78. COM_INTERFACE_ENTRY(IOleObject)
  79. COM_INTERFACE_ENTRY(IPersistStreamInit)
  80. COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
  81. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  82. COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
  83. COM_INTERFACE_ENTRY(IQuickActivate)
  84. COM_INTERFACE_ENTRY(IPersistStorage)
  85. COM_INTERFACE_ENTRY(IDataObject)
  86. COM_INTERFACE_ENTRY(IProvideClassInfo)
  87. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  88. COM_INTERFACE_ENTRY(IObjectSafety)
  89. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  90. END_COM_MAP()
  91. BEGIN_PROP_MAP(CStaticIp)
  92. PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
  93. PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
  94. // Example entries
  95. // PROP_ENTRY("Property Description", dispid, clsid)
  96. // PROP_PAGE(CLSID_StockColorPage)
  97. END_PROP_MAP()
  98. BEGIN_CONNECTION_POINT_MAP(CStaticIp)
  99. CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink)
  100. CONNECTION_POINT_ENTRY(DIID__IStaticIpEvents)
  101. END_CONNECTION_POINT_MAP()
  102. BEGIN_MSG_MAP(CStaticIp)
  103. MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
  104. CHAIN_MSG_MAP(CComControl<CStaticIp>)
  105. DEFAULT_REFLECTION_HANDLER()
  106. END_MSG_MAP()
  107. // Handler prototypes:
  108. // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  109. // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  110. // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  111. // IViewObjectEx
  112. DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
  113. // IStaticIp
  114. public:
  115. STDMETHOD(get_Gateway)
  116. (
  117. /*[out, retval]*/ BSTR *pVal
  118. );
  119. STDMETHOD(put_Gateway)
  120. (
  121. /*[in]*/ BSTR newVal
  122. );
  123. STDMETHOD(get_SubnetMask)
  124. (
  125. /*[out, retval]*/ BSTR *pVal
  126. );
  127. STDMETHOD(put_SubnetMask)
  128. (
  129. /*[in]*/ BSTR newVal
  130. );
  131. STDMETHOD(get_IpAddress)
  132. (
  133. /*[out, retval]*/ BSTR *pVal
  134. );
  135. STDMETHOD(put_IpAddress)
  136. (
  137. /*[in]*/ BSTR newVal
  138. );
  139. // IObjectSafety
  140. STDMETHOD(SetInterfaceSafetyOptions)
  141. (
  142. REFIID riid,
  143. DWORD dwOptionSetMask,
  144. DWORD dwEnabledOptions
  145. )
  146. {
  147. return S_OK;
  148. }
  149. //
  150. // called just after constructor, gets the localized strings and creates the font
  151. //
  152. STDMETHOD(FinalConstruct)(void);
  153. //
  154. // called just before destructor, releases resources
  155. //
  156. STDMETHOD(FinalRelease)(void);
  157. //
  158. // gets the current character set
  159. //
  160. BYTE GetCharacterSet ();
  161. HRESULT OnDraw
  162. (
  163. ATL_DRAWINFO& di
  164. );
  165. LRESULT OnKeyDown
  166. (
  167. UINT uMsg,
  168. WPARAM wParam,
  169. LPARAM lParam,
  170. BOOL& bHandled
  171. );
  172. void ProcessArrowKey
  173. (
  174. WCHAR * strFocus,
  175. WPARAM wParam
  176. );
  177. void CreateFocusString
  178. (
  179. WCHAR * strFocus,
  180. WCHAR * strEntry
  181. );
  182. HRESULT FormatAndCopy
  183. (
  184. /*[in]*/BSTR bstrValue,
  185. /*[in,out]*/ WCHAR *strValue
  186. );
  187. HRESULT TrimDuplicateZerosAndCopy
  188. (
  189. /*[in]*/WCHAR *strValue,
  190. /*[in,out]*/ BSTR *pNewVal
  191. );
  192. WCHAR m_strIpAddress[IpAddressSize];
  193. WCHAR m_strSubnetMask[IpAddressSize];
  194. WCHAR m_strGateway[IpAddressSize];
  195. int m_iEntryFocus;
  196. int m_iPositionFocus;
  197. CComBSTR m_bstrIpHeader;
  198. CComBSTR m_bstrSubnetHeader;
  199. CComBSTR m_bstrDefaultGatewayHeader;
  200. HFONT m_hFont;
  201. };
  202. #endif //__STATICIP_H_