ReactOS  0.4.13-dev-39-g8b6696f
shellclasses.cpp File Reference
#include <precomp.h>
Include dependency graph for shellclasses.cpp:

Go to the source code of this file.

Macros

#define CSIDL_FLAG_CREATE   0x8000
 

Functions

void HandleException (COMException &e, HWND hwnd)
 Exception Handler for COM exceptions. More...
 
ShellFolderGetDesktopFolder ()
 
HRESULT path_from_pidlA (IShellFolder *folder, LPCITEMIDLIST pidl, LPSTR buffer, int len)
 
HRESULT path_from_pidlW (IShellFolder *folder, LPCITEMIDLIST pidl, LPWSTR buffer, int len)
 
HRESULT name_from_pidl (IShellFolder *folder, LPCITEMIDLIST pidl, LPTSTR buffer, int len, SHGDNF flags)
 
UINT ILGetSize_local (LPCITEMIDLIST pidl)
 
HRESULT ShellFolderContextMenu (IShellFolder *shell_folder, HWND hwndParent, int cidl, LPCITEMIDLIST *apidl, int x, int y, CtxMenuInterfaces &cm_ifs)
 

Macro Definition Documentation

◆ CSIDL_FLAG_CREATE

#define CSIDL_FLAG_CREATE   0x8000

Definition at line 445 of file shellclasses.cpp.

Function Documentation

◆ GetDesktopFolder()

◆ HandleException()

void HandleException ( COMException e,
HWND  hwnd 
)

Exception Handler for COM exceptions.

Definition at line 93 of file shellclasses.cpp.

94 {
95  String msg = e.toString();
96 
97  SetLastError(0);
98 
99  if (hwnd && !IsWindowVisible(hwnd))
100  hwnd = 0;
101 
102  MessageBox(hwnd, msg, TEXT("ShellClasses Exception"), MB_ICONHAND|MB_OK);
103 
104  // If displaying the error message box _with_ parent was not successfull, display it now without a parent window.
106  MessageBox(0, msg, TEXT("ShellClasses Exception"), MB_ICONHAND|MB_OK);
107 }
#define MB_ICONHAND
Definition: winuser.h:782
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static WCHAR String[]
Definition: stringtable.c:55
#define e
Definition: ke_i.h:82
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881
#define SetLastError(x)
Definition: compat.h:409
#define MessageBox
Definition: winuser.h:5688
#define TEXT(s)
Definition: k32.h:26
#define MB_OK
Definition: winuser.h:784
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI IsWindowVisible(_In_ HWND)

Referenced by PropertySheetDialog::DoModal(), explorer_main(), StartMenu::Init(), ShellBrowser::InsertSubitems(), Window::MessageLoop(), MainFrameBase::OpenShellFolders(), ShellDirectory::read_directory(), StartMenuRoot::TrackStartmenu(), and WebChildWindow::WndProc().

◆ ILGetSize_local()

UINT ILGetSize_local ( LPCITEMIDLIST  pidl)

Definition at line 428 of file shellclasses.cpp.

429 {
430  if (!pidl)
431  return 0;
432 
433  int l = sizeof(USHORT/*SHITEMID::cb*/);
434 
435  while(pidl->mkid.cb) {
436  l += pidl->mkid.cb;
437  pidl = LPCITEMIDLIST((LPBYTE)pidl+pidl->mkid.cb);
438  }
439 
440  return l;
441 }
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
unsigned char * LPBYTE
Definition: typedefs.h:52
r l[0]
Definition: byte_order.h:167
unsigned short USHORT
Definition: pedump.c:61

◆ name_from_pidl()

HRESULT name_from_pidl ( IShellFolder folder,
LPCITEMIDLIST  pidl,
LPTSTR  buffer,
int  len,
SHGDNF  flags 
)

Definition at line 175 of file shellclasses.cpp.

176 {
177  CONTEXT("name_from_pidl()");
178 
179  StrRet str;
180 
181  HRESULT hr = folder->GetDisplayNameOf(pidl, flags, &str);
182 
183  if (SUCCEEDED(hr))
184  str.GetString(pidl->mkid, buffer, len);
185  else
186  buffer[0] = '\0';
187 
188  return hr;
189 }
struct _CONTEXT CONTEXT
Definition: fci.c:115
HRESULT hr
Definition: shlfolder.c:183
GLuint buffer
Definition: glext.h:5915
#define StrRet
Definition: shellclasses.h:871
const WCHAR * str
LONG HRESULT
Definition: typedefs.h:77
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by ShellDirectory::read_directory().

◆ path_from_pidlA()

HRESULT path_from_pidlA ( IShellFolder folder,
LPCITEMIDLIST  pidl,
LPSTR  buffer,
int  len 
)

Definition at line 143 of file shellclasses.cpp.

144 {
145  CONTEXT("path_from_pidlA()");
146 
147  StrRetA str;
148 
149  HRESULT hr = folder->GetDisplayNameOf(pidl, SHGDN_FORPARSING, &str);
150 
151  if (SUCCEEDED(hr))
152  str.GetString(pidl->mkid, buffer, len);
153  else
154  buffer[0] = '\0';
155 
156  return hr;
157 }
struct _CONTEXT CONTEXT
Definition: fci.c:115
HRESULT hr
Definition: shlfolder.c:183
easy retrieval of multi byte strings out of STRRET structures
Definition: shellclasses.h:879
GLuint buffer
Definition: glext.h:5915
const WCHAR * str
LONG HRESULT
Definition: typedefs.h:77
GLenum GLsizei len
Definition: glext.h:6722
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ path_from_pidlW()

HRESULT path_from_pidlW ( IShellFolder folder,
LPCITEMIDLIST  pidl,
LPWSTR  buffer,
int  len 
)

Definition at line 159 of file shellclasses.cpp.

160 {
161  CONTEXT("path_from_pidlW()");
162 
163  StrRetW str;
164 
165  HRESULT hr = folder->GetDisplayNameOf(pidl, SHGDN_FORPARSING, &str);
166 
167  if (SUCCEEDED(hr))
168  str.GetString(pidl->mkid, buffer, len);
169  else
170  buffer[0] = '\0';
171 
172  return hr;
173 }
struct _CONTEXT CONTEXT
Definition: fci.c:115
HRESULT hr
Definition: shlfolder.c:183
GLuint buffer
Definition: glext.h:5915
const WCHAR * str
easy retrieval of wide char strings out of STRRET structures
Definition: shellclasses.h:905
LONG HRESULT
Definition: typedefs.h:77
GLenum GLsizei len
Definition: glext.h:6722
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ ShellFolderContextMenu()

HRESULT ShellFolderContextMenu ( IShellFolder shell_folder,
HWND  hwndParent,
int  cidl,
LPCITEMIDLIST apidl,
int  x,
int  y,
CtxMenuInterfaces cm_ifs 
)

Definition at line 524 of file shellclasses.cpp.

526 {
527  IContextMenu* pcm;
528 
529  HRESULT hr = shell_folder->GetUIObjectOf(hwndParent, cidl, apidl, IID_IContextMenu, NULL, (LPVOID*)&pcm);
530 // HRESULT hr = CDefFolderMenu_Create2(dir?dir->_pidl:DesktopFolder(), hwndParent, 1, &pidl, shell_folder, NULL, 0, NULL, &pcm);
531 
532  if (SUCCEEDED(hr)) {
533  pcm = cm_ifs.query_interfaces(pcm);
534 
536 
537  if (hmenu) {
538  hr = pcm->QueryContextMenu(hmenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, CMF_NORMAL|CMF_EXPLORE);
539 
540  if (SUCCEEDED(hr)) {
542 
543  cm_ifs.reset();
544 
545  if (idCmd) {
546  CMINVOKECOMMANDINFO cmi;
547 
548  cmi.cbSize = sizeof(CMINVOKECOMMANDINFO);
549  cmi.fMask = 0;
550  cmi.hwnd = hwndParent;
551  cmi.lpVerb = (LPCSTR)(INT_PTR)(idCmd - FCIDM_SHVIEWFIRST);
552  cmi.lpParameters = NULL;
553  cmi.lpDirectory = NULL;
554  cmi.nShow = SW_SHOWNORMAL;
555  cmi.dwHotKey = 0;
556  cmi.hIcon = 0;
557 
558  hr = pcm->InvokeCommand(&cmi);
559  }
560  } else
561  cm_ifs.reset();
563  }
564 
565  pcm->Release();
566  }
567 
568  return hr;
569 }
HRESULT hr
Definition: shlfolder.c:183
static HMENU hmenu
Definition: win.c:66
#define TPM_LEFTALIGN
Definition: winuser.h:2331
#define TPM_RETURNCMD
Definition: winuser.h:2341
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define FCIDM_SHVIEWFIRST
Definition: shlobj.h:499
int32_t INT_PTR
Definition: typedefs.h:62
#define TPM_RIGHTBUTTON
Definition: winuser.h:2334
smooth NULL
Definition: ftsmooth.c:416
static HWND hwndParent
Definition: cryptui.c:300
const char * LPCSTR
Definition: xmlstorage.h:183
#define FCIDM_SHVIEWLAST
Definition: shlobj.h:532
LONG HRESULT
Definition: typedefs.h:77
nsrefcnt Release()
BOOL WINAPI DestroyMenu(_In_ HMENU)
IContextMenu * query_interfaces(IContextMenu *pcm1)
#define SW_SHOWNORMAL
Definition: winuser.h:764
unsigned int UINT
Definition: ndis.h:50
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:846
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
#define SUCCEEDED(hr)
Definition: intsafe.h:57
HRESULT GetUIObjectOf([in] HWND hwndOwner, [in] UINT cidl, [in, size_is(cidl)] PCUITEMID_CHILD_ARRAY apidl, [in] REFIID riid, [in, out, unique] UINT *prgfInOut, [out, iid_is(riid)] void **ppvOut)

Referenced by ShellEntry::do_context_menu(), Entry::do_context_menu(), and DesktopShellView::DoContextMenu().