ReactOS  0.4.15-dev-1177-g6cb3b62
CCopyToMenu.cpp File Reference
#include "precomp.h"
Include dependency graph for CCopyToMenu.cpp:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
HRESULT _GetCidlFromDataObject (IDataObject *pDataObject, CIDA **ppcida)
 
static LRESULT CALLBACK WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static int CALLBACK BrowseCallbackProc (HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
 

Function Documentation

◆ _GetCidlFromDataObject()

HRESULT _GetCidlFromDataObject ( IDataObject pDataObject,
CIDA **  ppcida 
)

Definition at line 12 of file CCopyToMenu.cpp.

13 {
14  static CLIPFORMAT s_cfHIDA = 0;
15  if (s_cfHIDA == 0)
16  {
17  s_cfHIDA = static_cast<CLIPFORMAT>(RegisterClipboardFormatW(CFSTR_SHELLIDLIST));
18  }
19 
20  FORMATETC fmt = { s_cfHIDA, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
21  STGMEDIUM medium;
22 
23  HRESULT hr = pDataObject->GetData(&fmt, &medium);
25  return hr;
26 
27  LPVOID lpSrc = GlobalLock(medium.hGlobal);
28  SIZE_T cbSize = GlobalSize(medium.hGlobal);
29 
30  *ppcida = reinterpret_cast<CIDA *>(::CoTaskMemAlloc(cbSize));
31  if (*ppcida)
32  {
33  memcpy(*ppcida, lpSrc, cbSize);
34  hr = S_OK;
35  }
36  else
37  {
38  ERR("Out of memory\n");
39  hr = E_FAIL;
40  }
41  ReleaseStgMedium(&medium);
42  return hr;
43 }
#define CFSTR_SHELLIDLIST
Definition: shlobj.h:477
HRESULT hr
Definition: shlfolder.c:183
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)
#define E_FAIL
Definition: ddrawi.h:102
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:79
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERR(fmt,...)
Definition: debug.h:110
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define S_OK
Definition: intsafe.h:51
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
Definition: dsound.c:943

Referenced by CCopyToMenu::DoGetFileTitle(), and CCopyToMenu::DoRealCopy().

◆ BrowseCallbackProc()

static int CALLBACK BrowseCallbackProc ( HWND  hwnd,
UINT  uMsg,
LPARAM  lParam,
LPARAM  lpData 
)
static

Definition at line 101 of file CCopyToMenu.cpp.

102 {
103  CCopyToMenu *this_ =
104  reinterpret_cast<CCopyToMenu *>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
105 
106  switch (uMsg)
107  {
108  case BFFM_INITIALIZED:
109  {
111  this_ = reinterpret_cast<CCopyToMenu *>(lpData);
112 
113  // Select initial directory
115  reinterpret_cast<LPARAM>(static_cast<LPCITEMIDLIST>(this_->m_pidlFolder)));
116 
117  // Set caption
119  SetWindowTextW(hwnd, strCaption);
120 
121  // Set OK button text
123  SetDlgItemText(hwnd, IDOK, strCopy);
124 
125  // Subclassing
126  this_->m_fnOldWndProc =
127  reinterpret_cast<WNDPROC>(
128  SetWindowLongPtr(hwnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(WindowProc)));
129 
130  // Disable OK
132  break;
133  }
134  case BFFM_SELCHANGED:
135  {
137  LPCITEMIDLIST pidl = reinterpret_cast<LPCITEMIDLIST>(lParam);
138 
139  szPath[0] = 0;
141 
142  if (ILIsEqual(pidl, this_->m_pidlFolder))
144  else if (PathFileExistsW(szPath) || _ILIsDesktop(pidl))
146  else
148 
149  // the text box will be updated later soon, ignore it
150  this_->m_bIgnoreTextBoxChange = TRUE;
151  break;
152  }
153  }
154 
155  return FALSE;
156 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define IDOK
Definition: winuser.h:824
#define TRUE
Definition: types.h:120
CComHeapPtr< ITEMIDLIST > m_pidlFolder
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1294
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: CCopyToMenu.cpp:59
#define BFFM_INITIALIZED
Definition: shlobj.h:1163
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:535
#define IDS_COPYBUTTON
Definition: shresdef.h:303
#define SetWindowLongPtr
Definition: treelist.c:70
#define FALSE
Definition: types.h:117
#define BFFM_SETSELECTION
Definition: shlobj.h:1183
#define GWLP_USERDATA
Definition: treelist.c:63
WNDPROC m_fnOldWndProc
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1756
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
#define SetDlgItemText
Definition: winuser.h:5824
BOOL m_bIgnoreTextBoxChange
#define GWLP_WNDPROC
Definition: treelist.c:66
#define BFFM_ENABLEOK
Definition: shlobj.h:1171
LPCWSTR szPath
Definition: env.c:35
#define BFFM_SELCHANGED
Definition: shlobj.h:1164
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDS_COPYITEMS
Definition: shresdef.h:302
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define GetWindowLongPtr
Definition: treelist.c:73
LPARAM lParam
Definition: combotst.c:139

Referenced by CCopyToMenu::DoCopyToFolder().

◆ WindowProc()

static LRESULT CALLBACK WindowProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 59 of file CCopyToMenu.cpp.

60 {
62  CCopyToMenu *this_ =
63  reinterpret_cast<CCopyToMenu *>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
64 
65  switch (uMsg)
66  {
67  case WM_COMMAND:
68  {
69  switch (LOWORD(wParam))
70  {
72  {
73  if (HIWORD(wParam) == EN_CHANGE)
74  {
75  if (!this_->m_bIgnoreTextBoxChange)
76  {
77  // get the text
79  StrTrimW(szPath, L" \t");
80 
81  // update OK button
83  SendMessageW(hwnd, BFFM_ENABLEOK, 0, bValid);
84 
85  return 0;
86  }
87 
88  // reset flag
90  }
91  break;
92  }
93  }
94  break;
95  }
96  }
97  return CallWindowProcW(this_->m_fnOldWndProc, hwnd, uMsg, wParam, lParam);
98 }
#define IDC_BROWSE_FOR_FOLDER_FOLDER_TEXT
Definition: shresdef.h:387
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1702
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2271
#define PathIsRelative
Definition: shlwapi.h:951
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GWLP_USERDATA
Definition: treelist.c:63
WNDPROC m_fnOldWndProc
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
static const WCHAR L[]
Definition: oid.c:1250
#define WM_COMMAND
Definition: winuser.h:1722
BOOL m_bIgnoreTextBoxChange
#define BFFM_ENABLEOK
Definition: shlobj.h:1171
LPCWSTR szPath
Definition: env.c:35
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI StrTrimW(LPWSTR lpszStr, LPCWSTR lpszTrim)
Definition: string.c:1869
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define HIWORD(l)
Definition: typedefs.h:247
#define GetWindowLongPtr
Definition: treelist.c:73
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define EN_CHANGE
Definition: winuser.h:2004

Referenced by BrowseCallbackProc().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )