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.

145 lines
5.1 KiB

  1. #ifndef _HOSTUTIL_H_
  2. #define _HOSTUTIL_H_
  3. // usefull macro's which aren't elsewhere
  4. #define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
  5. #define RECTWIDTH(rc) ((rc).right-(rc).left)
  6. #define RECTHEIGHT(rc) ((rc).bottom-(rc).top)
  7. // Balloon tip / infotip / tooltip helper
  8. HWND CreateBalloonTip(HWND hwndOwner, int x, int y, HFONT hf, UINT idsTitle, UINT idsText);
  9. void MakeMultilineTT(HWND hwndTT);
  10. LRESULT HandleApplyRegion(HWND hwnd, HTHEME hTheme,
  11. PSMNMAPPLYREGION par, int iPartId, int iStateId);
  12. class CPropBagFromReg : public IPropertyBag
  13. {
  14. private:
  15. HKEY _hk;
  16. DWORD _cref;
  17. CPropBagFromReg::CPropBagFromReg(HKEY hk);
  18. CPropBagFromReg::~CPropBagFromReg();
  19. public:
  20. STDMETHOD (QueryInterface) (REFIID riid, PVOID *ppvObject);
  21. STDMETHOD_(ULONG, AddRef)(void);
  22. STDMETHOD_(ULONG, Release)(void);
  23. STDMETHODIMP Read(LPCOLESTR pszPropName, VARIANT *pVar, IErrorLog *pErrorLog);
  24. STDMETHODIMP Write(LPCOLESTR pszPropName, VARIANT *pVar)
  25. {
  26. return E_NOTIMPL;
  27. }
  28. friend HRESULT CreatePropBagFromReg(LPCTSTR pszKey, IPropertyBag**pppb);
  29. };
  30. BOOL RectFromStrW(LPCWSTR pwsz, RECT *pr);
  31. //
  32. // To get a common implementation of IUnknown so the compiler can collapse
  33. // them all together.
  34. //
  35. class CUnknown : public IUnknown
  36. {
  37. public:
  38. virtual STDMETHODIMP QueryInterface(REFIID riid, void** ppvObj) PURE;
  39. virtual STDMETHODIMP_(ULONG) AddRef(void) { return ++_cRef; }
  40. virtual STDMETHODIMP_(ULONG) Release(void)
  41. {
  42. ULONG cRef = --_cRef;
  43. if (cRef == 0) {
  44. delete this;
  45. return 0;
  46. }
  47. return cRef;
  48. }
  49. virtual ~CUnknown() { } // Because we delete from the base class
  50. IUnknown *GetUnknown() { return this; }
  51. protected:
  52. CUnknown() : _cRef(1) { }
  53. LONG _cRef;
  54. };
  55. //
  56. // Implementation of IAccessible that wraps the default IAccessible
  57. // of a window, but allows people to override selected methods.
  58. //
  59. class CAccessible : public IAccessible
  60. {
  61. public:
  62. // *** IUnknown ***
  63. STDMETHOD(QueryInterface)(REFIID riid, LPVOID *ppvOut) PURE;
  64. STDMETHOD_(ULONG, AddRef)() PURE;
  65. STDMETHOD_(ULONG, Release)() PURE;
  66. // *** IDispatch ***
  67. STDMETHODIMP GetTypeInfoCount(UINT *pctinfo);
  68. STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo **pptinfo);
  69. STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR **rgszNames, UINT cNames,
  70. LCID lcid, DISPID *rgdispid);
  71. STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags,
  72. DISPPARAMS *pdispparams, VARIANT *pvarResult, EXCEPINFO *pexcepinfo,
  73. UINT *puArgErr);
  74. // *** IAccessible ***
  75. STDMETHODIMP get_accParent(IDispatch **ppdispParent);
  76. STDMETHODIMP get_accChildCount(long *pChildCount);
  77. STDMETHODIMP get_accChild(VARIANT varChildIndex, IDispatch **ppdispChild);
  78. STDMETHODIMP get_accName(VARIANT varChild, BSTR *pszName);
  79. STDMETHODIMP get_accValue(VARIANT varChild, BSTR *pszValue);
  80. STDMETHODIMP get_accDescription(VARIANT varChild, BSTR *pszDescription);
  81. STDMETHODIMP get_accRole(VARIANT varChild, VARIANT *pvarRole);
  82. STDMETHODIMP get_accState(VARIANT varChild, VARIANT *pvarState);
  83. STDMETHODIMP get_accHelp(VARIANT varChild, BSTR *pszHelp);
  84. STDMETHODIMP get_accHelpTopic(BSTR *pszHelpFile, VARIANT varChild, long *pidTopic);
  85. STDMETHODIMP get_accKeyboardShortcut(VARIANT varChild, BSTR *pszKeyboardShortcut);
  86. STDMETHODIMP get_accFocus(VARIANT *pvarFocusChild);
  87. STDMETHODIMP get_accSelection(VARIANT *pvarSelectedChildren);
  88. STDMETHODIMP get_accDefaultAction(VARIANT varChild, BSTR *pszDefaultAction);
  89. STDMETHODIMP accSelect(long flagsSelect, VARIANT varChild);
  90. STDMETHODIMP accLocation(long *pxLeft, long *pyTop, long *pcxWidth, long *pcyHeight, VARIANT varChild);
  91. STDMETHODIMP accNavigate(long navDir, VARIANT varStart, VARIANT *pvarEndUpAt);
  92. STDMETHODIMP accHitTest(long xLeft, long yTop, VARIANT *pvarChildAtPoint);
  93. STDMETHODIMP accDoDefaultAction(VARIANT varChild);
  94. STDMETHODIMP put_accName(VARIANT varChild, BSTR szName);
  95. STDMETHODIMP put_accValue(VARIANT varChild, BSTR pszValue);
  96. protected:
  97. ~CAccessible() { ATOMICRELEASE(_paccInner); }
  98. BOOL SetAccessibleSubclassWindow(HWND hwnd)
  99. {
  100. return SetWindowSubclass(hwnd, s_SubclassProc, 0,
  101. reinterpret_cast<DWORD_PTR>(this));
  102. }
  103. enum {
  104. ACCSTR_OPEN = -815,
  105. ACCSTR_CLOSE = -814,
  106. ACCSTR_EXECUTE = -842,
  107. };
  108. enum {
  109. E_NOT_APPLICABLE = DISP_E_MEMBERNOTFOUND,
  110. };
  111. static HRESULT GetRoleString(DWORD dwRole, BSTR *pbsOut);
  112. static HRESULT CreateAcceleratorBSTR(TCHAR tch, BSTR *pbsOut);
  113. private:
  114. static LRESULT CALLBACK s_SubclassProc(
  115. HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
  116. UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
  117. protected:
  118. IAccessible *_paccInner;
  119. };
  120. #endif // _HOSTUTIL_H_