ReactOS 0.4.15-dev-7906-g1b85a5f
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
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 hIcon2
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
unsigned int BOOL
Definition: ntddk_ex.h:94
pKey DeleteObject()
GLsizeiptr size
Definition: glext.h:5919
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
static HICON
Definition: imagelist.c:84
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI SHAreIconsEqual(HICON hIcon1, HICON hIcon2)
Definition: rosordinal.c:43
HRESULT WINAPI SHForwardContextMenuMsg(IUnknown *pUnk, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *pResult, BOOL useIContextMenu2)
Definition: rosordinal.c:11
HRESULT hr
Definition: shlfolder.c:183
Definition: bl.h:1331
HBITMAP hbmColor
Definition: winuser.h:3127
HBITMAP hbmMask
Definition: winuser.h:3126
Definition: tftpd.h:126
Definition: tftpd.h:138
ULONG_PTR SIZE_T
Definition: typedefs.h:80
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
#define DIB_RGB_COLORS
Definition: wingdi.h:367
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
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)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
BOOL WINAPI GetIconInfo(_In_ HICON, _Out_ PICONINFO)
Definition: cursoricon.c:2045
HDC WINAPI GetDC(_In_opt_ HWND)
unsigned char BYTE
Definition: xxhash.c:193