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.

208 lines
6.0 KiB

  1. //#--------------------------------------------------------------
  2. //
  3. // File: hostname.h
  4. //
  5. // Synopsis: This file holds the declaration of the
  6. // CSADataEntryCtrl 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 __HOSTNAME_H_
  15. #define __HOSTNAME_H_
  16. #include "resource.h" // main symbols
  17. #include <atlctl.h>
  18. #include "LocalUIControlsCP.h"
  19. #define SADataEntryCtrlMaxSize 50
  20. #define SADataEntryCtrlDefaultSize 20
  21. const WCHAR szDefaultCharSet[] = L"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ";
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CSADataEntryCtrl
  24. class ATL_NO_VTABLE CSADataEntryCtrl :
  25. public CComObjectRootEx<CComSingleThreadModel>,
  26. public IDispatchImpl<ISADataEntryCtrl, &IID_ISADataEntryCtrl, &LIBID_LOCALUICONTROLSLib>,
  27. public CComControl<CSADataEntryCtrl>,
  28. public IOleControlImpl<CSADataEntryCtrl>,
  29. public IOleObjectImpl<CSADataEntryCtrl>,
  30. public IOleInPlaceActiveObjectImpl<CSADataEntryCtrl>,
  31. public IViewObjectExImpl<CSADataEntryCtrl>,
  32. public IOleInPlaceObjectWindowlessImpl<CSADataEntryCtrl>,
  33. public IConnectionPointContainerImpl<CSADataEntryCtrl>,
  34. public IQuickActivateImpl<CSADataEntryCtrl>,
  35. public IProvideClassInfo2Impl<&CLSID_SADataEntryCtrl, &DIID__ISADataEntryCtrlEvents, &LIBID_LOCALUICONTROLSLib>,
  36. public IPropertyNotifySinkCP<CSADataEntryCtrl>,
  37. public CComCoClass<CSADataEntryCtrl, &CLSID_SADataEntryCtrl>,
  38. public CProxy_ISADataEntryCtrlEvents< CSADataEntryCtrl >,
  39. public IObjectSafetyImpl<CSADataEntryCtrl,INTERFACESAFE_FOR_UNTRUSTED_CALLER>
  40. {
  41. public:
  42. CSADataEntryCtrl()
  43. {
  44. wcscpy(m_strTextValue,L"AAAAAAAAAAAAAAAAAAA");
  45. m_iPositionFocus = 0;
  46. m_lMaxSize = SADataEntryCtrlDefaultSize;
  47. m_szTextCharSet = szDefaultCharSet;
  48. m_hFont = NULL;
  49. }
  50. DECLARE_REGISTRY_RESOURCEID(IDR_SADATAENTRYCTRL)
  51. DECLARE_PROTECT_FINAL_CONSTRUCT()
  52. DECLARE_CLASSFACTORY_SINGLETON (CSADataEntryCtrl)
  53. BEGIN_COM_MAP(CSADataEntryCtrl)
  54. COM_INTERFACE_ENTRY(ISADataEntryCtrl)
  55. COM_INTERFACE_ENTRY(IDispatch)
  56. COM_INTERFACE_ENTRY(IViewObjectEx)
  57. COM_INTERFACE_ENTRY(IViewObject2)
  58. COM_INTERFACE_ENTRY(IViewObject)
  59. COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
  60. COM_INTERFACE_ENTRY(IOleInPlaceObject)
  61. COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
  62. COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
  63. COM_INTERFACE_ENTRY(IOleControl)
  64. COM_INTERFACE_ENTRY(IOleObject)
  65. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  66. COM_INTERFACE_ENTRY(IQuickActivate)
  67. COM_INTERFACE_ENTRY(IProvideClassInfo)
  68. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  69. COM_INTERFACE_ENTRY(IObjectSafety)
  70. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  71. END_COM_MAP()
  72. BEGIN_PROP_MAP(CSADataEntryCtrl)
  73. PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
  74. PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
  75. // Example entries
  76. // PROP_ENTRY("Property Description", dispid, clsid)
  77. // PROP_PAGE(CLSID_StockColorPage)
  78. END_PROP_MAP()
  79. BEGIN_CONNECTION_POINT_MAP(CSADataEntryCtrl)
  80. CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink)
  81. CONNECTION_POINT_ENTRY(DIID__ISADataEntryCtrlEvents)
  82. END_CONNECTION_POINT_MAP()
  83. BEGIN_MSG_MAP(CSADataEntryCtrl)
  84. MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
  85. CHAIN_MSG_MAP(CComControl<CSADataEntryCtrl>)
  86. DEFAULT_REFLECTION_HANDLER()
  87. END_MSG_MAP()
  88. // Handler prototypes:
  89. // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  90. // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  91. // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  92. // IViewObjectEx
  93. DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
  94. // ISADataEntryCtrl
  95. public:
  96. //
  97. // get current data display in the controls
  98. //
  99. STDMETHOD(get_TextValue)
  100. (
  101. /*[out, retval]*/ BSTR *pVal
  102. );
  103. //
  104. // set current data display in the controls
  105. //
  106. STDMETHOD(put_TextValue)
  107. (
  108. /*[in]*/ BSTR newVal
  109. );
  110. //
  111. // set the maximum number of chars the control can display
  112. //
  113. STDMETHOD(put_MaxSize)
  114. (
  115. /*[in]*/ LONG lMaxSize
  116. );
  117. //
  118. // set character set that can used in the data entry
  119. //
  120. STDMETHOD(put_TextCharSet)
  121. (
  122. /*[in]*/ BSTR newVal
  123. );
  124. //
  125. // IObjectSafety methods
  126. //
  127. STDMETHOD(SetInterfaceSafetyOptions)
  128. (
  129. REFIID riid,
  130. DWORD dwOptionSetMask,
  131. DWORD dwEnabledOptions
  132. )
  133. {
  134. return S_OK;
  135. }
  136. //
  137. // called just after constructor, initializes the component
  138. //
  139. STDMETHOD(FinalConstruct)(void);
  140. //
  141. // called just before destructor, releases resources
  142. //
  143. STDMETHOD(FinalRelease)(void);
  144. //
  145. // gets the current character set
  146. //
  147. BYTE GetCharacterSet ();
  148. //
  149. // handler for key messages
  150. //
  151. LRESULT OnKeyDown
  152. (
  153. UINT uMsg,
  154. WPARAM wParam,
  155. LPARAM lParam,
  156. BOOL& bHandled
  157. );
  158. //
  159. // method to draw the control
  160. //
  161. HRESULT OnDraw
  162. (
  163. ATL_DRAWINFO& di
  164. );
  165. //
  166. //
  167. //
  168. WCHAR m_strTextValue[SADataEntryCtrlMaxSize+1];
  169. LONG m_lMaxSize;
  170. CComBSTR m_szTextCharSet;
  171. int m_iPositionFocus;
  172. HFONT m_hFont;
  173. };
  174. #endif //__HOSTNAME_H_