ReactOS  0.4.14-dev-317-g96040ec
rosordinal.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Shell
3  * LICENSE: GPL - See COPYING in the top level directory
4  * PURPOSE: Misc shell helper functions
5  * COPYRIGHT: Copyright 2015 Giannis Adamopoulos
6  */
7 
8 #include "precomp.h"
9 
10 /* http://undoc.airesoft.co.uk/shlwapi.dll/SHForwardContextMenuMsg.php */
12  LPARAM lParam, LRESULT* pResult, BOOL useIContextMenu2)
13 {
14  HRESULT hr;
15  IContextMenu3* pcmenu3;
16  IContextMenu2* pcmenu2;
17 
18  /* First try to use the IContextMenu3 interface */
19  hr = IUnknown_QueryInterface(pUnk, &IID_IContextMenu3, (void**)&pcmenu3);
20  if (SUCCEEDED(hr))
21  {
22  hr = IContextMenu3_HandleMenuMsg2(pcmenu3, uMsg, wParam, lParam, pResult);
23  IContextMenu3_Release(pcmenu3);
24  return hr;
25  }
26 
27  /* Return failure if we can't use the IContextMenu2 interface */
28  if(!useIContextMenu2)
29  return hr;
30 
31  /* Now try to use the IContextMenu2 interface */
32  hr = IUnknown_QueryInterface(pUnk, &IID_IContextMenu2, (void**)&pcmenu2);
33  if (FAILED(hr))
34  return hr;
35 
36  hr = IContextMenu2_HandleMenuMsg(pcmenu2, uMsg, wParam, lParam);
37  IContextMenu2_Release(pcmenu2);
38  return hr;
39 }
40 
41 /* http://undoc.airesoft.co.uk/shlwapi.dll/SHAreIconsEqual.php */
42 
44 {
45  ICONINFO iconInfo1, iconInfo2;
46  BITMAP bm1, bm2;
47  BOOL bSame = FALSE;
48 
49  if (!hIcon1 || !hIcon2)
50  return FALSE;
51 
52  if (!GetIconInfo(hIcon1, &iconInfo1))
53  return FALSE;
54 
55  if (!GetIconInfo(hIcon2, &iconInfo2))
56  {
57  DeleteObject(iconInfo1.hbmColor);
58  DeleteObject(iconInfo1.hbmMask);
59  return FALSE;
60  }
61 
62  GetObjectW(iconInfo1.hbmColor, sizeof(bm1), &bm1);
63  GetObjectW(iconInfo2.hbmColor, sizeof(bm2), &bm2);
64 
65  if (bm1.bmWidth == bm2.bmWidth && bm1.bmHeight == bm2.bmHeight)
66  {
67  BITMAPINFO bmi = { { sizeof(bmi), bm1.bmWidth, bm1.bmHeight, 1, 32 } };
68  HDC hdc = GetDC(0);
69  SIZE_T size = bm1.bmWidth * bm1.bmHeight * 4;
70  BYTE *data1, *data2;
71 
74 
75  if (data1 && data2)
76  {
77  if (GetDIBits(hdc, iconInfo1.hbmColor, 0, bm1.bmHeight, data1, &bmi, DIB_RGB_COLORS) &&
78  GetDIBits(hdc, iconInfo2.hbmColor, 0, bm2.bmHeight, data2, &bmi, DIB_RGB_COLORS))
79  {
80  bSame = memcmp(data1, data2, size) == 0;
81  }
82  }
85 
86  ReleaseDC(NULL, hdc);
87  }
88 
89  DeleteObject(iconInfo1.hbmColor);
90  DeleteObject(iconInfo1.hbmMask);
91 
92  DeleteObject(iconInfo2.hbmColor);
93  DeleteObject(iconInfo2.hbmMask);
94 
95  return bSame;
96 }
static HICON
Definition: imagelist.c:84
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
HRESULT hr
Definition: shlfolder.c:183
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
BOOL WINAPI SHAreIconsEqual(HICON hIcon1, HICON hIcon2)
Definition: rosordinal.c:43
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
Definition: tftpd.h:125
UINT_PTR WPARAM
Definition: windef.h:207
BOOL WINAPI GetIconInfo(_In_ HICON, _Out_ PICONINFO)
Definition: cursoricon.c:2014
WPARAM wParam
Definition: combotst.c:138
HRESULT WINAPI SHForwardContextMenuMsg(IUnknown *pUnk, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *pResult, BOOL useIContextMenu2)
Definition: rosordinal.c:11
unsigned int BOOL
Definition: ntddk_ex.h:94
HBITMAP hbmMask
Definition: winuser.h:3100
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
HBITMAP hbmColor
Definition: winuser.h:3101
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
static HICON hIcon2
#define WINAPI
Definition: msvc.h:8
HDC hdc
Definition: main.c:9
unsigned char BYTE
Definition: mem.h:68
ULONG_PTR SIZE_T
Definition: typedefs.h:78
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
static const WCHAR data1[]
Definition: db.c:2967
static const WCHAR data2[]
Definition: db.c:2971
Definition: bl.h:1331
unsigned int UINT
Definition: ndis.h:50
int WINAPI GetDIBits(_In_ HDC hdc, _In_ HBITMAP hbm, _In_ UINT start, _In_ UINT cLines, _Out_opt_ LPVOID lpvBits, _At_((LPBITMAPINFOHEADER) lpbmi, _Inout_) LPBITMAPINFO lpbmi, _In_ UINT usage)
LONG_PTR LRESULT
Definition: windef.h:209
#define DIB_RGB_COLORS
Definition: wingdi.h:366
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
LPARAM lParam
Definition: combotst.c:139
#define HeapFree(x, y, z)
Definition: compat.h:394
#define SUCCEEDED(hr)
Definition: intsafe.h:57
Definition: tftpd.h:137