some more LongPath handling

This commit is contained in:
METANEOCORTEX\Kotti 2021-10-11 04:08:04 +02:00
parent b134d21328
commit b8558bbfd4
9 changed files with 108 additions and 146 deletions

View File

@ -1506,6 +1506,7 @@ INT_PTR RunDlg(HWND hwnd,LPCWSTR lpstrDefault)
static INT_PTR CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
{
static HWND hwndLV = NULL;
static HPATHL hFilePath = NULL;
switch(umsg) {
case WM_INITDIALOG: {
@ -1515,6 +1516,9 @@ static INT_PTR CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM
InitWindowCommon(hwnd, true);
hFilePath = Path_Allocate(NULL);
Path_WriteAccessBuf(hFilePath, PATHLONG_MAX_CCH); // reserve buffer
#ifdef D_NP3_WIN10_DARK_MODE
if (UseDarkMode()) {
SetExplorerTheme(GetDlgItem(hwnd, IDOK));
@ -1534,7 +1538,7 @@ static INT_PTR CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM
ListView_SetExtendedListViewStyle(hwndLV, /*LVS_EX_FULLROWSELECT|*/ LVS_EX_DOUBLEBUFFER | LVS_EX_LABELTIP);
ListView_InsertColumn(hwndLV, 0, &lvc);
DirList_Init(hwndLV, NULL);
DirList_Init(hwndLV, NULL, hFilePath);
DirList_Fill(hwndLV, Path_Get(Settings.OpenWithDir), DL_ALLOBJECTS, NULL, false, Flags.NoFadeHidden, DS_NAME, false);
DirList_StartIconThread(hwndLV);
ListView_SetItemState(hwndLV, 0, LVIS_FOCUSED, LVIS_FOCUSED);
@ -1555,6 +1559,7 @@ static INT_PTR CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM
DirList_Destroy(hwndLV);
hwndLV = NULL;
DeleteBitmapButton(hwnd,IDC_GETOPENWITHDIR);
Path_Release(hFilePath);
ResizeDlg_Destroy(hwnd,&Settings.OpenWithDlgSizeX,&Settings.OpenWithDlgSizeY);
return FALSE;
@ -1703,7 +1708,7 @@ bool OpenWithDlg(HWND hwnd, LPCWSTR lpstrFile)
HPATHL hpthFileName = Path_Allocate(lpstrFile);
dliOpenWith.pthFileName = Path_WriteAccessBuf(hpthFileName, PATHLONG_MAX_CCH);
WCHAR chDispayName[MAX_PATH];
WCHAR chDispayName[128];
Path_GetDisplayName(chDispayName, COUNTOF(chDispayName), hpthFileName, L"");
dliOpenWith.strDisplayName = chDispayName;
@ -1762,6 +1767,7 @@ bool OpenWithDlg(HWND hwnd, LPCWSTR lpstrFile)
static INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
{
static HWND hwndLV = NULL;
static HPATHL hFilePath = NULL;
switch(umsg) {
case WM_INITDIALOG: {
@ -1770,6 +1776,9 @@ static INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
InitWindowCommon(hwnd, true);
hFilePath = Path_Allocate(NULL);
Path_WriteAccessBuf(hFilePath, PATHLONG_MAX_CCH); // reserve buffer
#ifdef D_NP3_WIN10_DARK_MODE
if (UseDarkMode()) {
SetExplorerTheme(GetDlgItem(hwnd, IDOK));
@ -1789,7 +1798,7 @@ static INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
ListView_SetExtendedListViewStyle(hwndLV,/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP);
ListView_InsertColumn(hwndLV,0,&lvc);
DirList_Init(hwndLV,NULL);
DirList_Init(hwndLV, NULL, hFilePath);
DirList_Fill(hwndLV,Path_Get(Settings.FavoritesDir),DL_ALLOBJECTS,NULL,false,Flags.NoFadeHidden,DS_NAME,false);
DirList_StartIconThread(hwndLV);
ListView_SetItemState(hwndLV,0,LVIS_FOCUSED,LVIS_FOCUSED);
@ -1810,6 +1819,7 @@ static INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
DirList_Destroy(hwndLV);
hwndLV = NULL;
DeleteBitmapButton(hwnd,IDC_GETFAVORITESDIR);
Path_Release(hFilePath);
ResizeDlg_Destroy(hwnd,&Settings.FavoritesDlgSizeX,&Settings.FavoritesDlgSizeY);
return FALSE;
@ -2143,7 +2153,6 @@ DWORD WINAPI FileMRUIconThread(LPVOID lpParam)
(void)CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_SPEED_OVER_MEMORY);
WCHAR tch[MAX_PATH] = { L'\0' };
DWORD dwFlags = SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED;
HWND hwnd = worker->hwnd;
@ -2154,22 +2163,23 @@ DWORD WINAPI FileMRUIconThread(LPVOID lpParam)
LV_ITEM lvi = { 0 };
lvi.mask = LVIF_TEXT;
lvi.pszText = tch;
lvi.cchTextMax = COUNTOF(tch);
lvi.pszText = Path_WriteAccessBuf(worker->hFilePath, 0);
lvi.cchTextMax = (int)Path_GetBufCount(worker->hFilePath);
lvi.iItem = iItem;
SHFILEINFO shfi = { 0 };
if (ListView_GetItem(hwnd,&lvi)) {
Path_Sanitize(worker->hFilePath);
DWORD dwAttr = 0;
if (PathIsUNC(tch) || !PathIsExistingFile(tch)) {
if (Path_IsValidUNC(worker->hFilePath) || !Path_IsExistingFile(worker->hFilePath)) {
dwFlags |= SHGFI_USEFILEATTRIBUTES;
dwAttr = FILE_ATTRIBUTE_NORMAL;
shfi.dwAttributes = 0;
SHGetFileInfo(PathFindFileName(tch),dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags);
SHGetFileInfoW(Path_FindFileName(worker->hFilePath), dwAttr, &shfi, sizeof(SHFILEINFO), dwFlags);
} else {
shfi.dwAttributes = SFGAO_LINK | SFGAO_SHARE;
SHGetFileInfo(tch,dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags);
SHGetFileInfoW(Path_Get(worker->hFilePath), dwAttr, &shfi, sizeof(SHFILEINFO), dwFlags);
}
lvi.mask = LVIF_IMAGE;
@ -2189,10 +2199,10 @@ DWORD WINAPI FileMRUIconThread(LPVOID lpParam)
lvi.state |= INDEXTOOVERLAYMASK(1);
}
if (PathIsUNC(tch)) {
if (Path_IsValidUNC(worker->hFilePath)) {
dwAttr = FILE_ATTRIBUTE_NORMAL;
} else {
dwAttr = GetFileAttributes(tch);
dwAttr = GetFileAttributesW(Path_Get(worker->hFilePath));
}
if (!Flags.NoFadeHidden &&
@ -2218,6 +2228,7 @@ DWORD WINAPI FileMRUIconThread(LPVOID lpParam)
static INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
static HWND hwndLV = NULL;
static HPATHL hFilePath = NULL;
switch (umsg) {
case WM_INITDIALOG: {
@ -2226,6 +2237,9 @@ static INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPAR
InitWindowCommon(hwnd, true);
hFilePath = Path_Allocate(NULL);
Path_WriteAccessBuf(hFilePath, PATHLONG_MAX_CCH); // reserve buffer
#ifdef D_NP3_WIN10_DARK_MODE
if (UseDarkMode()) {
SetExplorerTheme(GetDlgItem(hwnd, IDOK));
@ -2252,7 +2266,7 @@ static INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPAR
BackgroundWorker *worker = (BackgroundWorker *)GlobalAlloc(GPTR, sizeof(BackgroundWorker));
SetProp(hwnd, L"it", (HANDLE)worker);
BackgroundWorker_Init(worker, hwndLV);
BackgroundWorker_Init(worker, hwndLV, hFilePath);
ResizeDlg_Init(hwnd, Settings.FileMRUDlgSizeX, Settings.FileMRUDlgSizeY, IDC_RESIZEGRIP);
@ -2299,6 +2313,8 @@ static INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPAR
Settings.SaveFindReplace = IsButtonChecked(hwnd, IDC_REMEMBERSEARCHPATTERN);
Settings.PreserveCaretPos = IsButtonChecked(hwnd, IDC_PRESERVECARET);
Path_Release(hFilePath);
ResizeDlg_Destroy(hwnd, &Settings.FileMRUDlgSizeX, &Settings.FileMRUDlgSizeY);
}
return FALSE;
@ -2402,65 +2418,7 @@ CASE_WM_CTLCOLOR_SET:
break;
case LVN_GETDISPINFO: {
/*
LV_DISPINFO *lpdi = (LPVOID)lParam;
if (lpdi->item.mask & LVIF_IMAGE) {
WCHAR tch[MAX_PATH] = { L'\0' };
LV_ITEM lvi = { 0 };
SHFILEINFO shfi = { 0 };
DWORD dwFlags = SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED;
DWORD dwAttr = 0;
lvi.mask = LVIF_TEXT;
lvi.pszText = tch;
lvi.cchTextMax = COUNTOF(tch);
lvi.iItem = lpdi->item.iItem;
ListView_GetItem(GetDlgItem(hwnd,IDC_FILEMRU),&lvi);
if (!PathIsExistingFile(tch)) {
dwFlags |= SHGFI_USEFILEATTRIBUTES;
dwAttr = FILE_ATTRIBUTE_NORMAL;
shfi.dwAttributes = 0;
SHGetFileInfo(PathFindFileName(tch),dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags);
}
else {
shfi.dwAttributes = SFGAO_LINK | SFGAO_SHARE;
SHGetFileInfo(tch,dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags);
}
lpdi->item.iImage = shfi.iIcon;
lpdi->item.mask |= LVIF_DI_SETITEM;
lpdi->item.stateMask = 0;
lpdi->item.state = 0;
if (shfi.dwAttributes & SFGAO_LINK) {
lpdi->item.mask |= LVIF_STATE;
lpdi->item.stateMask |= LVIS_OVERLAYMASK;
lpdi->item.state |= INDEXTOOVERLAYMASK(2);
}
if (shfi.dwAttributes & SFGAO_SHARE) {
lpdi->item.mask |= LVIF_STATE;
lpdi->item.stateMask |= LVIS_OVERLAYMASK;
lpdi->item.state |= INDEXTOOVERLAYMASK(1);
}
dwAttr = GetFileAttributes(tch);
if (!Flags.NoFadeHidden &&
dwAttr != INVALID_FILE_ATTRIBUTES &&
dwAttr & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) {
lpdi->item.mask |= LVIF_STATE;
lpdi->item.stateMask |= LVIS_CUT;
lpdi->item.state |= LVIS_CUT;
}
}
*/
// done by BackgroundWorker FileMRUIconThread()
}
break;
@ -2492,7 +2450,7 @@ CASE_WM_CTLCOLOR_SET:
switch (LOWORD(wParam)) {
case IDC_FILEMRU_UPDATE_VIEW: {
BackgroundWorker *worker = (BackgroundWorker *)GetProp(hwnd, L"it");
BackgroundWorker* worker = (BackgroundWorker*)GetProp(hwnd, L"it");
BackgroundWorker_Cancel(worker);
ListView_DeleteAllItems(hwndLV);
@ -2505,13 +2463,17 @@ CASE_WM_CTLCOLOR_SET:
SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES);
lvi.iImage = shfi.iIcon;
WCHAR tch[MAX_PATH] = { L'\0' };
LPWSTR const szFileBuf = Path_WriteAccessBuf(hFilePath, 0);
int const cchFileBuf = (int)Path_GetBufCount(hFilePath);
for (int i = 0; i < MRU_Count(Globals.pFileMRU); i++) {
MRU_Enum(Globals.pFileMRU, i, tch, COUNTOF(tch));
MRU_Enum(Globals.pFileMRU, i, szFileBuf, cchFileBuf);
Path_Sanitize(hFilePath);
// SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_ADDSTRING,0,(LPARAM)tch); }
// SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_SETCARETINDEX,0,false);
lvi.iItem = i;
lvi.pszText = tch;
lvi.pszText = Path_WriteAccessBuf(hFilePath, 0);
lvi.cchTextMax = (int)Path_GetBufCount(hFilePath);
ListView_InsertItem(hwndLV, &lvi);
}
@ -2545,22 +2507,21 @@ CASE_WM_CTLCOLOR_SET:
case IDOK:
case IDC_REMOVE: {
WCHAR tchFileName[MAX_PATH] = {L'\0'};
if (ListView_GetSelectedCount(hwndLV)) {
LV_ITEM lvi = { 0 };
lvi.mask = LVIF_TEXT;
lvi.pszText = tchFileName;
lvi.cchTextMax = COUNTOF(tchFileName);
lvi.iItem = ListView_GetNextItem(hwndLV, -1, LVNI_ALL | LVNI_SELECTED);
lvi.pszText = Path_WriteAccessBuf(hFilePath, 0);
lvi.cchTextMax = (int)Path_GetBufCount(hFilePath);
lvi.iItem = ListView_GetNextItem(hwndLV, -1, LVNI_ALL | LVNI_SELECTED);
ListView_GetItem(hwndLV, &lvi);
PathUnquoteSpaces(tchFileName);
PathAbsoluteFromApp(tchFileName, COUNTOF(tchFileName), true);
Path_UnQuoteSpaces(hFilePath);
Path_AbsoluteFromApp(hFilePath, true);
if (!PathIsExistingFile(tchFileName) || (LOWORD(wParam) == IDC_REMOVE)) {
if (!Path_IsExistingFile(hFilePath) || (LOWORD(wParam) == IDC_REMOVE)) {
// don't remove myself
int iCur = 0;
if (!MRU_FindPath(Globals.pFileMRU, Paths.CurrentFile, &iCur)) {
@ -2579,7 +2540,8 @@ CASE_WM_CTLCOLOR_SET:
// (LB_ERR != SendDlgItemMessage(hwnd,IDC_GOTO,LB_GETCURSEL,0,0)));
}
} else { // file to load
StringCchCopy((LPWSTR)GetWindowLongPtr(hwnd, DWLP_USER), MAX_PATH, tchFileName);
HPATHL hFilePathOut = (HPATHL)GetWindowLongPtr(hwnd, DWLP_USER);
Path_Reset(hFilePathOut, Path_Get(hFilePath)); // (!) no Path_Swap() here
EndDialog(hwnd, IDOK);
}
@ -2618,13 +2580,10 @@ CASE_WM_CTLCOLOR_SET:
// FileMRUDlg()
//
//
bool FileMRUDlg(HWND hwnd,LPWSTR lpstrFile)
bool FileMRUDlg(HWND hwnd, HPATHL hFilePath_out)
{
if (IDOK == ThemedDialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_FILEMRU),
hwnd, FileMRUDlgProc, (LPARAM)lpstrFile)) {
return TRUE;
}
return FALSE;
return (IDOK == ThemedDialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_FILEMRU),
hwnd, FileMRUDlgProc, (LPARAM)hFilePath_out));
}
@ -4753,13 +4712,15 @@ void DialogGrepWin(HWND hwnd, LPCWSTR searchPattern)
}
}
WCHAR tchTemp[MAX_PATH] = { L'\0' };
HPATHL hLngFilePath = Path_Allocate(NULL);
LPWSTR wchLngPathBuf = Path_WriteAccessBuf(hLngFilePath, PATHLONG_MAX_CCH);
if (lngIdx >= 0) {
IniSectionGetString(globalSection, L"languagefile", grepWinLangResName[lngIdx].filename, tchTemp, COUNTOF(tchTemp));
IniSectionSetString(globalSection, L"languagefile", tchTemp);
IniSectionGetString(globalSection, L"languagefile", grepWinLangResName[lngIdx].filename, wchLngPathBuf, Path_GetBufCount(hLngFilePath));
IniSectionSetString(globalSection, L"languagefile", wchLngPathBuf);
} else {
IniSectionGetString(globalSection, L"languagefile", L"", tchTemp, COUNTOF(tchTemp));
if (StrIsEmpty(tchTemp)) {
IniSectionGetString(globalSection, L"languagefile", L"", wchLngPathBuf, Path_GetBufCount(hLngFilePath));
if (Path_IsEmpty(hLngFilePath)) {
IniSectionDelete(globalSection, L"languagefile", false);
}
}
@ -4767,8 +4728,10 @@ void DialogGrepWin(HWND hwnd, LPCWSTR searchPattern)
bool const bDarkMode = UseDarkMode(); // <- override usr ~ IniSectionGetBool(globalSection, L"darkmode", UseDarkMode());
IniSectionSetBool(globalSection, L"darkmode", bDarkMode);
StringCchPrintf(tchTemp, COUNTOF(tchTemp), L"%s /%%mode%% \"%%pattern%%\" /g %%line%% - %%path%%", Path_Get(hNotepad3Path));
IniSectionSetString(globalSection, L"editorcmd", tchTemp);
StringCchPrintf(wchLngPathBuf, Path_GetBufCount(hLngFilePath), L"%s /%%mode%% \"%%pattern%%\" /g %%line%% - %%path%%", Path_Get(hNotepad3Path));
IniSectionSetString(globalSection, L"editorcmd", wchLngPathBuf);
Path_Release(hLngFilePath);
long const iOpacity = IniSectionGetLong(globalSection, L"OpacityNoFocus", Settings2.FindReplaceOpacityLevel);
IniSectionSetLong(globalSection, L"OpacityNoFocus", iOpacity);

View File

@ -47,7 +47,7 @@ INT_PTR RunDlg(HWND hwnd,LPCWSTR lpstrDefault);
bool OpenWithDlg(HWND hwnd,LPCWSTR lpstrFile);
bool FavoritesDlg(HWND hwnd, HPATHL hpath_in_out);
bool AddToFavDlg(HWND hwnd, HPATHL hTargetPth);
bool FileMRUDlg(HWND hwnd,LPWSTR lpstrFile);
bool FileMRUDlg(HWND hwnd, HPATHL hFilePath_out);
bool ChangeNotifyDlg(HWND hwnd);
bool ColumnWrapDlg(HWND hwnd,UINT uidDlg,UINT * iNumber);
bool WordWrapSettingsDlg(HWND hwnd,UINT uidDlg,int * iNumber);

View File

@ -39,8 +39,7 @@ typedef struct tagDLDATA { // dl
int iDefIconFolder; // Default Folder Icon
int iDefIconFile; // Default File Icon
bool bNoFadeHidden; // Flag passed from GetDispInfo()
WCHAR szPath[MAX_PATH]; // Pathname to Directory Id
HPATHL hDirectoryPath; // Pathname to Directory Id
} DLDATA, *LPDLDATA;
@ -56,7 +55,7 @@ static const WCHAR *pDirListProp = L"DirListData";
//
// Initializes the DLDATA structure and sets up the listview control
//
bool DirList_Init(HWND hwnd,LPCWSTR pszHeader)
bool DirList_Init(HWND hwnd,LPCWSTR pszHeader, HPATHL hFilePath)
{
UNREFERENCED_PARAMETER(pszHeader);
@ -64,13 +63,13 @@ bool DirList_Init(HWND hwnd,LPCWSTR pszHeader)
LPDLDATA lpdl = (LPDLDATA)GlobalAlloc(GPTR, sizeof(DLDATA));
if (lpdl) {
SetProp(hwnd, pDirListProp, (HANDLE)lpdl);
// Setup dl
BackgroundWorker_Init(&lpdl->worker, hwnd);
BackgroundWorker_Init(&lpdl->worker, hwnd, NULL);
lpdl->cbidl = 0;
lpdl->pidl = NULL;
lpdl->lpsf = NULL;
StringCchCopy(lpdl->szPath, COUNTOF(lpdl->szPath), L"");
lpdl->hDirectoryPath = hFilePath;
Path_Empty(lpdl->hDirectoryPath, false);
// Add Imagelists
SHFILEINFO shfi = { 0 };
@ -152,11 +151,8 @@ int DirList_Fill(HWND hwnd,LPCWSTR lpszDir,DWORD grfFlags,LPCWSTR lpszFileSpec,
bool bExcludeFilter,bool bNoFadeHidden,
int iSortFlags,bool fSortRev)
{
LPDLDATA lpdl = (LPDLDATA)GetProp(hwnd, pDirListProp);
WCHAR wszDir[MAX_PATH] = { L'\0' };
// Initialize default icons
SHFILEINFO shfi = { 0 };
SHGetFileInfo(L"Icon",FILE_ATTRIBUTE_DIRECTORY,&shfi,sizeof(SHFILEINFO),
@ -174,7 +170,7 @@ int DirList_Fill(HWND hwnd,LPCWSTR lpszDir,DWORD grfFlags,LPCWSTR lpszFileSpec,
if (!lpszDir || !*lpszDir) {
return(-1);
}
StringCchCopyN(lpdl->szPath, COUNTOF(lpdl->szPath), lpszDir, MAX_PATH);
Path_Reset(lpdl->hDirectoryPath, lpszDir);
// Init ListView
SendMessage(hwnd,WM_SETREDRAW,0,0);
@ -200,7 +196,7 @@ int DirList_Fill(HWND hwnd,LPCWSTR lpszDir,DWORD grfFlags,LPCWSTR lpszFileSpec,
-1,
wszDir,
MAX_PATH);*/
StringCchCopy(wszDir,COUNTOF(wszDir),lpszDir);
LPWSTR const wchDir = Path_WriteAccessBuf(lpdl->hDirectoryPath, 0);
// Get Desktop Folder
LPSHELLFOLDER lpsf = NULL;
@ -215,7 +211,7 @@ int DirList_Fill(HWND hwnd,LPCWSTR lpszDir,DWORD grfFlags,LPCWSTR lpszFileSpec,
lpsfDesktop,
hwnd,
NULL,
wszDir,
wchDir,
&chParsed,
&pidl,
&dwAttributes))
@ -649,25 +645,18 @@ int DirList_GetItem(HWND hwnd,int iItem,LPDLITEM lpdli)
//
int DirList_GetItemEx(HWND hwnd,int iItem,LPWIN32_FIND_DATA pfd)
{
LV_ITEM lvi;
LPLV_ITEMDATA lplvid;
if (iItem == -1) {
if (ListView_GetSelectedCount(hwnd))
{
iItem = ListView_GetNextItem(hwnd,-1,LVNI_ALL | LVNI_SELECTED);
}
else
{
return(-1);
}
}
lvi.mask = LVIF_PARAM;
@ -698,7 +687,6 @@ int DirList_GetItemEx(HWND hwnd,int iItem,LPWIN32_FIND_DATA pfd)
//
bool DirList_PropertyDlg(HWND hwnd,int iItem)
{
LV_ITEM lvi;
LPLV_ITEMDATA lplvid;
LPCONTEXTMENU lpcm;
@ -711,7 +699,6 @@ bool DirList_PropertyDlg(HWND hwnd,int iItem)
if (ListView_GetSelectedCount(hwnd)) {
iItem = ListView_GetNextItem(hwnd,-1,LVNI_ALL | LVNI_SELECTED);
}
else {
return false;
}
@ -747,21 +734,16 @@ bool DirList_PropertyDlg(HWND hwnd,int iItem)
if (NOERROR != lpcm->lpVtbl->InvokeCommand(lpcm,&cmi)) {
bSuccess = false;
}
lpcm->lpVtbl->Release(lpcm);
}
else {
bSuccess = false;
}
return(bSuccess);
}
#if 0
//=============================================================================
//
// DirList_GetLongPathName()
@ -778,7 +760,7 @@ bool DirList_GetLongPathName(HWND hwnd,LPWSTR lpszLongPath,int length)
}
return false;
}
#endif
//=============================================================================
@ -925,7 +907,7 @@ bool DirList_MatchFilter(LPSHELLFOLDER lpsf,LPCITEMIDLIST pidl,PDL_FILTER pdlf)
}
#if 0
//==== DriveBox ===============================================================
//=============================================================================
@ -1277,14 +1259,12 @@ LRESULT DriveBox_DeleteItem(HWND hwnd,LPARAM lParam)
}
//=============================================================================
//
// DriveBox_GetDispInfo
//
LRESULT DriveBox_GetDispInfo(HWND hwnd,LPARAM lParam)
{
NMCOMBOBOXEX *lpnmcbe;
LPDC_ITEMDATA lpdcid;
SHFILEINFO shfi = { 0 };
@ -1314,12 +1294,15 @@ LRESULT DriveBox_GetDispInfo(HWND hwnd,LPARAM lParam)
attr = FILE_ATTRIBUTE_NORMAL;
}
WCHAR szTemp[MAX_PATH] = { L'\0' };
IL_GetDisplayName(lpdcid->lpsf,lpdcid->pidl,SHGDN_FORPARSING,szTemp,MAX_PATH);
SHGetFileInfo(szTemp,attr,&shfi,sizeof(SHFILEINFO),
SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES);
HPATHL hFilePath = Path_Allocate(NULL);
LPWSTR const wchFileBuf = Path_WriteAccessBuf(hFilePath, PATHLONG_MAX_CCH);
IL_GetDisplayName(lpdcid->lpsf, lpdcid->pidl, SHGDN_FORPARSING, wchFileBuf, (int)Path_GetBufCount(hFilePath));
Path_Sanitize(hFilePath);
SHGetFileInfoW(wchFileBuf, attr, &shfi, sizeof(SHFILEINFO),
SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES);
lpnmcbe->ceItem.iImage = shfi.iIcon;
lpnmcbe->ceItem.iSelectedImage = shfi.iIcon;
Path_Release(hFilePath);
}
// Set values
@ -1330,6 +1313,7 @@ LRESULT DriveBox_GetDispInfo(HWND hwnd,LPARAM lParam)
return true;
}
#endif
//==== ItemID =================================================================

View File

@ -36,7 +36,7 @@ typedef struct tagLV_ITEMDATA { // lvid
//==== DlInit() ===============================================================
bool DirList_Init(HWND hwnd,LPCWSTR pszHeader);
bool DirList_Init(HWND hwnd, LPCWSTR pszHeader, HPATHL hFilePath);
//==== DlDestroy() ============================================================
@ -119,7 +119,7 @@ bool DirList_PropertyDlg(HWND hwnd,int iItem);
//==== DlGetLongPathName() ====================================================
bool DirList_GetLongPathName(HWND hwnd,LPWSTR lpszLongPath,int length);
//bool DirList_GetLongPathName(HWND hwnd,LPWSTR lpszLongPath,int length);
//==== DlSelectItem() =========================================================
@ -144,14 +144,14 @@ bool DirList_MatchFilter(LPSHELLFOLDER lpsf,LPCITEMIDLIST pidl,PDL_FILTER pdlf);
//==== DriveBox ===============================================================
bool DriveBox_Init(HWND hwnd);
int DriveBox_Fill(HWND hwnd);
bool DriveBox_GetSelDrive(HWND hwnd,LPWSTR lpszDrive,int nDrive,bool);
bool DriveBox_SelectDrive(HWND hwnd,LPCWSTR lpszPath);
bool DriveBox_PropertyDlg(HWND hwnd);
//bool DriveBox_Init(HWND hwnd);
//int DriveBox_Fill(HWND hwnd);
//bool DriveBox_GetSelDrive(HWND hwnd,LPWSTR lpszDrive,int nDrive,bool);
//bool DriveBox_SelectDrive(HWND hwnd,LPCWSTR lpszPath);
//bool DriveBox_PropertyDlg(HWND hwnd);
LRESULT DriveBox_DeleteItem(HWND hwnd,LPARAM lParam);
LRESULT DriveBox_GetDispInfo(HWND hwnd,LPARAM lParam);
//LRESULT DriveBox_DeleteItem(HWND hwnd,LPARAM lParam);
//LRESULT DriveBox_GetDispInfo(HWND hwnd,LPARAM lParam);

View File

@ -589,10 +589,12 @@ bool IsRunAsAdmin()
//=============================================================================
void BackgroundWorker_Init(BackgroundWorker *worker, HWND hwnd) {
void BackgroundWorker_Init(BackgroundWorker* worker, HWND hwnd, HPATHL hFilePath)
{
worker->hwnd = hwnd;
worker->eventCancel = CreateEvent(NULL, TRUE, FALSE, NULL);
worker->workerThread = NULL;
worker->hFilePath = hFilePath;
}
void BackgroundWorker_Stop(BackgroundWorker *worker) {

View File

@ -377,9 +377,10 @@ typedef struct BackgroundWorker {
HWND hwnd;
HANDLE eventCancel;
HANDLE workerThread;
HPATHL hFilePath; // PATHLONG_MAX_CCH
} BackgroundWorker;
void BackgroundWorker_Init(BackgroundWorker *worker, HWND hwnd);
void BackgroundWorker_Init(BackgroundWorker* worker, HWND hwnd, HPATHL hFilePath);
void BackgroundWorker_Cancel(BackgroundWorker *worker);
void BackgroundWorker_Destroy(BackgroundWorker *worker);
#define BackgroundWorker_Continue(worker) \

View File

@ -4547,9 +4547,8 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
case IDM_FILE_RECENT:
if (MRU_Count(Globals.pFileMRU) > 0) {
if (FileSave(false, true, false, false, Flags.bPreserveFileModTime)) {
HPATHL hfile_pth = Path_Allocate(L"");
wchar_t* const file_buf = Path_WriteAccessBuf(hfile_pth, MAX_PATH); // TODO: §§§ @@@ MAX_PATH
if (FileMRUDlg(hwnd, file_buf)) {
HPATHL hfile_pth = Path_Allocate(NULL);
if (FileMRUDlg(hwnd, hfile_pth)) {
FileLoad(hfile_pth, true, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, false);
}
Path_Release(hfile_pth);

View File

@ -1230,6 +1230,18 @@ bool PTHAPI Path_QuoteSpaces(HPATHL hpth_in_out, bool bForceQuotes)
// ----------------------------------------------------------------------------
void PTHAPI Path_UnQuoteSpaces(HPATHL hpth_in_out)
{
HSTRINGW hstr_io = ToHStrgW(hpth_in_out);
if (!hstr_io)
return;
StrgTrimLeft(hstr_io, L'"');
StrgTrimRight(hstr_io, L'"');
}
// ----------------------------------------------------------------------------
int PTHAPI Path_GetDriveNumber(const HPATHL hpth)
{
int res = -1;

View File

@ -81,6 +81,7 @@ size_t PTHAPI Path_CommonPrefix(const HPATHL hpth1, const HPATHL hpth2,
const wchar_t* PTHAPI Path_FindFileName(const HPATHL hpth);
const wchar_t* PTHAPI Path_FindExtension(const HPATHL hpth);
bool PTHAPI Path_QuoteSpaces(HPATHL hpth_in_out, bool bForceQuotes);
void PTHAPI Path_UnQuoteSpaces(HPATHL hpth_in_out);
int PTHAPI Path_GetDriveNumber(const HPATHL hpth);
wchar_t PTHAPI Path_GetDriveLetterByNumber(const int number);
DWORD PTHAPI Path_GetFileAttributes(const HPATHL hpth);