ReactOS 0.4.15-dev-8236-g99f0937
CCopyMoveToMenu.cpp File Reference
#include "precomp.h"
Include dependency graph for CCopyMoveToMenu.cpp:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
static LRESULT CALLBACK WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static INT CALLBACK BrowseCallbackProc (HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
 
static HRESULT DoGetFileTitle (CStringW &strTitle, IDataObject *pDataObject)
 
static BOOL GetPreviousMenuItemInfo (HMENU hMenu, UINT iItem, LPMENUITEMINFOW lpmii)
 

Function Documentation

◆ BrowseCallbackProc()

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

Definition at line 64 of file CCopyMoveToMenu.cpp.

65{
66 CCopyMoveToMenu *this_ =
68
69 switch (uMsg)
70 {
72 {
74 this_ = reinterpret_cast<CCopyMoveToMenu *>(lpData);
75
76 // Select initial directory
78 reinterpret_cast<LPARAM>(static_cast<LPCITEMIDLIST>(this_->m_pidlFolder)));
79
80 // Set caption
81 CString strCaption(MAKEINTRESOURCEW(this_->GetCaptionStringID()));
82 SetWindowTextW(hwnd, strCaption);
83
84 // Set OK button text
85 CString strCopyOrMove(MAKEINTRESOURCEW(this_->GetButtonStringID()));
86 SetDlgItemText(hwnd, IDOK, strCopyOrMove);
87
88 // Subclassing
89 this_->m_fnOldWndProc =
90 reinterpret_cast<WNDPROC>(
92
93 // Disable OK
95 break;
96 }
97 case BFFM_SELCHANGED:
98 {
99 if (!this_)
100 break;
101
103 LPCITEMIDLIST pidl = reinterpret_cast<LPCITEMIDLIST>(lParam);
104
105 szPath[0] = 0;
107
108 if (ILIsEqual(pidl, this_->m_pidlFolder))
110 else if (PathFileExistsW(szPath) || _ILIsDesktop(pidl))
112 else
114
115 // the text box will be updated later soon, ignore it
117 break;
118 }
119 }
120
121 return FALSE;
122}
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
virtual UINT GetCaptionStringID() const =0
CComHeapPtr< ITEMIDLIST > m_pidlFolder
virtual UINT GetButtonStringID() const =0
WNDPROC m_fnOldWndProc
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1777
LPCWSTR szPath
Definition: env.c:37
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1342
BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:548
#define BFFM_SELCHANGED
Definition: shlobj.h:1237
#define BFFM_ENABLEOK
Definition: shlobj.h:1244
#define BFFM_SETSELECTION
Definition: shlobj.h:1256
#define BFFM_INITIALIZED
Definition: shlobj.h:1236
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
#define GWLP_WNDPROC
Definition: treelist.c:66
#define GWLP_USERDATA
Definition: treelist.c:63
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDOK
Definition: winuser.h:830
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2906
#define SetDlgItemText
Definition: winuser.h:5858
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ DoGetFileTitle()

static HRESULT DoGetFileTitle ( CStringW strTitle,
IDataObject pDataObject 
)
static

Definition at line 187 of file CCopyMoveToMenu.cpp.

188{
189 CDataObjectHIDA pCIDA(pDataObject);
190 if (FAILED_UNEXPECTEDLY(pCIDA.hr()))
191 return E_FAIL;
192
193 PCUIDLIST_ABSOLUTE pidlParent = HIDA_GetPIDLFolder(pCIDA);
194 if (!pidlParent)
195 {
196 ERR("HIDA_GetPIDLFolder failed\n");
197 return E_FAIL;
198 }
199
201 PCUIDLIST_RELATIVE pidlRelative = HIDA_GetPIDLItem(pCIDA, 0);
202 if (!pidlRelative)
203 {
204 ERR("HIDA_GetPIDLItem failed\n");
205 return E_FAIL;
206 }
207
208 CComHeapPtr<ITEMIDLIST> pidlCombine(ILCombine(pidlParent, pidlRelative));
209
210 if (!SHGetPathFromIDListW(pidlCombine, szPath))
211 {
212 ERR("Cannot get path\n");
213 return E_FAIL;
214 }
215
216 strTitle = PathFindFileNameW(szPath);
217 if (strTitle.IsEmpty())
218 return E_FAIL;
219
220 if (pCIDA->cidl > 1)
221 strTitle += L" ...";
222
223 return S_OK;
224}
#define ERR(fmt,...)
Definition: debug.h:113
bool IsEmpty() const noexcept
Definition: atlsimpstr.h:394
#define E_FAIL
Definition: ddrawi.h:102
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:394
#define S_OK
Definition: intsafe.h:52
#define L(x)
Definition: ntvdm.h:50
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:712
static PCUIDLIST_RELATIVE HIDA_GetPIDLItem(CIDA const *pida, SIZE_T i)
Definition: shellutils.h:619
static PCUIDLIST_ABSOLUTE HIDA_GetPIDLFolder(CIDA const *pida)
Definition: shellutils.h:614
const ITEMIDLIST_ABSOLUTE UNALIGNED * PCUIDLIST_ABSOLUTE
Definition: shtypes.idl:63
const ITEMIDLIST_RELATIVE UNALIGNED * PCUIDLIST_RELATIVE
Definition: shtypes.idl:57

Referenced by CCopyMoveToMenu::DoAction().

◆ GetPreviousMenuItemInfo()

static BOOL GetPreviousMenuItemInfo ( HMENU  hMenu,
UINT  iItem,
LPMENUITEMINFOW  lpmii 
)
static

Definition at line 261 of file CCopyMoveToMenu.cpp.

262{
264
265 while (iItem > 0)
266 {
267 bSuccess = GetMenuItemInfoW(hMenu, --iItem, TRUE, lpmii);
269 break;
270 }
271
272 return bSuccess;
273}
static BOOLEAN bSuccess
Definition: drive.cpp:433
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_MENU_ITEM_NOT_FOUND
Definition: winerror.h:937
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)

Referenced by CCopyToMenu::QueryContextMenu(), and CMoveToMenu::QueryContextMenu().

◆ WindowProc()

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

Definition at line 22 of file CCopyMoveToMenu.cpp.

23{
25 CCopyMoveToMenu *this_ =
27
28 switch (uMsg)
29 {
30 case WM_COMMAND:
31 {
32 switch (LOWORD(wParam))
33 {
35 {
36 if (HIWORD(wParam) == EN_CHANGE)
37 {
38 if (!this_->m_bIgnoreTextBoxChange)
39 {
40 // get the text
42 StrTrimW(szPath, L" \t");
43
44 // update OK button
46 SendMessageW(hwnd, BFFM_ENABLEOK, 0, bValid);
47
48 return 0;
49 }
50
51 // reset flag
53 }
54 break;
55 }
56 }
57 break;
58 }
59 }
60 return CallWindowProcW(this_->m_fnOldWndProc, hwnd, uMsg, wParam, lParam);
61}
WPARAM wParam
Definition: combotst.c:138
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1723
BOOL WINAPI StrTrimW(LPWSTR lpszStr, LPCWSTR lpszTrim)
Definition: string.c:1877
#define LOWORD(l)
Definition: pedump.c:82
#define PathIsRelative
Definition: shlwapi.h:951
#define IDC_BROWSE_FOR_FOLDER_FOLDER_TEXT
Definition: shresdef.h:439
#define _countof(array)
Definition: sndvol32.h:70
#define HIWORD(l)
Definition: typedefs.h:247
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
#define WM_COMMAND
Definition: winuser.h:1740
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define EN_CHANGE
Definition: winuser.h:2022

Referenced by BrowseCallbackProc().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )