mirror of
https://github.com/reactos/reactos.git
synced 2025-04-25 08:00:24 +00:00
[SHELL32] Allow .Lnk properties dialog to change icon for non-FS targets (#7911)
CORE-19971
This commit is contained in:
parent
7eb8535edf
commit
efbdd483b3
2 changed files with 71 additions and 47 deletions
|
@ -294,7 +294,6 @@ CShellLink::CShellLink()
|
||||||
m_pDBList = NULL;
|
m_pDBList = NULL;
|
||||||
m_bInInit = FALSE;
|
m_bInInit = FALSE;
|
||||||
m_hIcon = NULL;
|
m_hIcon = NULL;
|
||||||
m_idCmdFirst = 0;
|
|
||||||
|
|
||||||
m_sLinkPath = NULL;
|
m_sLinkPath = NULL;
|
||||||
|
|
||||||
|
@ -2543,8 +2542,6 @@ HRESULT STDMETHODCALLTYPE CShellLink::QueryContextMenu(HMENU hMenu, UINT indexMe
|
||||||
{
|
{
|
||||||
INT id = 0;
|
INT id = 0;
|
||||||
|
|
||||||
m_idCmdFirst = idCmdFirst;
|
|
||||||
|
|
||||||
TRACE("%p %p %u %u %u %u\n", this,
|
TRACE("%p %p %u %u %u %u\n", this,
|
||||||
hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
|
hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
|
||||||
|
|
||||||
|
@ -2934,14 +2931,41 @@ void CShellLink::OnCommand(HWND hwndDlg, int id, HWND hwndCtl, UINT codeNotify)
|
||||||
|
|
||||||
case IDC_SHORTCUT_CHANGE_ICON:
|
case IDC_SHORTCUT_CHANGE_ICON:
|
||||||
{
|
{
|
||||||
WCHAR wszPath[MAX_PATH] = L"";
|
SHFILEINFOW fi;
|
||||||
|
|
||||||
if (m_sIcoPath)
|
|
||||||
wcscpy(wszPath, m_sIcoPath);
|
|
||||||
else
|
|
||||||
FindExecutableW(m_sPath, NULL, wszPath);
|
|
||||||
|
|
||||||
INT IconIndex = m_Header.nIconIndex;
|
INT IconIndex = m_Header.nIconIndex;
|
||||||
|
WCHAR wszPath[MAX_PATH];
|
||||||
|
*wszPath = UNICODE_NULL;
|
||||||
|
|
||||||
|
if (!StrIsNullOrEmpty(m_sIcoPath))
|
||||||
|
{
|
||||||
|
PWSTR pszPath = m_sIcoPath;
|
||||||
|
if (*m_sIcoPath == '.') // Extension-only icon location, we need a fake path
|
||||||
|
{
|
||||||
|
if (SUCCEEDED(StringCchPrintfW(wszPath, _countof(wszPath), L"x:\\x%s", m_sIcoPath)) &&
|
||||||
|
SHGetFileInfoW(wszPath, 0, &fi, sizeof(fi), SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES))
|
||||||
|
{
|
||||||
|
pszPath = fi.szDisplayName; // The path is now a generic icon based
|
||||||
|
IconIndex = fi.iIcon; // on the registry info of the file extension.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FAILED(StringCchCopyW(wszPath, _countof(wszPath), pszPath)))
|
||||||
|
*wszPath = UNICODE_NULL;
|
||||||
|
}
|
||||||
|
else if (!StrIsNullOrEmpty(m_sPath))
|
||||||
|
{
|
||||||
|
FindExecutableW(m_sPath, NULL, wszPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!*wszPath && m_pPidl)
|
||||||
|
{
|
||||||
|
if (SHGetFileInfoW((PWSTR)m_pPidl, 0, &fi, sizeof(fi), SHGFI_ICONLOCATION | SHGFI_PIDL) &&
|
||||||
|
SUCCEEDED(StringCchCopyW(wszPath, _countof(wszPath), fi.szDisplayName)))
|
||||||
|
{
|
||||||
|
IconIndex = fi.iIcon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (PickIconDlg(hwndDlg, wszPath, _countof(wszPath), &IconIndex))
|
if (PickIconDlg(hwndDlg, wszPath, _countof(wszPath), &IconIndex))
|
||||||
{
|
{
|
||||||
SetIconLocation(wszPath, IconIndex);
|
SetIconLocation(wszPath, IconIndex);
|
||||||
|
@ -2993,44 +3017,45 @@ LRESULT CShellLink::OnNotify(HWND hwndDlg, int idFrom, LPNMHDR pnmhdr)
|
||||||
SetWorkingDirectory(wszBuf);
|
SetWorkingDirectory(wszBuf);
|
||||||
|
|
||||||
/* set link destination */
|
/* set link destination */
|
||||||
GetDlgItemTextW(hwndDlg, IDC_SHORTCUT_TARGET_TEXT, wszBuf, _countof(wszBuf));
|
HWND hWndTarget = GetDlgItem(hwndDlg, IDC_SHORTCUT_TARGET_TEXT);
|
||||||
LPWSTR lpszArgs = NULL;
|
GetWindowTextW(hWndTarget, wszBuf, _countof(wszBuf));
|
||||||
LPWSTR unquoted = strdupW(wszBuf);
|
// Only set the path and arguments for filesystem targets (we can't verify other targets)
|
||||||
StrTrimW(unquoted, L" ");
|
if (IsWindowEnabled(hWndTarget))
|
||||||
|
|
||||||
if (!PathFileExistsW(unquoted))
|
|
||||||
{
|
{
|
||||||
lpszArgs = PathGetArgsW(unquoted);
|
LPWSTR lpszArgs = NULL;
|
||||||
PathRemoveArgsW(unquoted);
|
LPWSTR unquoted = wszBuf;
|
||||||
StrTrimW(lpszArgs, L" ");
|
StrTrimW(unquoted, L" ");
|
||||||
|
|
||||||
|
if (!PathFileExistsW(unquoted))
|
||||||
|
{
|
||||||
|
lpszArgs = PathGetArgsW(unquoted);
|
||||||
|
PathRemoveArgsW(unquoted);
|
||||||
|
StrTrimW(lpszArgs, L" ");
|
||||||
|
}
|
||||||
|
if (unquoted[0] == '"' && unquoted[wcslen(unquoted) - 1] == '"')
|
||||||
|
PathUnquoteSpacesW(unquoted);
|
||||||
|
|
||||||
|
WCHAR *pwszExt = PathFindExtensionW(unquoted);
|
||||||
|
if (!_wcsicmp(pwszExt, L".lnk"))
|
||||||
|
{
|
||||||
|
// TODO: SLDF_ALLOW_LINK_TO_LINK (Win7+)
|
||||||
|
// FIXME load localized error msg
|
||||||
|
MessageBoxW(hwndDlg, L"You cannot create a link to a shortcut", NULL, MB_ICONERROR);
|
||||||
|
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!PathFileExistsW(unquoted))
|
||||||
|
{
|
||||||
|
// FIXME load localized error msg
|
||||||
|
MessageBoxW(hwndDlg, L"The specified file name in the target box is invalid", NULL, MB_ICONERROR);
|
||||||
|
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetPath(unquoted);
|
||||||
|
SetArguments(lpszArgs ? lpszArgs : L"\0");
|
||||||
}
|
}
|
||||||
if (unquoted[0] == '"' && unquoted[wcslen(unquoted) - 1] == '"')
|
|
||||||
PathUnquoteSpacesW(unquoted);
|
|
||||||
|
|
||||||
WCHAR *pwszExt = PathFindExtensionW(unquoted);
|
|
||||||
if (!_wcsicmp(pwszExt, L".lnk"))
|
|
||||||
{
|
|
||||||
// FIXME load localized error msg
|
|
||||||
MessageBoxW(hwndDlg, L"You cannot create a link to a shortcut", L"Error", MB_ICONERROR);
|
|
||||||
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!PathFileExistsW(unquoted))
|
|
||||||
{
|
|
||||||
// FIXME load localized error msg
|
|
||||||
MessageBoxW(hwndDlg, L"The specified file name in the target box is invalid", L"Error", MB_ICONERROR);
|
|
||||||
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetPath(unquoted);
|
|
||||||
if (lpszArgs)
|
|
||||||
SetArguments(lpszArgs);
|
|
||||||
else
|
|
||||||
SetArguments(L"\0");
|
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, unquoted);
|
|
||||||
|
|
||||||
m_Header.wHotKey = (WORD)SendDlgItemMessageW(hwndDlg, IDC_SHORTCUT_KEY_HOTKEY, HKM_GETHOTKEY, 0, 0);
|
m_Header.wHotKey = (WORD)SendDlgItemMessageW(hwndDlg, IDC_SHORTCUT_KEY_HOTKEY, HKM_GETHOTKEY, 0, 0);
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,6 @@ private:
|
||||||
LPDBLIST m_pDBList; /* Optional data block list (in the extra data section) */
|
LPDBLIST m_pDBList; /* Optional data block list (in the extra data section) */
|
||||||
BOOL m_bInInit; // in initialization or not
|
BOOL m_bInInit; // in initialization or not
|
||||||
HICON m_hIcon;
|
HICON m_hIcon;
|
||||||
UINT m_idCmdFirst;
|
|
||||||
|
|
||||||
/* Pointers to strings inside Logo3/Darwin info blocks, cached for debug info purposes only */
|
/* Pointers to strings inside Logo3/Darwin info blocks, cached for debug info purposes only */
|
||||||
LPWSTR sProduct;
|
LPWSTR sProduct;
|
||||||
|
|
Loading…
Reference in a new issue