ReactOS 0.4.17-dev-683-g0dafdc5
CCopyMoveToMenu.cpp File Reference
#include "precomp.h"
Include dependency graph for CCopyMoveToMenu.cpp:

Go to the source code of this file.

Enumerations

enum  { IDC_ACTION = 0 }
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
static BOOL IsValidTarget (CCopyMoveToMenu *pThis, LPCITEMIDLIST pidl)
 
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 (const CIDA *pCIDA, CStringW &strTitle)
 
static BOOL GetPreviousMenuItemInfo (HMENU hMenu, UINT iItem, LPMENUITEMINFOW lpmii)
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
IDC_ACTION 

Definition at line 12 of file CCopyMoveToMenu.cpp.

12{ IDC_ACTION = 0 };
@ IDC_ACTION

Function Documentation

◆ BrowseCallbackProc()

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

Definition at line 76 of file CCopyMoveToMenu.cpp.

77{
78 CCopyMoveToMenu *this_ = reinterpret_cast<CCopyMoveToMenu*>(lpData);
79
80 switch (uMsg)
81 {
83 {
84 // Set caption
85 CString strCaption(MAKEINTRESOURCEW(this_->GetCaptionStringID()));
86 SetWindowTextW(hwnd, strCaption);
87
88 // Set OK button text
89 CString strCopyOrMove(MAKEINTRESOURCEW(this_->GetButtonStringID()));
90 SetDlgItemText(hwnd, IDOK, strCopyOrMove);
91
92 // Subclassing
93 // TODO: Replace this with BIF_VALIDATE
95 this_->m_fnOldWndProc =
96 reinterpret_cast<WNDPROC>(
98
99 // Expand "My Computer"
101 if (drivesPidl)
103
104 // Select initial directory
105 // TODO: Remember the last directory used by the user
107 if (pidl)
109
110 SendMessageW(hwnd, BFFM_ENABLEOK, 0, pidl && IsValidTarget(this_, pidl));
111 break;
112 }
113 case BFFM_SELCHANGED:
114 {
115 LPCITEMIDLIST pidl = reinterpret_cast<LPCITEMIDLIST>(lParam);
116 PostMessageW(hwnd, BFFM_ENABLEOK, 0, IsValidTarget(this_, pidl));
117
118 // the text box will be updated later soon, ignore it
120 break;
121 }
122 }
123
124 return FALSE;
125}
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
static BOOL IsValidTarget(CCopyMoveToMenu *pThis, LPCITEMIDLIST pidl)
virtual UINT GetCaptionStringID() const =0
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
LONG_PTR LPARAM
Definition: minwindef.h:175
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
LPITEMIDLIST WINAPI SHCloneSpecialIDList(HWND hwndOwner, int nFolder, BOOL fCreate)
Definition: pidl.c:446
#define BFFM_SELCHANGED
Definition: shlobj.h:1253
#define CSIDL_PERSONAL
Definition: shlobj.h:2196
#define BFFM_SETEXPANDED
Definition: shlobj.h:1265
#define BFFM_ENABLEOK
Definition: shlobj.h:1260
#define BFFM_SETSELECTION
Definition: shlobj.h:1272
#define BFFM_INITIALIZED
Definition: shlobj.h:1252
#define CSIDL_DRIVES
Definition: shlobj.h:2207
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#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
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDOK
Definition: winuser.h:841
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:3014
#define SetDlgItemText
Definition: winuser.h:6015
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

◆ DoGetFileTitle()

static HRESULT DoGetFileTitle ( const CIDA pCIDA,
CStringW strTitle 
)
static

Definition at line 177 of file CCopyMoveToMenu.cpp.

178{
179 CComHeapPtr<ITEMIDLIST> pidlCombine(SHELL_CIDA_ILCloneFull(pCIDA, 0));
180 if (!pidlCombine)
181 return E_OUTOFMEMORY;
182
184 HRESULT hr = SHGetNameAndFlagsW(pidlCombine, SHGDN_INFOLDER, szPath, _countof(szPath), NULL);
185 strTitle = SUCCEEDED(hr) ? szPath : L"";
186 if (strTitle.IsEmpty())
187 return E_FAIL;
188
189 if (pCIDA->cidl > 1)
190 strTitle += L" ...";
191 return S_OK;
192}
bool IsEmpty() const noexcept
Definition: atlsimpstr.h:394
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_FAIL
Definition: ddrawi.h:102
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
PIDLIST_ABSOLUTE SHELL_CIDA_ILCloneFull(_In_ const CIDA *pCIDA, _In_ UINT Index)
HRESULT SHGetNameAndFlagsW(_In_ LPCITEMIDLIST pidl, _In_ DWORD dwFlags, _Out_opt_ LPWSTR pszText, _In_ UINT cchBuf, _Inout_opt_ DWORD *pdwAttributes)
Definition: utils.cpp:551
#define L(x)
Definition: resources.c:13
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
LPCWSTR szPath
Definition: env.c:37
short WCHAR
Definition: pedump.c:58
#define _countof(array)
Definition: sndvol32.h:70
UINT cidl
Definition: shlobj.h:582

Referenced by CCopyMoveToMenu::DoAction().

◆ GetPreviousMenuItemInfo()

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

Definition at line 235 of file CCopyMoveToMenu.cpp.

236{
237 BOOL bSuccess = FALSE;
238
239 while (iItem > 0)
240 {
241 bSuccess = GetMenuItemInfoW(hMenu, --iItem, TRUE, lpmii);
242 if (bSuccess || (!bSuccess && GetLastError() != ERROR_MENU_ITEM_NOT_FOUND))
243 break;
244 }
245
246 return bSuccess;
247}
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:1282
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)

Referenced by CCopyMoveToMenu::QueryContextMenuImpl().

◆ IsValidTarget()

static BOOL IsValidTarget ( CCopyMoveToMenu pThis,
LPCITEMIDLIST  pidl 
)
static

Definition at line 21 of file CCopyMoveToMenu.cpp.

22{
24
25 if (ILIsEqual(pidl, pThis->m_pidlFolder))
26 return pThis->GetFileOp() == FO_COPY;
27
30 return _ILIsDesktop(pidl) || PathFileExistsW(szPath);
31}
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
CComHeapPtr< ITEMIDLIST > m_pidlFolder
virtual UINT GetFileOp() const =0
BOOL WINAPI PathFileExistsW(const WCHAR *path)
Definition: path.c:2583
#define UNICODE_NULL
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1496
BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:583
#define FO_COPY
Definition: shellapi.h:137

Referenced by BrowseCallbackProc().

◆ WindowProc()

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

Definition at line 34 of file CCopyMoveToMenu.cpp.

35{
37 CCopyMoveToMenu *this_ =
39
40 switch (uMsg)
41 {
42 case WM_COMMAND:
43 {
44 switch (LOWORD(wParam))
45 {
47 {
48 if (HIWORD(wParam) == EN_CHANGE)
49 {
50 if (!this_->m_bIgnoreTextBoxChange)
51 {
52 // get the text
54 StrTrimW(szPath, L" \t");
55
56 // update OK button
58 SendMessageW(hwnd, BFFM_ENABLEOK, 0, bValid);
59
60 return 0;
61 }
62
63 // reset flag
65 }
66 break;
67 }
68 }
69 break;
70 }
71 }
72 return CallWindowProcW(this_->m_fnOldWndProc, hwnd, uMsg, wParam, lParam);
73}
WPARAM wParam
Definition: combotst.c:138
BOOL WINAPI StrTrimW(WCHAR *str, const WCHAR *trim)
Definition: string.c:804
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:669
#define LOWORD(l)
Definition: pedump.c:82
#define PathIsRelative
Definition: shlwapi.h:483
#define IDC_BROWSE_FOR_FOLDER_FOLDER_TEXT
Definition: shresdef.h:478
#define GetWindowLongPtr
Definition: treelist.c:73
#define HIWORD(l)
Definition: typedefs.h:247
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2283
#define WM_COMMAND
Definition: winuser.h:1768
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define EN_CHANGE
Definition: winuser.h:2051

Referenced by BrowseCallbackProc().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )