ReactOS 0.4.15-dev-7998-gdb93cb1
utils.cpp File Reference
#include "precomp.h"
#include <shellapi.h>
#include <shlwapi.h>
#include <shlwapi_undoc.h>
#include <shlobj_undoc.h>
#include <shlguid_undoc.h>
#include <atlstr.h>
#include <strsafe.h>
Include dependency graph for utils.cpp:

Go to the source code of this file.

Macros

#define _ATL_NO_EXCEPTIONS
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
EXTERN_C BOOL WINAPI IContextMenu_Invoke (_In_ IContextMenu *pContextMenu, _In_ HWND hwnd, _In_ LPCSTR lpVerb, _In_ UINT uFlags)
 

Macro Definition Documentation

◆ _ATL_NO_EXCEPTIONS

#define _ATL_NO_EXCEPTIONS

Definition at line 8 of file utils.cpp.

Function Documentation

◆ IContextMenu_Invoke()

EXTERN_C BOOL WINAPI IContextMenu_Invoke ( _In_ IContextMenu pContextMenu,
_In_ HWND  hwnd,
_In_ LPCSTR  lpVerb,
_In_ UINT  uFlags 
)

Definition at line 27 of file utils.cpp.

32{
33 CMINVOKECOMMANDINFO info;
34 BOOL ret = FALSE;
35 INT iDefItem = 0;
36 HMENU hMenu = NULL;
37 HCURSOR hOldCursor;
38
39 TRACE("(%p, %p, %s, %u)\n", pContextMenu, hwnd, debugstr_a(lpVerb), uFlags);
40
41 if (!pContextMenu)
42 return FALSE;
43
44 hOldCursor = SetCursor(LoadCursorW(NULL, (LPCWSTR)IDC_WAIT));
45
46 ZeroMemory(&info, sizeof(info));
47 info.cbSize = sizeof(info);
48 info.hwnd = hwnd;
49 info.nShow = SW_NORMAL;
50 info.lpVerb = lpVerb;
51
52 if (IS_INTRESOURCE(lpVerb))
53 {
54 hMenu = CreatePopupMenu();
55 if (hMenu)
56 {
57 pContextMenu->QueryContextMenu(hMenu, 0, 1, MAXSHORT, uFlags | CMF_DEFAULTONLY);
58 iDefItem = GetMenuDefaultItem(hMenu, 0, 0);
59 if (iDefItem != -1)
60 info.lpVerb = MAKEINTRESOURCEA(iDefItem - 1);
61 }
62 }
63
64 if (iDefItem != -1 || info.lpVerb)
65 {
66 if (!hwnd)
67 info.fMask |= CMIC_MASK_FLAG_NO_UI;
68 ret = SUCCEEDED(pContextMenu->InvokeCommand(&info));
69 }
70
71 /* Invoking itself doesn't need the menu object, but getting the command info
72 needs the menu. */
73 if (hMenu)
74 DestroyMenu(hMenu);
75
76 SetCursor(hOldCursor);
77
78 return ret;
79}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
UINT uFlags
Definition: api.c:59
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_a
Definition: kernel32.h:31
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
#define TRACE(s)
Definition: solgame.cpp:4
int32_t INT
Definition: typedefs.h:58
#define MAXSHORT
Definition: umtypes.h:114
int ret
#define ZeroMemory
Definition: winbase.h:1712
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
HICON HCURSOR
Definition: windef.h:299
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:838
UINT WINAPI GetMenuDefaultItem(_In_ HMENU hMenu, _In_ UINT fByPos, _In_ UINT gmdiFlags)
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2136
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define IDC_WAIT
Definition: winuser.h:689
#define SW_NORMAL
Definition: winuser.h:769
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )