1
0

WinApi.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. //---------------------------------------------------------------------------
  2. #ifndef WinApiH
  3. #define WinApiH
  4. //---------------------------------------------------------------------------
  5. // For other API definitions, see also PasTools.pas
  6. //---------------------------------------------------------------------------
  7. #include <shlobj.h>
  8. //---------------------------------------------------------------------------
  9. typedef BOOL WINAPI (* ChangeWindowMessageFilterExProc)(
  10. HWND hwnd, UINT message, DWORD action, PCHANGEFILTERSTRUCT pChangeFilterStruct);
  11. typedef BOOL WINAPI (* AddClipboardFormatListenerProc)(HWND hwnd);
  12. typedef BOOL WINAPI (* RemoveClipboardFormatListenerProc)(HWND hwnd);
  13. //---------------------------------------------------------------------------
  14. #define WM_DPICHANGED 0x02E0
  15. #define WM_GETDPISCALEDSIZE 0x02E4
  16. //---------------------------------------------------------------------------
  17. typedef enum _Monitor_DPI_Type {
  18. MDT_Effective_DPI = 0,
  19. MDT_Angular_DPI = 1,
  20. MDT_Raw_DPI = 2,
  21. MDT_Default = MDT_Effective_DPI
  22. } MONITOR_DPI_TYPE;
  23. //---------------------------------------------------------------------------
  24. typedef HRESULT WINAPI (* GetDpiForMonitorProc)(
  25. HMONITOR hmonitor, MONITOR_DPI_TYPE dpiType, UINT * dpiX, UINT * dpiY);
  26. //---------------------------------------------------------------------------
  27. //---------------------------------------------------------------------------
  28. // Taken from https://www.codeproject.com/Articles/35197/Undocumented-List-View-Features
  29. //---------------------------------------------------------------------------
  30. #define LVM_QUERYINTERFACE (LVM_FIRST + 189)
  31. //---------------------------------------------------------------------------
  32. // the interface's GUID
  33. extern const IID IID_IListView_Win7;
  34. //---------------------------------------------------------------------------
  35. class IOwnerDataCallback; // we do not need this interface, so we do not define it
  36. //---------------------------------------------------------------------------
  37. class IListView_Win7 : public IOleWindow
  38. {
  39. public:
  40. virtual HRESULT STDMETHODCALLTYPE GetImageList(int imageList, HIMAGELIST* pHImageList) = 0;
  41. virtual HRESULT STDMETHODCALLTYPE SetImageList(int imageList, HIMAGELIST hNewImageList, HIMAGELIST* pHOldImageList) = 0;
  42. virtual HRESULT STDMETHODCALLTYPE GetBackgroundColor(COLORREF* pColor) = 0;
  43. virtual HRESULT STDMETHODCALLTYPE SetBackgroundColor(COLORREF color) = 0;
  44. virtual HRESULT STDMETHODCALLTYPE GetTextColor(COLORREF* pColor) = 0;
  45. virtual HRESULT STDMETHODCALLTYPE SetTextColor(COLORREF color) = 0;
  46. virtual HRESULT STDMETHODCALLTYPE GetTextBackgroundColor(COLORREF* pColor) = 0;
  47. virtual HRESULT STDMETHODCALLTYPE SetTextBackgroundColor(COLORREF color) = 0;
  48. virtual HRESULT STDMETHODCALLTYPE GetHotLightColor(COLORREF* pColor) = 0;
  49. virtual HRESULT STDMETHODCALLTYPE SetHotLightColor(COLORREF color) = 0;
  50. virtual HRESULT STDMETHODCALLTYPE GetItemCount(PINT pItemCount) = 0;
  51. virtual HRESULT STDMETHODCALLTYPE SetItemCount(int itemCount, DWORD flags) = 0;
  52. virtual HRESULT STDMETHODCALLTYPE GetItem(LVITEMW* pItem) = 0;
  53. virtual HRESULT STDMETHODCALLTYPE SetItem(LVITEMW* const pItem) = 0;
  54. virtual HRESULT STDMETHODCALLTYPE GetItemState(int itemIndex, int subItemIndex, ULONG mask, ULONG* pState) = 0;
  55. virtual HRESULT STDMETHODCALLTYPE SetItemState(int itemIndex, int subItemIndex, ULONG mask, ULONG state) = 0;
  56. virtual HRESULT STDMETHODCALLTYPE GetItemText(int itemIndex, int subItemIndex, LPWSTR pBuffer, int bufferSize) = 0;
  57. virtual HRESULT STDMETHODCALLTYPE SetItemText(int itemIndex, int subItemIndex, LPCWSTR pText) = 0;
  58. virtual HRESULT STDMETHODCALLTYPE GetBackgroundImage(LVBKIMAGEW* pBkImage) = 0;
  59. virtual HRESULT STDMETHODCALLTYPE SetBackgroundImage(LVBKIMAGEW* const pBkImage) = 0;
  60. virtual HRESULT STDMETHODCALLTYPE GetFocusedColumn(PINT pColumnIndex) = 0;
  61. // parameters may be in wrong order
  62. virtual HRESULT STDMETHODCALLTYPE SetSelectionFlags(ULONG mask, ULONG flags) = 0;
  63. virtual HRESULT STDMETHODCALLTYPE GetSelectedColumn(PINT pColumnIndex) = 0;
  64. virtual HRESULT STDMETHODCALLTYPE SetSelectedColumn(int columnIndex) = 0;
  65. virtual HRESULT STDMETHODCALLTYPE GetView(DWORD* pView) = 0;
  66. virtual HRESULT STDMETHODCALLTYPE SetView(DWORD view) = 0;
  67. virtual HRESULT STDMETHODCALLTYPE InsertItem(LVITEMW* const pItem, PINT pItemIndex) = 0;
  68. virtual HRESULT STDMETHODCALLTYPE DeleteItem(int itemIndex) = 0;
  69. virtual HRESULT STDMETHODCALLTYPE DeleteAllItems(void) = 0;
  70. virtual HRESULT STDMETHODCALLTYPE UpdateItem(int itemIndex) = 0;
  71. virtual HRESULT STDMETHODCALLTYPE GetItemRect(LVITEMINDEX itemIndex, int rectangleType, LPRECT pRectangle) = 0;
  72. virtual HRESULT STDMETHODCALLTYPE GetSubItemRect(LVITEMINDEX itemIndex, int subItemIndex, int rectangleType, LPRECT pRectangle) = 0;
  73. virtual HRESULT STDMETHODCALLTYPE HitTestSubItem(LVHITTESTINFO* pHitTestData) = 0;
  74. virtual HRESULT STDMETHODCALLTYPE GetIncrSearchString(PWSTR pBuffer, int bufferSize, PINT pCopiedChars) = 0;
  75. // pHorizontalSpacing and pVerticalSpacing may be in wrong order
  76. virtual HRESULT STDMETHODCALLTYPE GetItemSpacing(BOOL smallIconView, PINT pHorizontalSpacing, PINT pVerticalSpacing) = 0;
  77. // parameters may be in wrong order
  78. virtual HRESULT STDMETHODCALLTYPE SetIconSpacing(int horizontalSpacing, int verticalSpacing, PINT pHorizontalSpacing, PINT pVerticalSpacing) = 0;
  79. virtual HRESULT STDMETHODCALLTYPE GetNextItem(LVITEMINDEX itemIndex, ULONG flags, LVITEMINDEX* pNextItemIndex) = 0;
  80. virtual HRESULT STDMETHODCALLTYPE FindItem(LVITEMINDEX startItemIndex, LVFINDINFOW const* pFindInfo, LVITEMINDEX* pFoundItemIndex) = 0;
  81. virtual HRESULT STDMETHODCALLTYPE GetSelectionMark(LVITEMINDEX* pSelectionMark) = 0;
  82. virtual HRESULT STDMETHODCALLTYPE SetSelectionMark(LVITEMINDEX newSelectionMark, LVITEMINDEX* pOldSelectionMark) = 0;
  83. virtual HRESULT STDMETHODCALLTYPE GetItemPosition(LVITEMINDEX itemIndex, POINT* pPosition) = 0;
  84. virtual HRESULT STDMETHODCALLTYPE SetItemPosition(int itemIndex, POINT const* pPosition) = 0;
  85. // parameters may be in wrong order
  86. virtual HRESULT STDMETHODCALLTYPE ScrollView(int horizontalScrollDistance, int verticalScrollDistance) = 0;
  87. virtual HRESULT STDMETHODCALLTYPE EnsureItemVisible(LVITEMINDEX itemIndex, BOOL partialOk) = 0;
  88. virtual HRESULT STDMETHODCALLTYPE EnsureSubItemVisible(LVITEMINDEX itemIndex, int subItemIndex) = 0;
  89. virtual HRESULT STDMETHODCALLTYPE EditSubItem(LVITEMINDEX itemIndex, int subItemIndex) = 0;
  90. virtual HRESULT STDMETHODCALLTYPE RedrawItems(int firstItemIndex, int lastItemIndex) = 0;
  91. virtual HRESULT STDMETHODCALLTYPE ArrangeItems(int mode) = 0;
  92. virtual HRESULT STDMETHODCALLTYPE RecomputeItems(int unknown) = 0;
  93. virtual HRESULT STDMETHODCALLTYPE GetEditControl(HWND* pHWndEdit) = 0;
  94. // TODO: verify that 'initialEditText' really is used to specify the initial text
  95. virtual HRESULT STDMETHODCALLTYPE EditLabel(LVITEMINDEX itemIndex, LPCWSTR initialEditText, HWND* phWndEdit) = 0;
  96. virtual HRESULT STDMETHODCALLTYPE EditGroupLabel(int groupIndex) = 0;
  97. virtual HRESULT STDMETHODCALLTYPE CancelEditLabel(void) = 0;
  98. virtual HRESULT STDMETHODCALLTYPE GetEditItem(LVITEMINDEX* itemIndex, PINT subItemIndex) = 0;
  99. virtual HRESULT STDMETHODCALLTYPE HitTest(LVHITTESTINFO* pHitTestData) = 0;
  100. virtual HRESULT STDMETHODCALLTYPE GetStringWidth(PCWSTR pString, PINT pWidth) = 0;
  101. virtual HRESULT STDMETHODCALLTYPE GetColumn(int columnIndex, LVCOLUMNW* pColumn) = 0;
  102. virtual HRESULT STDMETHODCALLTYPE SetColumn(int columnIndex, LVCOLUMNW* const pColumn) = 0;
  103. virtual HRESULT STDMETHODCALLTYPE GetColumnOrderArray(int numberOfColumns, PINT pColumns) = 0;
  104. virtual HRESULT STDMETHODCALLTYPE SetColumnOrderArray(int numberOfColumns, int const* pColumns) = 0;
  105. virtual HRESULT STDMETHODCALLTYPE GetHeaderControl(HWND* pHWndHeader) = 0;
  106. virtual HRESULT STDMETHODCALLTYPE InsertColumn(int insertAt, LVCOLUMNW* const pColumn, PINT pColumnIndex) = 0;
  107. virtual HRESULT STDMETHODCALLTYPE DeleteColumn(int columnIndex) = 0;
  108. virtual HRESULT STDMETHODCALLTYPE CreateDragImage(int itemIndex, POINT const* pUpperLeft, HIMAGELIST* pHImageList) = 0;
  109. virtual HRESULT STDMETHODCALLTYPE GetViewRect(RECT* pRectangle) = 0;
  110. virtual HRESULT STDMETHODCALLTYPE GetClientRect(BOOL unknown, RECT* pClientRectangle) = 0;
  111. virtual HRESULT STDMETHODCALLTYPE GetColumnWidth(int columnIndex, PINT pWidth) = 0;
  112. virtual HRESULT STDMETHODCALLTYPE SetColumnWidth(int columnIndex, int width) = 0;
  113. virtual HRESULT STDMETHODCALLTYPE GetCallbackMask(ULONG* pMask) = 0;
  114. virtual HRESULT STDMETHODCALLTYPE SetCallbackMask(ULONG mask) = 0;
  115. virtual HRESULT STDMETHODCALLTYPE GetTopIndex(PINT pTopIndex) = 0;
  116. virtual HRESULT STDMETHODCALLTYPE GetCountPerPage(PINT pCountPerPage) = 0;
  117. virtual HRESULT STDMETHODCALLTYPE GetOrigin(POINT* pOrigin) = 0;
  118. virtual HRESULT STDMETHODCALLTYPE GetSelectedCount(PINT pSelectedCount) = 0;
  119. // 'unknown' might specify whether to pass items' data or indexes
  120. virtual HRESULT STDMETHODCALLTYPE SortItems(BOOL unknown, LPARAM lParam, PFNLVCOMPARE pComparisonFunction) = 0;
  121. virtual HRESULT STDMETHODCALLTYPE GetExtendedStyle(DWORD* pStyle) = 0;
  122. // parameters may be in wrong order
  123. virtual HRESULT STDMETHODCALLTYPE SetExtendedStyle(DWORD mask, DWORD style, DWORD* pOldStyle) = 0;
  124. virtual HRESULT STDMETHODCALLTYPE GetHoverTime(UINT* pTime) = 0;
  125. virtual HRESULT STDMETHODCALLTYPE SetHoverTime(UINT time, UINT* pOldSetting) = 0;
  126. virtual HRESULT STDMETHODCALLTYPE GetToolTip(HWND* pHWndToolTip) = 0;
  127. virtual HRESULT STDMETHODCALLTYPE SetToolTip(HWND hWndToolTip, HWND* pHWndOldToolTip) = 0;
  128. virtual HRESULT STDMETHODCALLTYPE GetHotItem(LVITEMINDEX* pHotItem) = 0;
  129. virtual HRESULT STDMETHODCALLTYPE SetHotItem(LVITEMINDEX newHotItem, LVITEMINDEX* pOldHotItem) = 0;
  130. virtual HRESULT STDMETHODCALLTYPE GetHotCursor(HCURSOR* pHCursor) = 0;
  131. virtual HRESULT STDMETHODCALLTYPE SetHotCursor(HCURSOR hCursor, HCURSOR* pHOldCursor) = 0;
  132. // parameters may be in wrong order
  133. virtual HRESULT STDMETHODCALLTYPE ApproximateViewRect(int itemCount, PINT pWidth, PINT pHeight) = 0;
  134. virtual HRESULT STDMETHODCALLTYPE SetRangeObject(int unknown, LPVOID/*ILVRange**/ pObject) = 0;
  135. virtual HRESULT STDMETHODCALLTYPE GetWorkAreas(int numberOfWorkAreas, RECT* pWorkAreas) = 0;
  136. virtual HRESULT STDMETHODCALLTYPE SetWorkAreas(int numberOfWorkAreas, RECT const* pWorkAreas) = 0;
  137. virtual HRESULT STDMETHODCALLTYPE GetWorkAreaCount(PINT pNumberOfWorkAreas) = 0;
  138. virtual HRESULT STDMETHODCALLTYPE ResetEmptyText(void) = 0;
  139. virtual HRESULT STDMETHODCALLTYPE EnableGroupView(BOOL enable) = 0;
  140. virtual HRESULT STDMETHODCALLTYPE IsGroupViewEnabled(BOOL* pIsEnabled) = 0;
  141. virtual HRESULT STDMETHODCALLTYPE SortGroups(::PFNLVGROUPCOMPARE pComparisonFunction, PVOID lParam) = 0;
  142. virtual HRESULT STDMETHODCALLTYPE GetGroupInfo(int unknown1, int unknown2, LVGROUP* pGroup) = 0;
  143. virtual HRESULT STDMETHODCALLTYPE SetGroupInfo(int unknown, int groupID, LVGROUP* const pGroup) = 0;
  144. virtual HRESULT STDMETHODCALLTYPE GetGroupRect(BOOL unknown, int groupID, int rectangleType, RECT* pRectangle) = 0;
  145. virtual HRESULT STDMETHODCALLTYPE GetGroupState(int groupID, ULONG mask, ULONG* pState) = 0;
  146. virtual HRESULT STDMETHODCALLTYPE HasGroup(int groupID, BOOL* pHasGroup) = 0;
  147. virtual HRESULT STDMETHODCALLTYPE InsertGroup(int insertAt, LVGROUP* const pGroup, PINT pGroupID) = 0;
  148. virtual HRESULT STDMETHODCALLTYPE RemoveGroup(int groupID) = 0;
  149. virtual HRESULT STDMETHODCALLTYPE InsertGroupSorted(LVINSERTGROUPSORTED const* pGroup, PINT pGroupID) = 0;
  150. virtual HRESULT STDMETHODCALLTYPE GetGroupMetrics(LVGROUPMETRICS* pMetrics) = 0;
  151. virtual HRESULT STDMETHODCALLTYPE SetGroupMetrics(LVGROUPMETRICS* const pMetrics) = 0;
  152. virtual HRESULT STDMETHODCALLTYPE RemoveAllGroups(void) = 0;
  153. virtual HRESULT STDMETHODCALLTYPE GetFocusedGroup(PINT pGroupID) = 0;
  154. virtual HRESULT STDMETHODCALLTYPE GetGroupCount(PINT pCount) = 0;
  155. virtual HRESULT STDMETHODCALLTYPE SetOwnerDataCallback(IOwnerDataCallback* pCallback) = 0;
  156. virtual HRESULT STDMETHODCALLTYPE GetTileViewInfo(LVTILEVIEWINFO* pInfo) = 0;
  157. virtual HRESULT STDMETHODCALLTYPE SetTileViewInfo(LVTILEVIEWINFO* const pInfo) = 0;
  158. virtual HRESULT STDMETHODCALLTYPE GetTileInfo(LVTILEINFO* pTileInfo) = 0;
  159. virtual HRESULT STDMETHODCALLTYPE SetTileInfo(LVTILEINFO* const pTileInfo) = 0;
  160. virtual HRESULT STDMETHODCALLTYPE GetInsertMark(LVINSERTMARK* pInsertMarkDetails) = 0;
  161. virtual HRESULT STDMETHODCALLTYPE SetInsertMark(LVINSERTMARK const* pInsertMarkDetails) = 0;
  162. virtual HRESULT STDMETHODCALLTYPE GetInsertMarkRect(LPRECT pInsertMarkRectangle) = 0;
  163. virtual HRESULT STDMETHODCALLTYPE GetInsertMarkColor(COLORREF* pColor) = 0;
  164. virtual HRESULT STDMETHODCALLTYPE SetInsertMarkColor(COLORREF color, COLORREF* pOldColor) = 0;
  165. virtual HRESULT STDMETHODCALLTYPE HitTestInsertMark(POINT const* pPoint, LVINSERTMARK* pInsertMarkDetails) = 0;
  166. virtual HRESULT STDMETHODCALLTYPE SetInfoTip(LVSETINFOTIP* const pInfoTip) = 0;
  167. virtual HRESULT STDMETHODCALLTYPE GetOutlineColor(COLORREF* pColor) = 0;
  168. virtual HRESULT STDMETHODCALLTYPE SetOutlineColor(COLORREF color, COLORREF* pOldColor) = 0;
  169. virtual HRESULT STDMETHODCALLTYPE GetFrozenItem(PINT pItemIndex) = 0;
  170. // one parameter will be the item index; works in Icons view only
  171. virtual HRESULT STDMETHODCALLTYPE SetFrozenItem(int unknown1, int unknown2) = 0;
  172. virtual HRESULT STDMETHODCALLTYPE GetFrozenSlot(RECT* pUnknown) = 0;
  173. virtual HRESULT STDMETHODCALLTYPE SetFrozenSlot(int unknown1, POINT const* pUnknown2) = 0;
  174. virtual HRESULT STDMETHODCALLTYPE GetViewMargin(RECT* pMargin) = 0;
  175. virtual HRESULT STDMETHODCALLTYPE SetViewMargin(RECT const* pMargin) = 0;
  176. virtual HRESULT STDMETHODCALLTYPE SetKeyboardSelected(LVITEMINDEX itemIndex) = 0;
  177. virtual HRESULT STDMETHODCALLTYPE MapIndexToId(int itemIndex, PINT pItemID) = 0;
  178. virtual HRESULT STDMETHODCALLTYPE MapIdToIndex(int itemID, PINT pItemIndex) = 0;
  179. virtual HRESULT STDMETHODCALLTYPE IsItemVisible(LVITEMINDEX itemIndex, BOOL* pVisible) = 0;
  180. virtual HRESULT STDMETHODCALLTYPE EnableAlphaShadow(BOOL enable) = 0;
  181. virtual HRESULT STDMETHODCALLTYPE GetGroupSubsetCount(PINT pNumberOfRowsDisplayed) = 0;
  182. virtual HRESULT STDMETHODCALLTYPE SetGroupSubsetCount(int numberOfRowsToDisplay) = 0;
  183. virtual HRESULT STDMETHODCALLTYPE GetVisibleSlotCount(PINT pCount) = 0;
  184. virtual HRESULT STDMETHODCALLTYPE GetColumnMargin(RECT* pMargin) = 0;
  185. virtual HRESULT STDMETHODCALLTYPE SetSubItemCallback(LPVOID/*ISubItemCallback**/ pCallback) = 0;
  186. virtual HRESULT STDMETHODCALLTYPE GetVisibleItemRange(LVITEMINDEX* pFirstItem, LVITEMINDEX* pLastItem) = 0;
  187. virtual HRESULT STDMETHODCALLTYPE SetTypeAheadFlags(UINT mask, UINT flags) = 0;
  188. };
  189. //---------------------------------------------------------------------------
  190. //---------------------------------------------------------------------------
  191. #define EM_SETEDITSTYLEEX (WM_USER + 275)
  192. #define SES_EX_HANDLEFRIENDLYURL (0x100)
  193. //---------------------------------------------------------------------------
  194. //---------------------------------------------------------------------------
  195. // msi.h (available, but does not compile)
  196. extern "C"
  197. {
  198. #define MAX_GUID_CHARS 38
  199. #define INSTALLPROPERTY_INSTALLLOCATION __TEXT("InstallLocation")
  200. UINT WINAPI MsiEnumRelatedProductsW(
  201. __in LPCWSTR lpUpgradeCode, // upgrade code of products to enumerate
  202. __reserved DWORD dwReserved, // reserved, must be 0
  203. __in DWORD iProductIndex, // 0-based index into registered products
  204. __out_ecount(MAX_GUID_CHARS+1) LPWSTR lpProductBuf); // buffer of char count: 39 (size of string GUID)
  205. #define MsiEnumRelatedProducts MsiEnumRelatedProductsW
  206. //---------------------------------------------------------------------------
  207. UINT WINAPI MsiGetProductInfoW(
  208. __in LPCWSTR szProduct, // product code
  209. __in LPCWSTR szAttribute, // attribute name, case-sensitive
  210. __out_ecount_opt(*pcchValueBuf) LPWSTR lpValueBuf, // returned value, NULL if not desired
  211. __inout_opt LPDWORD pcchValueBuf); // in/out buffer character count
  212. #define MsiGetProductInfo MsiGetProductInfoW
  213. }
  214. //---------------------------------------------------------------------------
  215. #endif // WinApiH