ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
July 2018
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
17 participants
89 discussions
Start a n
N
ew thread
01/01: [USER32][WIN32SS] Improve CascadeWindows function (#677)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cc3ba6e41cd53c022fb9e…
commit cc3ba6e41cd53c022fb9e393c5602611063cb251 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Mon Jul 9 21:52:30 2018 +0900 Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org> CommitDate: Mon Jul 9 14:52:30 2018 +0200 [USER32][WIN32SS] Improve CascadeWindows function (#677) If the window is too large, then shrink it if possible. CORE-14807 --- win32ss/user/user32/windows/mdi.c | 57 ++++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 10 deletions(-) diff --git a/win32ss/user/user32/windows/mdi.c b/win32ss/user/user32/windows/mdi.c index 38ee4af264..5e892de252 100644 --- a/win32ss/user/user32/windows/mdi.c +++ b/win32ss/user/user32/windows/mdi.c @@ -2047,6 +2047,22 @@ GetCascadeChildProc(HWND hwnd, LPARAM lParam) return TRUE; } +static void +QuerySizeFix(HWND hwnd, LPINT pcx, LPINT pcy) +{ + MINMAXINFO mmi; + DWORD_PTR dwResult; + + mmi.ptMinTrackSize.x = mmi.ptMinTrackSize.y = 0; + mmi.ptMaxTrackSize.x = mmi.ptMaxTrackSize.y = MAXLONG; + if (SendMessageTimeoutW(hwnd, WM_GETMINMAXINFO, 0, (LPARAM)&mmi, + SMTO_ABORTIFHUNG | SMTO_NORMAL, 120, &dwResult)) + { + *pcx = min(max(*pcx, mmi.ptMinTrackSize.x), mmi.ptMaxTrackSize.x); + *pcy = min(max(*pcy, mmi.ptMinTrackSize.y), mmi.ptMaxTrackSize.y); + } +} + WORD WINAPI CascadeWindows(HWND hwndParent, UINT wFlags, LPCRECT lpRect, UINT cKids, const HWND *lpKids) @@ -2057,8 +2073,9 @@ CascadeWindows(HWND hwndParent, UINT wFlags, LPCRECT lpRect, MONITORINFO mi; RECT rcWork, rcWnd; DWORD i, ret = 0; - INT x, y, cx, cy, dx, dy; + INT x, y, cx, cy, cxNew, cyNew, cxWork, cyWork, dx, dy; HDWP hDWP; + POINT pt; TRACE("(%p,0x%08x,...,%u,...)\n", hwndParent, wFlags, cKids); @@ -2098,7 +2115,8 @@ CascadeWindows(HWND hwndParent, UINT wFlags, LPCRECT lpRect, } else { - hMon = MonitorFromWindow(hwndParent, MONITOR_DEFAULTTONEAREST); + pt.x = pt.y = 0; + hMon = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY); mi.cbSize = sizeof(mi); GetMonitorInfoW(hMon, &mi); rcWork = mi.rcWork; @@ -2112,30 +2130,49 @@ CascadeWindows(HWND hwndParent, UINT wFlags, LPCRECT lpRect, y = rcWork.top; dx = GetSystemMetrics(SM_CXSIZEFRAME) + GetSystemMetrics(SM_CXSIZE); dy = GetSystemMetrics(SM_CYSIZEFRAME) + GetSystemMetrics(SM_CYSIZE); + cxWork = rcWork.right - rcWork.left; + cyWork = rcWork.bottom - rcWork.top; hwndPrev = NULL; for (i = info.chwnd; i > 0;) /* in reverse order */ { --i; hwnd = info.ahwnd[i]; + if (!IsWindowVisible(hwnd) || IsIconic(hwnd)) + continue; + + if ((info.wFlags & MDITILE_SKIPDISABLED) && !IsWindowEnabled(hwnd)) + continue; + if (IsZoomed(hwnd)) ShowWindow(hwnd, SW_RESTORE | SW_SHOWNA); GetWindowRect(hwnd, &rcWnd); - cx = rcWnd.right - rcWnd.left; - cy = rcWnd.bottom - rcWnd.top; + cxNew = cx = rcWnd.right - rcWnd.left; + cyNew = cy = rcWnd.bottom - rcWnd.top; + + /* if we can change the window size and it is not only one */ + if (info.chwnd != 1 && (GetWindowLongPtrW(hwnd, GWL_STYLE) & WS_THICKFRAME)) + { + /* check the size */ +#define THRESHOLD(xy) (((xy) * 5) / 7) /* in the rate 5/7 */ + cxNew = min(cxNew, THRESHOLD(cxWork)); + cyNew = min(cyNew, THRESHOLD(cyWork)); +#undef THRESHOLD + if (cx != cxNew || cy != cyNew) + { + /* too large. shrink if we can */ + QuerySizeFix(hwnd, &cxNew, &cyNew); + cx = cxNew; + cy = cyNew; + } + } if (x + cx > rcWork.right) x = rcWork.left; if (y + cy > rcWork.bottom) y = rcWork.top; - if (!IsWindowVisible(hwnd) || IsIconic(hwnd)) - continue; - - if ((info.wFlags & MDITILE_SKIPDISABLED) && !IsWindowEnabled(hwnd)) - continue; - hDWP = DeferWindowPos(hDWP, hwnd, HWND_TOP, x, y, cx, cy, SWP_NOACTIVATE); if (hDWP == NULL) {
6 years, 5 months
1
0
0
0
02/02: [NET] Revert useless changes
by Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=506bd64e4402d64f3b3e3…
commit 506bd64e4402d64f3b3e370726f766bdc4746331 Author: Eric Kohl <eric.kohl(a)reactos.org> AuthorDate: Sat Jul 7 22:12:37 2018 +0200 Commit: Eric Kohl <eric.kohl(a)reactos.org> CommitDate: Mon Jul 9 05:56:41 2018 +0200 [NET] Revert useless changes --- base/applications/network/net/cmdAccounts.c | 2 +- base/applications/network/net/cmdUser.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/base/applications/network/net/cmdAccounts.c b/base/applications/network/net/cmdAccounts.c index 6bade9b574..454aeeb892 100644 --- a/base/applications/network/net/cmdAccounts.c +++ b/base/applications/network/net/cmdAccounts.c @@ -164,7 +164,7 @@ cmdAccounts( } } - if (Modified != FALSE) + if (Modified == TRUE) { Status = NetUserModalsSet(NULL, 0, (LPBYTE)Info0, &ParamErr); if (Status != NERR_Success) diff --git a/base/applications/network/net/cmdUser.c b/base/applications/network/net/cmdUser.c index 7750d247da..3e188de932 100644 --- a/base/applications/network/net/cmdUser.c +++ b/base/applications/network/net/cmdUser.c @@ -14,7 +14,7 @@ static WCHAR szPasswordChars[] = L"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHI static int -CompareUserInfo(const void *a, const void *b) +CompareInfo(const void *a, const void *b) { return _wcsicmp(((PUSER_INFO_0)a)->usri0_name, ((PUSER_INFO_0)b)->usri0_name); @@ -62,7 +62,7 @@ EnumerateUsers(VOID) qsort(pBuffer, dwRead, sizeof(PUSER_INFO_0), - CompareUserInfo); + CompareInfo); for (i = 0; i < dwRead; i++) { @@ -662,7 +662,7 @@ cmdUser( } done: - if ((bPasswordAllocated != FALSE) && (lpPassword != NULL)) + if ((bPasswordAllocated == TRUE) && (lpPassword != NULL)) HeapFree(GetProcessHeap(), 0, lpPassword); if (!bAdd && !bDelete && pUserInfo != NULL)
6 years, 5 months
1
0
0
0
01/02: [NET] Implement the undocumented /RANDOM option to generate random passwords
by Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b4969dc0d729e913a3aa5…
commit b4969dc0d729e913a3aa593e9ddc4dbb12b432c6 Author: Eric Kohl <eric.kohl(a)reactos.org> AuthorDate: Sat Jul 7 22:06:08 2018 +0200 Commit: Eric Kohl <eric.kohl(a)reactos.org> CommitDate: Mon Jul 9 05:56:40 2018 +0200 [NET] Implement the undocumented /RANDOM option to generate random passwords --- base/applications/network/net/cmdUser.c | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/base/applications/network/net/cmdUser.c b/base/applications/network/net/cmdUser.c index 3ee392b6c5..7750d247da 100644 --- a/base/applications/network/net/cmdUser.c +++ b/base/applications/network/net/cmdUser.c @@ -10,6 +10,8 @@ #include "net.h" +static WCHAR szPasswordChars[] = L"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@#$%_-+:"; + static int CompareUserInfo(const void *a, const void *b) @@ -356,6 +358,35 @@ ReadPassword( } +static +VOID +GenerateRandomPassword( + LPWSTR *lpPassword, + LPBOOL lpAllocated) +{ + LPWSTR pPassword = NULL; + INT nCharsLen, i, nLength = 8; + + srand(GetTickCount()); + + pPassword = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + (nLength + 1) * sizeof(WCHAR)); + if (pPassword == NULL) + return; + + nCharsLen = wcslen(szPasswordChars); + + for (i = 0; i < nLength; i++) + { + pPassword[i] = szPasswordChars[rand() % nCharsLen]; + } + + *lpPassword = pPassword; + *lpAllocated = TRUE; +} + + INT cmdUser( INT argc, @@ -368,6 +399,7 @@ cmdUser( #if 0 BOOL bDomain = FALSE; #endif + BOOL bRandomPassword = FALSE; LPWSTR lpUserName = NULL; LPWSTR lpPassword = NULL; PUSER_INFO_4 pUserInfo = NULL; @@ -428,6 +460,12 @@ cmdUser( bDomain = TRUE; #endif } + else if (_wcsicmp(argv[j], L"/random") == 0) + { + bRandomPassword = TRUE; + GenerateRandomPassword(&lpPassword, + &bPasswordAllocated); + } } if (bAdd && bDelete) @@ -616,6 +654,13 @@ cmdUser( ConPrintf(StdOut, L"Status: %lu\n", Status); } + if (Status == NERR_Success && + lpPassword != NULL && + bRandomPassword == TRUE) + { + ConPrintf(StdOut, L"The password for %s is: %s\n", lpUserName, lpPassword); + } + done: if ((bPasswordAllocated != FALSE) && (lpPassword != NULL)) HeapFree(GetProcessHeap(), 0, lpPassword);
6 years, 5 months
1
0
0
0
01/01: [USER32][WIN32SS] Implement CascadeWindows function (#676)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4e45a91547959914ca7ab…
commit 4e45a91547959914ca7abb629eef87d17b6b4bdd Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Mon Jul 9 08:51:14 2018 +0900 Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org> CommitDate: Mon Jul 9 01:51:14 2018 +0200 [USER32][WIN32SS] Implement CascadeWindows function (#676) CORE-14807 --- win32ss/user/user32/windows/mdi.c | 186 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 178 insertions(+), 8 deletions(-) diff --git a/win32ss/user/user32/windows/mdi.c b/win32ss/user/user32/windows/mdi.c index 9f25daf86e..38ee4af264 100644 --- a/win32ss/user/user32/windows/mdi.c +++ b/win32ss/user/user32/windows/mdi.c @@ -1,10 +1,11 @@ /* MDI.C * * Copyright 1994, Bob Amstadt - * 1995,1996 Alex Korobka + * Copyright 1995,1996 Alex Korobka + * Copyright 2018 Katayama Hirofumi MZ * * This file contains routines to support MDI (Multiple Document - * Interface) features . + * Interface) features. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -22,7 +23,7 @@ * * Notes: Fairly complete implementation. * Also, Excel and WinWord do _not_ use MDI so if you're trying - * to fix them look elsewhere. + * to fix them look elsewhere. * * Notes on how the "More Windows..." is implemented: * @@ -1975,7 +1976,6 @@ void WINAPI ScrollChildren(HWND hWnd, UINT uMsg, WPARAM wParam, SW_INVALIDATE | SW_ERASE | SW_SCROLLCHILDREN ); } - /****************************************************************************** * CascadeWindows (USER32.@) Cascades MDI child windows * @@ -1983,12 +1983,182 @@ void WINAPI ScrollChildren(HWND hWnd, UINT uMsg, WPARAM wParam, * Success: Number of cascaded windows. * Failure: 0 */ + +typedef struct CASCADE_INFO +{ + HWND hwndTop; + UINT wFlags; + HWND hwndParent; + HWND hwndDesktop; + HWND hTrayWnd; + HWND hwndProgman; + HWND *ahwnd; + DWORD chwnd; +} CASCADE_INFO; + +static BOOL CALLBACK +GetCascadeChildProc(HWND hwnd, LPARAM lParam) +{ + DWORD count, size; + HWND *ahwnd; + CASCADE_INFO *pInfo = (CASCADE_INFO *)lParam; + + if (hwnd == pInfo->hwndDesktop || hwnd == pInfo->hTrayWnd || + hwnd == pInfo->hwndProgman || hwnd == pInfo->hwndTop) + { + return TRUE; + } + + if (pInfo->hwndParent && GetParent(hwnd) != pInfo->hwndParent) + return TRUE; + + if ((pInfo->wFlags & MDITILE_SKIPDISABLED) && !IsWindowEnabled(hwnd)) + return TRUE; + + if (!IsWindowVisible(hwnd) || IsIconic(hwnd)) + return TRUE; + + count = pInfo->chwnd; + size = (count + 1) * sizeof(HWND); + + if (count == 0 || pInfo->ahwnd == NULL) + { + count = 0; + pInfo->ahwnd = (HWND *)HeapAlloc(GetProcessHeap(), 0, size); + } + else + { + ahwnd = (HWND *)HeapReAlloc(GetProcessHeap(), 0, pInfo->ahwnd, size); + if (ahwnd == NULL) + { + HeapFree(GetProcessHeap(), 0, pInfo->ahwnd); + } + pInfo->ahwnd = ahwnd; + } + + if (pInfo->ahwnd == NULL) + { + pInfo->chwnd = 0; + return FALSE; + } + + pInfo->ahwnd[count] = hwnd; + pInfo->chwnd = count + 1; + return TRUE; +} + WORD WINAPI -CascadeWindows (HWND hwndParent, UINT wFlags, LPCRECT lpRect, - UINT cKids, const HWND *lpKids) +CascadeWindows(HWND hwndParent, UINT wFlags, LPCRECT lpRect, + UINT cKids, const HWND *lpKids) { - FIXME("(%p,0x%08x,...,%u,...): stub\n", hwndParent, wFlags, cKids); - return 0; + CASCADE_INFO info; + HWND hwnd, hwndTop, hwndPrev; + HMONITOR hMon; + MONITORINFO mi; + RECT rcWork, rcWnd; + DWORD i, ret = 0; + INT x, y, cx, cy, dx, dy; + HDWP hDWP; + + TRACE("(%p,0x%08x,...,%u,...)\n", hwndParent, wFlags, cKids); + + hwndTop = GetTopWindow(hwndParent); + + ZeroMemory(&info, sizeof(info)); + info.hwndDesktop = GetDesktopWindow(); + info.hTrayWnd = FindWindowW(L"Shell_TrayWnd", NULL); + info.hwndProgman = FindWindowW(L"Progman", NULL); + info.hwndParent = hwndParent; + info.wFlags = wFlags; + + if (cKids == 0 || lpKids == NULL) + { + info.hwndTop = hwndTop; + EnumChildWindows(hwndParent, GetCascadeChildProc, (LPARAM)&info); + + info.hwndTop = NULL; + GetCascadeChildProc(hwndTop, (LPARAM)&info); + } + else + { + info.chwnd = cKids; + info.ahwnd = (HWND *)lpKids; + } + + if (info.chwnd == 0 || info.ahwnd == NULL) + return ret; + + if (lpRect) + { + rcWork = *lpRect; + } + else if (hwndParent) + { + GetClientRect(hwndParent, &rcWork); + } + else + { + hMon = MonitorFromWindow(hwndParent, MONITOR_DEFAULTTONEAREST); + mi.cbSize = sizeof(mi); + GetMonitorInfoW(hMon, &mi); + rcWork = mi.rcWork; + } + + hDWP = BeginDeferWindowPos(info.chwnd); + if (hDWP == NULL) + goto cleanup; + + x = rcWork.left; + y = rcWork.top; + dx = GetSystemMetrics(SM_CXSIZEFRAME) + GetSystemMetrics(SM_CXSIZE); + dy = GetSystemMetrics(SM_CYSIZEFRAME) + GetSystemMetrics(SM_CYSIZE); + hwndPrev = NULL; + for (i = info.chwnd; i > 0;) /* in reverse order */ + { + --i; + hwnd = info.ahwnd[i]; + + if (IsZoomed(hwnd)) + ShowWindow(hwnd, SW_RESTORE | SW_SHOWNA); + + GetWindowRect(hwnd, &rcWnd); + cx = rcWnd.right - rcWnd.left; + cy = rcWnd.bottom - rcWnd.top; + + if (x + cx > rcWork.right) + x = rcWork.left; + if (y + cy > rcWork.bottom) + y = rcWork.top; + + if (!IsWindowVisible(hwnd) || IsIconic(hwnd)) + continue; + + if ((info.wFlags & MDITILE_SKIPDISABLED) && !IsWindowEnabled(hwnd)) + continue; + + hDWP = DeferWindowPos(hDWP, hwnd, HWND_TOP, x, y, cx, cy, SWP_NOACTIVATE); + if (hDWP == NULL) + { + ret = 0; + goto cleanup; + } + + x += dx; + y += dy; + hwndPrev = hwnd; + ++ret; + } + + EndDeferWindowPos(hDWP); + + if (hwndPrev) + SetForegroundWindow(hwndPrev); + +cleanup: + if (cKids == 0 || lpKids == NULL) + HeapFree(GetProcessHeap(), 0, info.ahwnd); + + return (WORD)ret; }
6 years, 5 months
1
0
0
0
01/01: [SHELL32] Add 'Properties' menu item in My Computer (#647)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=55469633cfbf20ba34bc7…
commit 55469633cfbf20ba34bc747a80001bd4c7c4afb4 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Mon Jul 9 00:01:12 2018 +0900 Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Jul 8 17:01:12 2018 +0200 [SHELL32] Add 'Properties' menu item in My Computer (#647) - Add a Shell_DefaultContextMenuCallBack() helper function. - Implement the IContextMenuCB interface in CDrivesFolder. CORE-12509 --- dll/win32/shell32/folders/CDesktopFolder.cpp | 28 +-------------- dll/win32/shell32/folders/CDrivesFolder.cpp | 52 ++++++++++++++++++++++++++-- dll/win32/shell32/folders/CDrivesFolder.h | 7 +++- dll/win32/shell32/folders/CFSFolder.cpp | 28 +-------------- dll/win32/shell32/precomp.h | 3 ++ dll/win32/shell32/shlfolder.cpp | 41 ++++++++++++++++++++++ 6 files changed, 102 insertions(+), 57 deletions(-) diff --git a/dll/win32/shell32/folders/CDesktopFolder.cpp b/dll/win32/shell32/folders/CDesktopFolder.cpp index 9a1a452ea8..b5bb839603 100644 --- a/dll/win32/shell32/folders/CDesktopFolder.cpp +++ b/dll/win32/shell32/folders/CDesktopFolder.cpp @@ -864,33 +864,7 @@ HRESULT WINAPI CDesktopFolder::CallBack(IShellFolder *psf, HWND hwndOwner, IData if (uMsg != DFM_INVOKECOMMAND || wParam != DFM_CMD_PROPERTIES) return S_OK; - PIDLIST_ABSOLUTE pidlFolder; - PUITEMID_CHILD *apidl; - UINT cidl; - HRESULT hr = SH_GetApidlFromDataObject(pdtobj, &pidlFolder, &apidl, &cidl); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; - - if (cidl > 1) - ERR("SHMultiFileProperties is not yet implemented\n"); - - STRRET strFile; - hr = GetDisplayNameOf(apidl[0], SHGDN_FORPARSING, &strFile); - if (SUCCEEDED(hr)) - { - hr = SH_ShowPropertiesDialog(strFile.pOleStr, pidlFolder, apidl); - if (FAILED(hr)) - ERR("SH_ShowPropertiesDialog failed\n"); - } - else - { - ERR("Failed to get display name\n"); - } - - SHFree(pidlFolder); - _ILFreeaPidl(apidl, cidl); - - return hr; + return Shell_DefaultContextMenuCallBack(this, pdtobj); } /************************************************************************* diff --git a/dll/win32/shell32/folders/CDrivesFolder.cpp b/dll/win32/shell32/folders/CDrivesFolder.cpp index 77f6420196..15ccef2da8 100644 --- a/dll/win32/shell32/folders/CDrivesFolder.cpp +++ b/dll/win32/shell32/folders/CDrivesFolder.cpp @@ -669,8 +669,21 @@ HRESULT WINAPI CDrivesFolder::CreateViewObject(HWND hwndOwner, REFIID riid, LPVO } else if (IsEqualIID(riid, IID_IContextMenu)) { - WARN("IContextMenu not implemented\n"); - hr = E_NOTIMPL; + HKEY hKeys[16]; + UINT cKeys = 0; + AddClassKeyToArray(L"Directory\\Background", hKeys, &cKeys); + + DEFCONTEXTMENU dcm; + dcm.hwnd = hwndOwner; + dcm.pcmcb = this; + dcm.pidlFolder = pidlRoot; + dcm.psf = this; + dcm.cidl = 0; + dcm.apidl = NULL; + dcm.cKeys = cKeys; + dcm.aKeys = hKeys; + dcm.punkAssociationInfo = NULL; + hr = SHCreateDefaultContextMenu(&dcm, riid, ppvOut); } else if (IsEqualIID(riid, IID_IShellView)) { @@ -1059,3 +1072,38 @@ HRESULT WINAPI CDrivesFolder::GetCurFolder(LPITEMIDLIST *pidl) *pidl = ILClone(pidlRoot); return S_OK; } + +/************************************************************************/ +/* IContextMenuCB interface */ + +HRESULT WINAPI CDrivesFolder::CallBack(IShellFolder *psf, HWND hwndOwner, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + if (uMsg != DFM_MERGECONTEXTMENU && uMsg != DFM_INVOKECOMMAND) + return S_OK; + + /* no data object means no selection */ + if (!pdtobj) + { + if (uMsg == DFM_INVOKECOMMAND && wParam == 1) // #1 + { + // "System" properties + ShellExecuteW(hwndOwner, NULL, L"rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl", NULL, NULL, SW_SHOWNORMAL); + } + else if (uMsg == DFM_MERGECONTEXTMENU) + { + QCMINFO *pqcminfo = (QCMINFO *)lParam; + HMENU hpopup = CreatePopupMenu(); + _InsertMenuItemW(hpopup, 0, TRUE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED); // #0 + _InsertMenuItemW(hpopup, 1, TRUE, 1, MFT_STRING, MAKEINTRESOURCEW(IDS_PROPERTIES), MFS_ENABLED); // #1 + Shell_MergeMenus(pqcminfo->hmenu, hpopup, pqcminfo->indexMenu++, pqcminfo->idCmdFirst, pqcminfo->idCmdLast, MM_ADDSEPARATOR); + DestroyMenu(hpopup); + } + + return S_OK; + } + + if (uMsg != DFM_INVOKECOMMAND || wParam != DFM_CMD_PROPERTIES) + return S_OK; + + return Shell_DefaultContextMenuCallBack(this, pdtobj); +} diff --git a/dll/win32/shell32/folders/CDrivesFolder.h b/dll/win32/shell32/folders/CDrivesFolder.h index f0adc4960a..f83057d79d 100644 --- a/dll/win32/shell32/folders/CDrivesFolder.h +++ b/dll/win32/shell32/folders/CDrivesFolder.h @@ -27,7 +27,8 @@ class CDrivesFolder : public CComCoClass<CDrivesFolder, &CLSID_MyComputer>, public CComObjectRootEx<CComMultiThreadModelNoCS>, public IShellFolder2, - public IPersistFolder2 + public IPersistFolder2, + public IContextMenuCB { private: /* both paths are parsible from the desktop */ @@ -69,6 +70,9 @@ class CDrivesFolder : // IPersistFolder2 virtual HRESULT WINAPI GetCurFolder(LPITEMIDLIST * pidl); + // IContextMenuCB + virtual HRESULT WINAPI CallBack(IShellFolder *psf, HWND hwndOwner, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam); + DECLARE_REGISTRY_RESOURCEID(IDR_MYCOMPUTER) DECLARE_CENTRAL_INSTANCE_NOT_AGGREGATABLE(CDrivesFolder) @@ -80,6 +84,7 @@ class CDrivesFolder : COM_INTERFACE_ENTRY_IID(IID_IPersistFolder, IPersistFolder) COM_INTERFACE_ENTRY_IID(IID_IPersistFolder2, IPersistFolder2) COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersist) + COM_INTERFACE_ENTRY_IID(IID_IContextMenuCB, IContextMenuCB) END_COM_MAP() }; diff --git a/dll/win32/shell32/folders/CFSFolder.cpp b/dll/win32/shell32/folders/CFSFolder.cpp index 77d87e6f82..ad205c47e1 100644 --- a/dll/win32/shell32/folders/CFSFolder.cpp +++ b/dll/win32/shell32/folders/CFSFolder.cpp @@ -1624,31 +1624,5 @@ HRESULT WINAPI CFSFolder::CallBack(IShellFolder *psf, HWND hwndOwner, IDataObjec if (uMsg != DFM_INVOKECOMMAND || wParam != DFM_CMD_PROPERTIES) return S_OK; - PIDLIST_ABSOLUTE pidlFolder; - PUITEMID_CHILD *apidl; - UINT cidl; - HRESULT hr = SH_GetApidlFromDataObject(pdtobj, &pidlFolder, &apidl, &cidl); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; - - if (cidl > 1) - ERR("SHMultiFileProperties is not yet implemented\n"); - - STRRET strFile; - hr = GetDisplayNameOf(apidl[0], SHGDN_FORPARSING, &strFile); - if (SUCCEEDED(hr)) - { - hr = SH_ShowPropertiesDialog(strFile.pOleStr, pidlFolder, apidl); - if (FAILED(hr)) - ERR("SH_ShowPropertiesDialog failed\n"); - } - else - { - ERR("Failed to get display name\n"); - } - - SHFree(pidlFolder); - _ILFreeaPidl(apidl, cidl); - - return hr; + return Shell_DefaultContextMenuCallBack(this, pdtobj); } diff --git a/dll/win32/shell32/precomp.h b/dll/win32/shell32/precomp.h index 75c136664d..4e694f7b86 100644 --- a/dll/win32/shell32/precomp.h +++ b/dll/win32/shell32/precomp.h @@ -120,4 +120,7 @@ AddPropSheetPageCallback(HPROPSHEETPAGE hPage, LPARAM lParam) return FALSE; } +HRESULT WINAPI +Shell_DefaultContextMenuCallBack(IShellFolder *psf, IDataObject *pdtobj); + #endif /* _PRECOMP_H__ */ diff --git a/dll/win32/shell32/shlfolder.cpp b/dll/win32/shell32/shlfolder.cpp index 0b4d0f19a9..f652378616 100644 --- a/dll/win32/shell32/shlfolder.cpp +++ b/dll/win32/shell32/shlfolder.cpp @@ -3,6 +3,7 @@ * * Copyright 1997 Marcus Meissner * Copyright 1998, 1999, 2002 Juergen Schmied + * Copyright 2018 Katayama Hirofumi MZ * * IShellFolder2 and related interfaces * @@ -441,3 +442,43 @@ SHOpenFolderAndSelectItems(LPITEMIDLIST pidlFolder, else return E_FAIL; } + +/* + * for internal use + */ +HRESULT WINAPI +Shell_DefaultContextMenuCallBack(IShellFolder *psf, IDataObject *pdtobj) +{ + PIDLIST_ABSOLUTE pidlFolder; + PUITEMID_CHILD *apidl; + UINT cidl; + HRESULT hr = SH_GetApidlFromDataObject(pdtobj, &pidlFolder, &apidl, &cidl); + if (FAILED_UNEXPECTEDLY(hr)) + return hr; + + if (cidl > 1) + { + ERR("SHMultiFileProperties is not yet implemented\n"); + SHFree(pidlFolder); + _ILFreeaPidl(apidl, cidl); + return E_FAIL; + } + + STRRET strFile; + hr = psf->GetDisplayNameOf(apidl[0], SHGDN_FORPARSING, &strFile); + if (SUCCEEDED(hr)) + { + hr = SH_ShowPropertiesDialog(strFile.pOleStr, pidlFolder, apidl); + if (FAILED(hr)) + ERR("SH_ShowPropertiesDialog failed\n"); + } + else + { + ERR("Failed to get display name\n"); + } + + SHFree(pidlFolder); + _ILFreeaPidl(apidl, cidl); + + return hr; +}
6 years, 5 months
1
0
0
0
01/01: [SHELL32] Improve CShellLink a little (#651)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=96c0ef42094e067800e08…
commit 96c0ef42094e067800e0806267ffb539e017df19 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Sun Jul 8 23:45:40 2018 +0900 Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Jul 8 16:45:40 2018 +0200 [SHELL32] Improve CShellLink a little (#651) Improve the display and UI in the shortcut dialog. CORE-11407 --- dll/win32/shell32/CShellLink.cpp | 576 ++++++++++++++++++++++++--------------- dll/win32/shell32/CShellLink.h | 8 + 2 files changed, 360 insertions(+), 224 deletions(-) diff --git a/dll/win32/shell32/CShellLink.cpp b/dll/win32/shell32/CShellLink.cpp index ddabd18949..1bbb2e1111 100644 --- a/dll/win32/shell32/CShellLink.cpp +++ b/dll/win32/shell32/CShellLink.cpp @@ -268,6 +268,8 @@ CShellLink::CShellLink() m_bRunAs = FALSE; m_bDirty = FALSE; m_pDBList = NULL; + m_bInInit = FALSE; + m_hIcon = NULL; m_sLinkPath = NULL; m_iIdOpen = -1; @@ -347,12 +349,13 @@ HRESULT STDMETHODCALLTYPE CShellLink::Save(LPCOLESTR pszFileName, BOOL fRemember if (SUCCEEDED(hr)) { - if (m_sLinkPath) - HeapFree(GetProcessHeap(), 0, m_sLinkPath); + if (pszFileName != m_sLinkPath) + { + if (m_sLinkPath) + HeapFree(GetProcessHeap(), 0, m_sLinkPath); - m_sLinkPath = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, (wcslen(pszFileName) + 1) * sizeof(WCHAR)); - if (m_sLinkPath) - wcscpy(m_sLinkPath, pszFileName); + m_sLinkPath = strdupW(pszFileName); + } m_bDirty = FALSE; } @@ -1033,11 +1036,9 @@ static HRESULT ShellLink_UpdatePath(LPCWSTR sPathRel, LPCWSTR path, LPCWSTR sWor if (!*abs_path) wcscpy(abs_path, sPathRel); - *psPath = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, (wcslen(abs_path) + 1) * sizeof(WCHAR)); + *psPath = strdupW(abs_path); if (!*psPath) return E_OUTOFMEMORY; - - wcscpy(*psPath, abs_path); } return S_OK; @@ -1415,11 +1416,12 @@ HRESULT STDMETHODCALLTYPE CShellLink::Resolve(HWND hwnd, DWORD fFlags) bSuccess = SHGetPathFromIDListW(m_pPidl, buffer); if (bSuccess && *buffer) { - m_sPath = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, (wcslen(buffer) + 1) * sizeof(WCHAR)); - if (!m_sPath) - return E_OUTOFMEMORY; - - wcscpy(m_sPath, buffer); + if (buffer != m_sPath) + { + m_sPath = strdupW(buffer); + if (!m_sPath) + return E_OUTOFMEMORY; + } m_bDirty = TRUE; } @@ -1432,11 +1434,13 @@ HRESULT STDMETHODCALLTYPE CShellLink::Resolve(HWND hwnd, DWORD fFlags) // FIXME: Strange to do that here... if (!m_sIcoPath && m_sPath) { - m_sIcoPath = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, (wcslen(m_sPath) + 1) * sizeof(WCHAR)); - if (!m_sIcoPath) - return E_OUTOFMEMORY; + if (m_sIcoPath != m_sPath) + { + m_sIcoPath = strdupW(m_sPath); + if (!m_sIcoPath) + return E_OUTOFMEMORY; + } - wcscpy(m_sIcoPath, m_sPath); m_Header.nIconIndex = 0; m_bDirty = TRUE; @@ -1561,12 +1565,12 @@ HRESULT STDMETHODCALLTYPE CShellLink::SetDescription(LPCWSTR pszName) HeapFree(GetProcessHeap(), 0, m_sDescription); if (pszName) { - m_sDescription = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, - (wcslen(pszName) + 1) * sizeof(WCHAR)); - if (!m_sDescription) - return E_OUTOFMEMORY; - - wcscpy(m_sDescription, pszName); + if (m_sDescription != pszName) + { + m_sDescription = strdupW(pszName); + if (!m_sDescription) + return E_OUTOFMEMORY; + } } else m_sDescription = NULL; @@ -1596,11 +1600,12 @@ HRESULT STDMETHODCALLTYPE CShellLink::SetWorkingDirectory(LPCWSTR pszDir) HeapFree(GetProcessHeap(), 0, m_sWorkDir); if (pszDir) { - m_sWorkDir = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, - (wcslen(pszDir) + 1) * sizeof(WCHAR)); - if (!m_sWorkDir) - return E_OUTOFMEMORY; - wcscpy(m_sWorkDir, pszDir); + if (m_sWorkDir != pszDir) + { + m_sWorkDir = strdupW(pszDir); + if (!m_sWorkDir) + return E_OUTOFMEMORY; + } } else m_sWorkDir = NULL; @@ -1630,12 +1635,12 @@ HRESULT STDMETHODCALLTYPE CShellLink::SetArguments(LPCWSTR pszArgs) HeapFree(GetProcessHeap(), 0, m_sArgs); if (pszArgs) { - m_sArgs = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, - (wcslen(pszArgs) + 1) * sizeof(WCHAR)); - if (!m_sArgs) - return E_OUTOFMEMORY; - - wcscpy(m_sArgs, pszArgs); + if (m_sArgs != pszArgs) + { + m_sArgs = strdupW(pszArgs); + if (!m_sArgs) + return E_OUTOFMEMORY; + } } else m_sArgs = NULL; @@ -1670,12 +1675,13 @@ HRESULT STDMETHODCALLTYPE CShellLink::GetIconLocation(LPWSTR pszIconPath, INT cc SHExpandEnvironmentStringsW(pInfo->szwTarget, szPath, _countof(szPath)); - m_sIcoPath = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, - (wcslen(szPath) + 1) * sizeof(WCHAR)); - if (!m_sIcoPath) - return E_OUTOFMEMORY; + if (m_sIcoPath != szPath) + { + m_sIcoPath = strdupW(szPath); + if (!m_sIcoPath) + return E_OUTOFMEMORY; + } - wcscpy(m_sIcoPath, szPath); m_Header.dwFlags |= SLDF_HAS_ICONLOCATION; m_bDirty = TRUE; @@ -1768,27 +1774,42 @@ HRESULT STDMETHODCALLTYPE CShellLink::GetIconLocation(UINT uFlags, PWSTR pszIcon HRESULT STDMETHODCALLTYPE CShellLink::Extract(PCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) { - SHFILEINFOW info; + HRESULT hr = NOERROR; + UINT cxyLarge = LOWORD(nIconSize), cxySmall = HIWORD(nIconSize); if (phiconLarge) { - SHGetFileInfoW(pszFile, 0, &info, sizeof(info), - SHGFI_ICON | SHGFI_LARGEICON | SHGFI_LINKOVERLAY); - *phiconLarge = info.hIcon; - if (!info.hIcon) - return E_FAIL; + *phiconLarge = NULL; + PrivateExtractIconsW(pszFile, nIconIndex, cxyLarge, cxyLarge, phiconLarge, NULL, 1, 0); + + if (*phiconLarge == NULL) + hr = S_FALSE; } if (phiconSmall) { - SHGetFileInfoW(pszFile, 0, &info, sizeof(info), - SHGFI_ICON | SHGFI_SMALLICON | SHGFI_LINKOVERLAY); - *phiconSmall = info.hIcon; - if (!info.hIcon) - return E_FAIL; + *phiconSmall = NULL; + PrivateExtractIconsW(pszFile, nIconIndex, cxySmall, cxySmall, phiconSmall, NULL, 1, 0); + + if (*phiconSmall == NULL) + hr = S_FALSE; } - return S_OK; + if (hr == S_FALSE) + { + if (phiconLarge && *phiconLarge) + { + DestroyIcon(*phiconLarge); + *phiconLarge = NULL; + } + if (phiconSmall && *phiconSmall) + { + DestroyIcon(*phiconSmall); + *phiconSmall = NULL; + } + } + + return hr; } #if 0 @@ -1945,12 +1966,13 @@ HRESULT STDMETHODCALLTYPE CShellLink::SetIconLocation(LPCWSTR pszIconPath, INT i HeapFree(GetProcessHeap(), 0, m_sIcoPath); m_sIcoPath = NULL; - m_sIcoPath = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, - (wcslen(pszIconPath) + 1) * sizeof(WCHAR)); - if (!m_sIcoPath) - return E_OUTOFMEMORY; + if (m_sIcoPath != pszIconPath) + { + m_sIcoPath = strdupW(pszIconPath); + if (!m_sIcoPath) + return E_OUTOFMEMORY; + } - wcscpy(m_sIcoPath, pszIconPath); m_Header.dwFlags |= SLDF_HAS_ICONLOCATION; } @@ -1969,11 +1991,12 @@ HRESULT STDMETHODCALLTYPE CShellLink::SetRelativePath(LPCWSTR pszPathRel, DWORD HeapFree(GetProcessHeap(), 0, m_sPathRel); if (pszPathRel) { - m_sPathRel = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, - (wcslen(pszPathRel) + 1) * sizeof(WCHAR)); - if (!m_sPathRel) - return E_OUTOFMEMORY; - wcscpy(m_sPathRel, pszPathRel); + if (m_sPathRel != pszPathRel) + { + m_sPathRel = strdupW(pszPathRel); + if (!m_sPathRel) + return E_OUTOFMEMORY; + } } else m_sPathRel = NULL; @@ -2315,11 +2338,13 @@ HRESULT CShellLink::SetTargetFromPIDLOrPath(LPCITEMIDLIST pidl, LPCWSTR pszFile) /* Update the cached path (for link info) */ ShellLink_GetVolumeInfo(pszFile, &volume); - m_sPath = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, - (wcslen(pszFile) + 1) * sizeof(WCHAR)); - if (!m_sPath) - return E_OUTOFMEMORY; - wcscpy(m_sPath, pszFile); + + if (m_sPath != pszFile) + { + m_sPath = strdupW(pszFile); + if (!m_sPath) + return E_OUTOFMEMORY; + } m_bDirty = TRUE; return hr; @@ -2756,203 +2781,245 @@ LPWSTR SH_GetTargetTypeByPath(LPCWSTR lpcwFullPath) return wszBuf; } -/************************************************************************** - * SH_ShellLinkDlgProc - * - * dialog proc of the shortcut property dialog - */ - -INT_PTR CALLBACK CShellLink::SH_ShellLinkDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +BOOL CShellLink::OnInitDialog(HWND hwndDlg, HWND hwndFocus, LPARAM lParam) { - CShellLink *pThis = reinterpret_cast<CShellLink *>(GetWindowLongPtr(hwndDlg, DWLP_USER)); + TRACE("CShellLink::OnInitDialog(hwnd %p hwndFocus %p lParam %p)\n", hwndDlg, hwndFocus, lParam); - switch(uMsg) + TRACE("m_sArgs: %S sComponent: %S m_sDescription: %S m_sIcoPath: %S m_sPath: %S m_sPathRel: %S sProduct: %S m_sWorkDir: %S\n", m_sArgs, sComponent, m_sDescription, + m_sIcoPath, m_sPath, m_sPathRel, sProduct, m_sWorkDir); + + m_bInInit = TRUE; + + /* Get file information */ + // FIXME! FIXME! Shouldn't we use m_sIcoPath, m_Header.nIconIndex instead??? + SHFILEINFOW fi; + if (!SHGetFileInfoW(m_sLinkPath, 0, &fi, sizeof(fi), SHGFI_TYPENAME | SHGFI_ICON)) { - case WM_INITDIALOG: + ERR("SHGetFileInfoW failed for %ls (%lu)\n", m_sLinkPath, GetLastError()); + fi.szTypeName[0] = L'\0'; + fi.hIcon = NULL; + } + + if (fi.hIcon) + { + if (m_hIcon) + DestroyIcon(m_hIcon); + m_hIcon = fi.hIcon; + SendDlgItemMessageW(hwndDlg, IDC_SHORTCUT_ICON, STM_SETICON, (WPARAM)m_hIcon, 0); + } + else + ERR("ExtractIconW failed %ls %u\n", m_sIcoPath, m_Header.nIconIndex); + + /* Target type */ + if (m_sPath) + SetDlgItemTextW(hwndDlg, IDC_SHORTCUT_TYPE_EDIT, SH_GetTargetTypeByPath(m_sPath)); + + /* Target location */ + if (m_sPath) + { + WCHAR target[MAX_PATH]; + StringCchCopyW(target, _countof(target), m_sPath); + PathRemoveFileSpecW(target); + SetDlgItemTextW(hwndDlg, IDC_SHORTCUT_LOCATION_EDIT, PathFindFileNameW(target)); + } + + /* Target path */ + if (m_sPath) + { + WCHAR newpath[2*MAX_PATH] = L"\0"; + if (wcschr(m_sPath, ' ')) + StringCchPrintfExW(newpath, _countof(newpath), NULL, NULL, 0, L"\"%ls\"", m_sPath); + else + StringCchCopyExW(newpath, _countof(newpath), m_sPath, NULL, NULL, 0); + + if (m_sArgs && m_sArgs[0]) { - LPPROPSHEETPAGEW ppsp = (LPPROPSHEETPAGEW)lParam; - if (ppsp == NULL) - break; + StringCchCatW(newpath, _countof(newpath), L" "); + StringCchCatW(newpath, _countof(newpath), m_sArgs); + } + SetDlgItemTextW(hwndDlg, IDC_SHORTCUT_TARGET_TEXT, newpath); + } - TRACE("ShellLink_DlgProc (WM_INITDIALOG hwnd %p lParam %p ppsplParam %x)\n", hwndDlg, lParam, ppsp->lParam); + /* Working dir */ + if (m_sWorkDir) + SetDlgItemTextW(hwndDlg, IDC_SHORTCUT_START_IN_EDIT, m_sWorkDir); - pThis = reinterpret_cast<CShellLink *>(ppsp->lParam); - SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pThis); + /* Description */ + if (m_sDescription) + SetDlgItemTextW(hwndDlg, IDC_SHORTCUT_COMMENT_EDIT, m_sDescription); - TRACE("m_sArgs: %S sComponent: %S m_sDescription: %S m_sIcoPath: %S m_sPath: %S m_sPathRel: %S sProduct: %S m_sWorkDir: %S\n", pThis->m_sArgs, pThis->sComponent, pThis->m_sDescription, - pThis->m_sIcoPath, pThis->m_sPath, pThis->m_sPathRel, pThis->sProduct, pThis->m_sWorkDir); + m_bInInit = FALSE; - /* Get file information */ - // FIXME! FIXME! Shouldn't we use pThis->m_sIcoPath, pThis->m_Header.nIconIndex instead??? - SHFILEINFOW fi; - if (!SHGetFileInfoW(pThis->m_sLinkPath, 0, &fi, sizeof(fi), SHGFI_TYPENAME | SHGFI_ICON)) - { - ERR("SHGetFileInfoW failed for %ls (%lu)\n", pThis->m_sLinkPath, GetLastError()); - fi.szTypeName[0] = L'\0'; - fi.hIcon = NULL; - } + return TRUE; +} - if (fi.hIcon) // TODO: destroy icon - SendDlgItemMessageW(hwndDlg, IDC_SHORTCUT_ICON, STM_SETICON, (WPARAM)fi.hIcon, 0); - else - ERR("ExtractIconW failed %ls %u\n", pThis->m_sIcoPath, pThis->m_Header.nIconIndex); +void CShellLink::OnCommand(HWND hwndDlg, int id, HWND hwndCtl, UINT codeNotify) +{ + switch (id) + { + case IDC_SHORTCUT_FIND: + SHOpenFolderAndSelectItems(m_pPidl, 0, NULL, 0); + /// + /// FIXME + /// open target directory + /// + return; + + case IDC_SHORTCUT_CHANGE_ICON: + { + WCHAR wszPath[MAX_PATH] = L""; - /* Target type */ - if (pThis->m_sPath) - SetDlgItemTextW(hwndDlg, IDC_SHORTCUT_TYPE_EDIT, SH_GetTargetTypeByPath(pThis->m_sPath)); + if (m_sIcoPath) + wcscpy(wszPath, m_sIcoPath); + else + FindExecutableW(m_sPath, NULL, wszPath); - /* Target location */ - if (pThis->m_sPath) + INT IconIndex = m_Header.nIconIndex; + if (PickIconDlg(hwndDlg, wszPath, _countof(wszPath), &IconIndex)) { - WCHAR target[MAX_PATH]; - StringCchCopyW(target, _countof(target), pThis->m_sPath); - PathRemoveFileSpecW(target); - SetDlgItemTextW(hwndDlg, IDC_SHORTCUT_LOCATION_EDIT, PathFindFileNameW(target)); + SetIconLocation(wszPath, IconIndex); + PropSheet_Changed(GetParent(hwndDlg), hwndDlg); + + HICON hIconLarge = CreateShortcutIcon(wszPath, IconIndex); + if (hIconLarge) + { + if (m_hIcon) + DestroyIcon(m_hIcon); + m_hIcon = hIconLarge; + SendDlgItemMessageW(hwndDlg, IDC_SHORTCUT_ICON, STM_SETICON, (WPARAM)m_hIcon, 0); + } } + return; + } - /* Target path */ - if (pThis->m_sPath) + case IDC_SHORTCUT_ADVANCED: + { + INT_PTR result = DialogBoxParamW(shell32_hInstance, MAKEINTRESOURCEW(IDD_SHORTCUT_EXTENDED_PROPERTIES), hwndDlg, ExtendedShortcutProc, (LPARAM)m_bRunAs); + if (result == 1 || result == 0) { - WCHAR newpath[2*MAX_PATH] = L"\0"; - if (wcschr(pThis->m_sPath, ' ')) - StringCchPrintfExW(newpath, _countof(newpath), NULL, NULL, 0, L"\"%ls\"", pThis->m_sPath); - else - StringCchCopyExW(newpath, _countof(newpath), pThis->m_sPath, NULL, NULL, 0); - - if (pThis->m_sArgs && pThis->m_sArgs[0]) + if (m_bRunAs != result) { - StringCchCatW(newpath, _countof(newpath), L" "); - StringCchCatW(newpath, _countof(newpath), pThis->m_sArgs); + PropSheet_Changed(GetParent(hwndDlg), hwndDlg); } - SetDlgItemTextW(hwndDlg, IDC_SHORTCUT_TARGET_TEXT, newpath); + + m_bRunAs = result; } + return; + } + } + if (codeNotify == EN_CHANGE) + { + if (!m_bInInit) + PropSheet_Changed(GetParent(hwndDlg), hwndDlg); + } +} + +LRESULT CShellLink::OnNotify(HWND hwndDlg, int idFrom, LPNMHDR pnmhdr) +{ + WCHAR wszBuf[MAX_PATH]; + LPPSHNOTIFY lppsn = (LPPSHNOTIFY)pnmhdr; - /* Working dir */ - if (pThis->m_sWorkDir) - SetDlgItemTextW(hwndDlg, IDC_SHORTCUT_START_IN_EDIT, pThis->m_sWorkDir); + if (lppsn->hdr.code == PSN_APPLY) + { + /* set working directory */ + GetDlgItemTextW(hwndDlg, IDC_SHORTCUT_START_IN_EDIT, wszBuf, _countof(wszBuf)); + SetWorkingDirectory(wszBuf); + + /* set link destination */ + GetDlgItemTextW(hwndDlg, IDC_SHORTCUT_TARGET_TEXT, wszBuf, _countof(wszBuf)); + LPWSTR lpszArgs = NULL; + LPWSTR unquoted = strdupW(wszBuf); + StrTrimW(unquoted, L" "); - /* Description */ - if (pThis->m_sDescription) - SetDlgItemTextW(hwndDlg, IDC_SHORTCUT_COMMENT_EDIT, pThis->m_sDescription); + 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")) + { + // 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; } - case WM_NOTIFY: + if (!PathFileExistsW(unquoted)) { - LPPSHNOTIFY lppsn = (LPPSHNOTIFY)lParam; - if (lppsn->hdr.code == PSN_APPLY) - { - WCHAR wszBuf[MAX_PATH]; - /* set working directory */ - GetDlgItemTextW(hwndDlg, IDC_SHORTCUT_START_IN_EDIT, wszBuf, _countof(wszBuf)); - pThis->SetWorkingDirectory(wszBuf); - /* set link destination */ - GetDlgItemTextW(hwndDlg, IDC_SHORTCUT_TARGET_TEXT, wszBuf, _countof(wszBuf)); - LPWSTR lpszArgs = NULL; - LPWSTR unquoted = strdupW(wszBuf); - StrTrimW(unquoted, L" "); - if (!PathFileExistsW(unquoted)) - { - lpszArgs = PathGetArgsW(unquoted); - PathRemoveArgsW(unquoted); - StrTrimW(lpszArgs, L" "); - } - if (unquoted[0] == '"' && unquoted[wcslen(unquoted)-1] == '"') - PathUnquoteSpacesW(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"); - 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; - } + HeapFree(GetProcessHeap(), 0, unquoted); - 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; - } + TRACE("This %p m_sLinkPath %S\n", this, m_sLinkPath); + Save(m_sLinkPath, TRUE); + SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR); + return TRUE; + } + return FALSE; +} - pThis->SetPath(unquoted); - if (lpszArgs) - pThis->SetArguments(lpszArgs); - else - pThis->SetArguments(L"\0"); +void CShellLink::OnDestroy(HWND hwndDlg) +{ + if (m_hIcon) + { + DestroyIcon(m_hIcon); + m_hIcon = NULL; + } +} - HeapFree(GetProcessHeap(), 0, unquoted); +/************************************************************************** + * SH_ShellLinkDlgProc + * + * dialog proc of the shortcut property dialog + */ - TRACE("This %p m_sLinkPath %S\n", pThis, pThis->m_sLinkPath); - pThis->Save(pThis->m_sLinkPath, TRUE); - SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR); - return TRUE; - } - break; - } +INT_PTR CALLBACK +CShellLink::SH_ShellLinkDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + LPPROPSHEETPAGEW ppsp; + CShellLink *pThis = reinterpret_cast<CShellLink *>(GetWindowLongPtr(hwndDlg, DWLP_USER)); + + switch (uMsg) + { + case WM_INITDIALOG: + ppsp = (LPPROPSHEETPAGEW)lParam; + if (ppsp == NULL) + break; + + pThis = reinterpret_cast<CShellLink *>(ppsp->lParam); + SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pThis); + return pThis->OnInitDialog(hwndDlg, (HWND)(wParam), lParam); + + case WM_NOTIFY: + return pThis->OnNotify(hwndDlg, (int)wParam, (NMHDR *)lParam); case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDC_SHORTCUT_FIND: - SHOpenFolderAndSelectItems(pThis->m_pPidl, 0, NULL, 0); - /// - /// FIXME - /// open target directory - /// - return TRUE; - - case IDC_SHORTCUT_CHANGE_ICON: - { - WCHAR wszPath[MAX_PATH] = L""; - - if (pThis->m_sIcoPath) - wcscpy(wszPath, pThis->m_sIcoPath); - else - FindExecutableW(pThis->m_sPath, NULL, wszPath); - - INT IconIndex = pThis->m_Header.nIconIndex; - if (PickIconDlg(hwndDlg, wszPath, _countof(wszPath), &IconIndex)) - { - pThis->SetIconLocation(wszPath, IconIndex); - - HICON hIconLarge = NULL; - if (S_OK == pThis->Extract(wszPath, IconIndex, &hIconLarge, NULL, 0)) - { - HICON hIconOld = (HICON)SendDlgItemMessageW(hwndDlg, IDC_SHORTCUT_ICON, STM_GETICON, 0, 0); - SendDlgItemMessageW(hwndDlg, IDC_SHORTCUT_ICON, STM_SETICON, (WPARAM)hIconLarge, 0); - DestroyIcon(hIconOld); - } - } - return TRUE; - } + pThis->OnCommand(hwndDlg, LOWORD(wParam), (HWND)lParam, HIWORD(wParam)); + break; - case IDC_SHORTCUT_ADVANCED: - { - INT_PTR result = DialogBoxParamW(shell32_hInstance, MAKEINTRESOURCEW(IDD_SHORTCUT_EXTENDED_PROPERTIES), hwndDlg, ExtendedShortcutProc, (LPARAM)pThis->m_bRunAs); - if (result == 1 || result == 0) - { - if (pThis->m_bRunAs != result) - { - PropSheet_Changed(GetParent(hwndDlg), hwndDlg); - } - - pThis->m_bRunAs = result; - } - return TRUE; - } - } - if (HIWORD(wParam) == EN_CHANGE) - PropSheet_Changed(GetParent(hwndDlg), hwndDlg); + case WM_DESTROY: + pThis->OnDestroy(hwndDlg); break; default: break; } + return FALSE; } @@ -3083,3 +3150,64 @@ HRESULT WINAPI IShellLink_ConstructFromFile(IShellFolder * psf, LPCITEMIDLIST pi return IShellLink_ConstructFromPath(path, riid, ppv); } + +HICON CShellLink::CreateShortcutIcon(LPCWSTR wszIconPath, INT IconIndex) +{ + const INT cx = GetSystemMetrics(SM_CXICON), cy = GetSystemMetrics(SM_CYICON); + const COLORREF crMask = GetSysColor(COLOR_3DFACE); + HDC hDC; + HIMAGELIST himl = ImageList_Create(cx, cy, ILC_COLOR32 | ILC_MASK, 1, 1); + HICON hIcon = NULL, hNewIcon = NULL; + HICON hShortcut = (HICON)LoadImageW(shell32_hInstance, MAKEINTRESOURCE(IDI_SHELL_SHORTCUT), + IMAGE_ICON, cx, cy, 0); + + ::ExtractIconExW(wszIconPath, IconIndex, &hIcon, NULL, 1); + if (!hIcon || !hShortcut || !himl) + goto cleanup; + + hDC = CreateCompatibleDC(NULL); + if (hDC) + { + // create 32bpp bitmap + BITMAPINFO bi; + ZeroMemory(&bi, sizeof(bi)); + bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bi.bmiHeader.biWidth = cx; + bi.bmiHeader.biHeight = cy; + bi.bmiHeader.biPlanes = 1; + bi.bmiHeader.biBitCount = 32; + LPVOID pvBits; + HBITMAP hbm = CreateDIBSection(hDC, &bi, DIB_RGB_COLORS, &pvBits, NULL, 0); + if (hbm) + { + // draw the icon image + HGDIOBJ hbmOld = SelectObject(hDC, hbm); + { + HBRUSH hbr = CreateSolidBrush(crMask); + RECT rc = { 0, 0, cx, cy }; + FillRect(hDC, &rc, hbr); + DeleteObject(hbr); + + DrawIconEx(hDC, 0, 0, hIcon, cx, cy, 0, NULL, DI_NORMAL); + DrawIconEx(hDC, 0, 0, hShortcut, cx, cy, 0, NULL, DI_NORMAL); + } + SelectObject(hDC, hbmOld); + + INT iAdded = ImageList_AddMasked(himl, hbm, crMask); + hNewIcon = ImageList_GetIcon(himl, iAdded, ILD_NORMAL | ILD_TRANSPARENT); + + DeleteObject(hbm); + } + DeleteDC(hDC); + } + +cleanup: + if (hIcon) + DestroyIcon(hIcon); + if (hShortcut) + DestroyIcon(hShortcut); + if (himl) + ImageList_Destroy(himl); + + return hNewIcon; +} diff --git a/dll/win32/shell32/CShellLink.h b/dll/win32/shell32/CShellLink.h index c8ce27efad..3380a526c3 100644 --- a/dll/win32/shell32/CShellLink.h +++ b/dll/win32/shell32/CShellLink.h @@ -81,6 +81,8 @@ private: BOOL m_bRunAs; BOOL m_bDirty; LPDBLIST m_pDBList; /* Optional data block list (in the extra data section) */ + BOOL m_bInInit; // in initialization or not + HICON m_hIcon; /* Pointers to strings inside Logo3/Darwin info blocks, cached for debug info purposes only */ LPWSTR sProduct; @@ -98,12 +100,18 @@ private: HRESULT SetAdvertiseInfo(LPCWSTR str); HRESULT WriteAdvertiseInfo(LPCWSTR string, DWORD dwSig); HRESULT SetTargetFromPIDLOrPath(LPCITEMIDLIST pidl, LPCWSTR pszFile); + HICON CreateShortcutIcon(LPCWSTR wszIconPath, INT IconIndex); public: CShellLink(); ~CShellLink(); static INT_PTR CALLBACK SH_ShellLinkDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); + BOOL OnInitDialog(HWND hwndDlg, HWND hwndFocus, LPARAM lParam); + void OnCommand(HWND hwndDlg, int id, HWND hwndCtl, UINT codeNotify); + LRESULT OnNotify(HWND hwndDlg, int idFrom, LPNMHDR pnmhdr); + void OnDestroy(HWND hwndDlg); + // IPersistFile virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pclsid); virtual HRESULT STDMETHODCALLTYPE IsDirty();
6 years, 5 months
1
0
0
0
01/01: [APPWIZ] Add support for creating internet shortcuts (#664)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=33a65d45aa81c3296cfd3…
commit 33a65d45aa81c3296cfd31be405345e9a4050435 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Sun Jul 8 23:40:14 2018 +0900 Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Jul 8 16:40:14 2018 +0200 [APPWIZ] Add support for creating internet shortcuts (#664) CORE-8737 --- dll/cpl/appwiz/CMakeLists.txt | 2 +- dll/cpl/appwiz/appwiz.h | 4 + dll/cpl/appwiz/createlink.c | 220 ++++++++++++++++++++++++++++-------------- dll/cpl/appwiz/lang/bg-BG.rc | 3 + dll/cpl/appwiz/lang/cs-CZ.rc | 3 + dll/cpl/appwiz/lang/de-DE.rc | 3 + dll/cpl/appwiz/lang/el-GR.rc | 3 + dll/cpl/appwiz/lang/en-US.rc | 3 + dll/cpl/appwiz/lang/es-ES.rc | 3 + dll/cpl/appwiz/lang/et-EE.rc | 3 + dll/cpl/appwiz/lang/fr-FR.rc | 3 + dll/cpl/appwiz/lang/he-IL.rc | 3 + dll/cpl/appwiz/lang/it-IT.rc | 3 + dll/cpl/appwiz/lang/ja-JP.rc | 3 + dll/cpl/appwiz/lang/no-NO.rc | 3 + dll/cpl/appwiz/lang/pl-PL.rc | 3 + dll/cpl/appwiz/lang/pt-BR.rc | 3 + dll/cpl/appwiz/lang/ro-RO.rc | 3 + dll/cpl/appwiz/lang/ru-RU.rc | 3 + dll/cpl/appwiz/lang/sk-SK.rc | 3 + dll/cpl/appwiz/lang/sq-AL.rc | 3 + dll/cpl/appwiz/lang/tr-TR.rc | 3 + dll/cpl/appwiz/lang/uk-UA.rc | 3 + dll/cpl/appwiz/lang/zh-CN.rc | 3 + dll/cpl/appwiz/lang/zh-TW.rc | 3 + dll/cpl/appwiz/resource.h | 3 + 26 files changed, 221 insertions(+), 74 deletions(-) diff --git a/dll/cpl/appwiz/CMakeLists.txt b/dll/cpl/appwiz/CMakeLists.txt index cf926cb656..1a7e4a048c 100644 --- a/dll/cpl/appwiz/CMakeLists.txt +++ b/dll/cpl/appwiz/CMakeLists.txt @@ -24,6 +24,6 @@ add_library(appwiz SHARED set_module_type(appwiz cpl UNICODE) target_link_libraries(appwiz uuid wine) add_delay_importlibs(appwiz msi) -add_importlibs(appwiz urlmon ole32 comctl32 advapi32 shell32 user32 msvcrt kernel32 ntdll) +add_importlibs(appwiz urlmon ole32 comctl32 advapi32 shell32 shlwapi user32 msvcrt kernel32 ntdll) add_pch(appwiz appwiz.h SOURCE) add_cd_file(TARGET appwiz DESTINATION reactos/system32 FOR all) diff --git a/dll/cpl/appwiz/appwiz.h b/dll/cpl/appwiz/appwiz.h index 632345b877..fa38884869 100644 --- a/dll/cpl/appwiz/appwiz.h +++ b/dll/cpl/appwiz/appwiz.h @@ -17,6 +17,8 @@ #include <winreg.h> #include <winnls.h> #include <shlobj.h> +#include <intshcut.h> +#include <shlwapi.h> #include <wine/debug.h> WINE_DEFAULT_DEBUG_CHANNEL(appwiz); @@ -28,6 +30,8 @@ typedef struct WCHAR szTarget[MAX_PATH]; WCHAR szWorkingDirectory[MAX_PATH]; WCHAR szDescription[MAX_PATH]; + WCHAR szOrigin[MAX_PATH]; + WCHAR szOldFile[MAX_PATH]; WCHAR szLinkName[MAX_PATH]; } CREATE_LINK_CONTEXT, *PCREATE_LINK_CONTEXT; diff --git a/dll/cpl/appwiz/createlink.c b/dll/cpl/appwiz/createlink.c index ba83643f34..4788cc878b 100644 --- a/dll/cpl/appwiz/createlink.c +++ b/dll/cpl/appwiz/createlink.c @@ -5,13 +5,13 @@ * PROGRAMMER: Gero Kuehn (reactos.filter(a)gkware.com) * Dmitry Chapyshev (lentind(a)yandex.ru) * Johannes Anderwald + * Katayama Hirofumi MZ (katayama.hirofumi.mz(a)gmail.com) * UPDATE HISTORY: * 06-17-2004 Created */ #include "appwiz.h" - -#include <tchar.h> +#include <strsafe.h> BOOL IsShortcut(HKEY hKey) @@ -79,70 +79,102 @@ CreateShortcut(PCREATE_LINK_CONTEXT pContext) LPWSTR lpExtension; /* get the extension */ - lpExtension = wcsrchr(pContext->szTarget, '.'); + lpExtension = PathFindExtensionW(pContext->szTarget); if (IsExtensionAShortcut(lpExtension)) { hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_ALL, &IID_IShellLinkW, (void**)&pSourceShellLink); - if (hr != S_OK) + if (FAILED(hr)) return FALSE; - hr = pSourceShellLink->lpVtbl->QueryInterface(pSourceShellLink, &IID_IPersistFile, (void**)&pPersistFile); - if (hr != S_OK) + hr = IUnknown_QueryInterface(pSourceShellLink, &IID_IPersistFile, (void**)&pPersistFile); + if (FAILED(hr)) { - pSourceShellLink->lpVtbl->Release(pSourceShellLink); + IUnknown_Release(pSourceShellLink); return FALSE; } hr = pPersistFile->lpVtbl->Load(pPersistFile, (LPCOLESTR)pContext->szTarget, STGM_READ); - pPersistFile->lpVtbl->Release(pPersistFile); + IUnknown_Release(pPersistFile); - if (hr != S_OK) + if (FAILED(hr)) { - pSourceShellLink->lpVtbl->Release(pSourceShellLink); + IUnknown_Release(pSourceShellLink); return FALSE; } - hr = pSourceShellLink->lpVtbl->GetPath(pSourceShellLink, Path, sizeof(Path) / sizeof(WCHAR), NULL, 0); - pSourceShellLink->lpVtbl->Release(pSourceShellLink); + hr = IShellLinkW_GetPath(pSourceShellLink, Path, _countof(Path), NULL, 0); + IUnknown_Release(pSourceShellLink); - if (hr != S_OK) + if (FAILED(hr)) { return FALSE; } } else { - wcscpy(Path, pContext->szTarget); + StringCchCopyW(Path, _countof(Path), pContext->szTarget); } hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_ALL, - &IID_IShellLinkW, (void**)&pShellLink); + &IID_IShellLinkW, (void**)&pShellLink); if (hr != S_OK) return FALSE; - pShellLink->lpVtbl->SetPath(pShellLink, Path); pShellLink->lpVtbl->SetDescription(pShellLink, pContext->szDescription); pShellLink->lpVtbl->SetWorkingDirectory(pShellLink, pContext->szWorkingDirectory); - hr = pShellLink->lpVtbl->QueryInterface(pShellLink, &IID_IPersistFile, (void**)&pPersistFile); + hr = IUnknown_QueryInterface(pShellLink, &IID_IPersistFile, (void**)&pPersistFile); if (hr != S_OK) { - pShellLink->lpVtbl->Release(pShellLink); + IUnknown_Release(pShellLink); return FALSE; } hr = pPersistFile->lpVtbl->Save(pPersistFile, pContext->szLinkName, TRUE); - pPersistFile->lpVtbl->Release(pPersistFile); - pShellLink->lpVtbl->Release(pShellLink); + IUnknown_Release(pPersistFile); + IUnknown_Release(pShellLink); return (hr == S_OK); } +BOOL +CreateInternetShortcut(PCREATE_LINK_CONTEXT pContext) +{ + IUniformResourceLocatorW *pURL = NULL; + IPersistFile *pPersistFile = NULL; + HRESULT hr; + WCHAR szPath[MAX_PATH]; + GetFullPathNameW(pContext->szLinkName, _countof(szPath), szPath, NULL); + + hr = CoCreateInstance(&CLSID_InternetShortcut, NULL, CLSCTX_ALL, + &IID_IUniformResourceLocatorW, (void **)&pURL); + if (FAILED(hr)) + return FALSE; + + hr = IUnknown_QueryInterface(pURL, &IID_IPersistFile, (void **)&pPersistFile); + if (FAILED(hr)) + { + IUnknown_Release(pURL); + return FALSE; + } + + pURL->lpVtbl->SetURL(pURL, pContext->szTarget, 0); + + hr = pPersistFile->lpVtbl->Save(pPersistFile, szPath, TRUE); + + IUnknown_Release(pPersistFile); + IUnknown_Release(pURL); + return SUCCEEDED(hr); +} +BOOL IsInternetLocation(LPCWSTR pszLocation) +{ + return (PathIsURLW(pszLocation) || wcsstr(pszLocation, L"www.") == pszLocation); +} INT_PTR CALLBACK @@ -158,7 +190,6 @@ WelcomeDlgProc(HWND hwndDlg, WCHAR szDesc[100]; BROWSEINFOW brws; LPITEMIDLIST pidllist; - IMalloc* malloc; switch(uMsg) { @@ -196,15 +227,10 @@ WelcomeDlgProc(HWND hwndDlg, break; if (SHGetPathFromIDListW(pidllist, szPath)) - SendDlgItemMessage(hwndDlg, IDC_SHORTCUT_LOCATION, WM_SETTEXT, 0, (LPARAM)szPath); + SetDlgItemTextW(hwndDlg, IDC_SHORTCUT_LOCATION, szPath); /* Free memory, if possible */ - if (SUCCEEDED(SHGetMalloc(&malloc))) - { - IMalloc_Free(malloc, pidllist); - IMalloc_Release(malloc); - } - + CoTaskMemFree(pidllist); break; } break; @@ -212,47 +238,45 @@ WelcomeDlgProc(HWND hwndDlg, lppsn = (LPPSHNOTIFY) lParam; if (lppsn->hdr.code == PSN_WIZNEXT) { + LPWSTR pch; pContext = (PCREATE_LINK_CONTEXT) GetWindowLongPtr(hwndDlg, DWLP_USER); - SendDlgItemMessageW(hwndDlg, IDC_SHORTCUT_LOCATION, WM_GETTEXT, MAX_PATH, (LPARAM)pContext->szTarget); - /// - /// FIXME - /// it should also be possible to create a link to folders, shellobjects etc.... - /// - if (GetFileAttributesW(pContext->szTarget) == INVALID_FILE_ATTRIBUTES) + GetDlgItemTextW(hwndDlg, IDC_SHORTCUT_LOCATION, pContext->szTarget, _countof(pContext->szTarget)); + StrTrimW(pContext->szTarget, L" \t"); + + if (IsInternetLocation(pContext->szTarget)) { - szDesc[0] = L'\0'; - szPath[0] = L'\0'; - if (LoadStringW(hApplet, IDS_CREATE_SHORTCUT, szDesc, 100) < 100 && - LoadStringW(hApplet, IDS_ERROR_NOT_FOUND, szPath, MAX_PATH) < MAX_PATH) - { - WCHAR szError[MAX_PATH + 100]; - swprintf(szError, szPath, pContext->szTarget); - MessageBoxW(hwndDlg, szError, szDesc, MB_ICONERROR); - } + /* internet */ + WCHAR szName[128]; + LoadStringW(hApplet, IDS_NEW_INTERNET_SHORTCUT, szName, _countof(szName)); + StringCchCopyW(pContext->szDescription, _countof(pContext->szDescription), szName); + + pContext->szWorkingDirectory[0] = 0; + } + else if (GetFileAttributesW(pContext->szTarget) != INVALID_FILE_ATTRIBUTES) + { + /* file */ SendDlgItemMessage(hwndDlg, IDC_SHORTCUT_LOCATION, EM_SETSEL, 0, -1); SetFocus(GetDlgItem(hwndDlg, IDC_SHORTCUT_LOCATION)); SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE); - return -1; + + /* set working directory */ + StringCchCopyW(pContext->szWorkingDirectory, _countof(pContext->szWorkingDirectory), + pContext->szTarget); + PathRemoveBackslashW(pContext->szWorkingDirectory); + pch = PathFindFileNameW(pContext->szWorkingDirectory); + if (pch && *pch) + *pch = 0; + PathRemoveBackslashW(pContext->szWorkingDirectory); } else { - WCHAR * first, *last; - wcscpy(pContext->szWorkingDirectory, pContext->szTarget); - first = wcschr(pContext->szWorkingDirectory, L'\\'); - last = wcsrchr(pContext->szWorkingDirectory, L'\\'); - wcscpy(pContext->szDescription, &last[1]); - - if (first != last) - last[0] = L'\0'; - else - first[1] = L'\0'; - - first = wcsrchr(pContext->szDescription, L'.'); - - if(first) - first[0] = L'\0'; + /* not found */ + WCHAR szError[MAX_PATH + 100]; + LoadStringW(hApplet, IDS_CREATE_SHORTCUT, szDesc, _countof(szDesc)); + LoadStringW(hApplet, IDS_ERROR_NOT_FOUND, szPath, _countof(szPath)); + StringCchPrintfW(szError, _countof(szError), szPath, pContext->szTarget); + MessageBoxW(hwndDlg, szError, szDesc, MB_ICONERROR); } - } break; } @@ -276,7 +300,7 @@ FinishDlgProc(HWND hwndDlg, ppsp = (LPPROPSHEETPAGEW)lParam; pContext = (PCREATE_LINK_CONTEXT) ppsp->lParam; SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pContext); - SendDlgItemMessageW(hwndDlg, IDC_SHORTCUT_NAME, WM_SETTEXT, 0, (LPARAM)pContext->szDescription); + SetDlgItemTextW(hwndDlg, IDC_SHORTCUT_NAME, pContext->szDescription); PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_FINISH); break; case WM_COMMAND: @@ -299,16 +323,60 @@ FinishDlgProc(HWND hwndDlg, pContext = (PCREATE_LINK_CONTEXT) GetWindowLongPtr(hwndDlg, DWLP_USER); if (lppsn->hdr.code == PSN_WIZFINISH) { - SendDlgItemMessageW(hwndDlg, IDC_SHORTCUT_NAME, WM_GETTEXT, MAX_PATH, (LPARAM)pContext->szDescription); - wcscat(pContext->szLinkName, pContext->szDescription); - wcscat(pContext->szLinkName, L".lnk"); - if (!CreateShortcut(pContext)) + LPWSTR pch; + DWORD attrs; + GetDlgItemTextW(hwndDlg, IDC_SHORTCUT_NAME, pContext->szDescription, MAX_PATH); + StrTrimW(pContext->szDescription, L" \t"); + + /* if old shortcut file exists, then delete it now */ + attrs = GetFileAttributesW(pContext->szOldFile); + if (attrs != INVALID_FILE_ATTRIBUTES && !(attrs & FILE_ATTRIBUTE_DIRECTORY)) { - MessageBox(hwndDlg, _T("Failed to create shortcut"), _T("Error"), MB_ICONERROR); + DeleteFileW(pContext->szOldFile); } - } - + if (IsInternetLocation(pContext->szTarget)) + { + /* internet */ + StringCchCopyW(pContext->szLinkName, _countof(pContext->szLinkName), + pContext->szOrigin); + PathAppendW(pContext->szLinkName, pContext->szDescription); + + /* change extension if any */ + pch = PathFindExtensionW(pContext->szLinkName); + if (pch && *pch) + *pch = 0; + StringCchCatW(pContext->szLinkName, _countof(pContext->szLinkName), L".url"); + + if (!CreateInternetShortcut(pContext)) + { + WCHAR szMessage[128]; + LoadStringW(hApplet, IDS_CANTMAKEINETSHORTCUT, szMessage, _countof(szMessage)); + MessageBoxW(hwndDlg, szMessage, NULL, MB_ICONERROR); + } + } + else + { + /* file */ + StringCchCopyW(pContext->szLinkName, _countof(pContext->szLinkName), + pContext->szOrigin); + PathAppendW(pContext->szLinkName, pContext->szDescription); + + /* change extension if any */ + pch = PathFindExtensionW(pContext->szLinkName); + if (pch && *pch) + *pch = 0; + StringCchCatW(pContext->szLinkName, _countof(pContext->szLinkName), L".lnk"); + + if (!CreateShortcut(pContext)) + { + WCHAR szMessage[128]; + LoadStringW(hApplet, IDS_CANTMAKESHORTCUT, szMessage, _countof(szMessage)); + MessageBoxW(hwndDlg, szMessage, NULL, MB_ICONERROR); + } + } + } + break; } return FALSE; } @@ -329,6 +397,7 @@ ShowCreateShortcutWizard(HWND hwndCPl, LPWSTR szPath) /* no memory */ return FALSE; } + nLength = wcslen(szPath); if (!nLength) { @@ -347,13 +416,18 @@ ShowCreateShortcutWizard(HWND hwndCPl, LPWSTR szPath) return FALSE; } - wcscpy(pContext->szLinkName, szPath); - if (pContext->szLinkName[nLength-1] != L'\\') + /* build the pContext->szOrigin and pContext->szOldFile */ + StringCchCopyW(pContext->szOrigin, _countof(pContext->szOrigin), szPath); + pContext->szOldFile[0] = 0; + if (!(attrs & FILE_ATTRIBUTE_DIRECTORY)) { - pContext->szLinkName[nLength] = L'\\'; - pContext->szLinkName[nLength+1] = L'\0'; + LPWSTR pch; + StringCchCopyW(pContext->szOldFile, _countof(pContext->szOldFile), szPath); + pch = PathFindFileNameW(pContext->szOrigin); + if (pch && *pch) + *pch = 0; } - + PathAddBackslashW(pContext->szOrigin); /* Create the Welcome page */ psp.dwSize = sizeof(PROPSHEETPAGE); diff --git a/dll/cpl/appwiz/lang/bg-BG.rc b/dll/cpl/appwiz/lang/bg-BG.rc index aea61b4278..f1a883b21b 100644 --- a/dll/cpl/appwiz/lang/bg-BG.rc +++ b/dll/cpl/appwiz/lang/bg-BG.rc @@ -78,4 +78,7 @@ BEGIN IDS_DOWNLOADING "Downloading..." IDS_INSTALLING "Installing..." IDS_INVALID_SHA "Unexpected checksum of downloaded file. Aborting installation of corrupted file." + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/cs-CZ.rc b/dll/cpl/appwiz/lang/cs-CZ.rc index 8238fc3e24..3b60b303ca 100644 --- a/dll/cpl/appwiz/lang/cs-CZ.rc +++ b/dll/cpl/appwiz/lang/cs-CZ.rc @@ -83,4 +83,7 @@ BEGIN IDS_DOWNLOADING "Stahování..." IDS_INSTALLING "Instalace..." IDS_INVALID_SHA "Stažený soubor má neplatný kontrolní součet. Instalace poškozeného souboru bude přerušena." + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/de-DE.rc b/dll/cpl/appwiz/lang/de-DE.rc index 26cc670b44..7dca52c8fa 100644 --- a/dll/cpl/appwiz/lang/de-DE.rc +++ b/dll/cpl/appwiz/lang/de-DE.rc @@ -78,4 +78,7 @@ BEGIN IDS_DOWNLOADING "Lade herunter..." IDS_INSTALLING "Installiere..." IDS_INVALID_SHA "Die heruntergeladene Datei hat eine unerwartete Prüfsumme. Abbruch der Installation aufgrund beschädigter Datei." + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/el-GR.rc b/dll/cpl/appwiz/lang/el-GR.rc index bb799dc52e..d747592d19 100644 --- a/dll/cpl/appwiz/lang/el-GR.rc +++ b/dll/cpl/appwiz/lang/el-GR.rc @@ -78,4 +78,7 @@ BEGIN IDS_DOWNLOADING "Downloading..." IDS_INSTALLING "Installing..." IDS_INVALID_SHA "Unexpected checksum of downloaded file. Aborting installation of corrupted file." + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/en-US.rc b/dll/cpl/appwiz/lang/en-US.rc index 1896cd9074..e5d9516b17 100644 --- a/dll/cpl/appwiz/lang/en-US.rc +++ b/dll/cpl/appwiz/lang/en-US.rc @@ -78,4 +78,7 @@ BEGIN IDS_DOWNLOADING "Downloading..." IDS_INSTALLING "Installing..." IDS_INVALID_SHA "Unexpected checksum of downloaded file. Aborting installation of corrupted file." + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/es-ES.rc b/dll/cpl/appwiz/lang/es-ES.rc index ab63639a6d..949de044c3 100644 --- a/dll/cpl/appwiz/lang/es-ES.rc +++ b/dll/cpl/appwiz/lang/es-ES.rc @@ -84,4 +84,7 @@ BEGIN IDS_DOWNLOADING "Descargando..." IDS_INSTALLING "Instalando..." IDS_INVALID_SHA "La suma de verificación del archivo descargado no coincide. Se ha cancelado la instalación del archivo corrupto." + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/et-EE.rc b/dll/cpl/appwiz/lang/et-EE.rc index 926b579473..6d41c1bbd1 100644 --- a/dll/cpl/appwiz/lang/et-EE.rc +++ b/dll/cpl/appwiz/lang/et-EE.rc @@ -85,4 +85,7 @@ BEGIN IDS_DOWNLOADING "Allalaadimine..." IDS_INSTALLING "Paigaldamine..." IDS_INVALID_SHA "Kontrollsumma ei kattu. Paigaldamine katkestatud korrupteerinud faili tõttu." + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/fr-FR.rc b/dll/cpl/appwiz/lang/fr-FR.rc index cb23ebef3a..6c942eeeb3 100644 --- a/dll/cpl/appwiz/lang/fr-FR.rc +++ b/dll/cpl/appwiz/lang/fr-FR.rc @@ -78,4 +78,7 @@ BEGIN IDS_DOWNLOADING "Téléchargement..." IDS_INSTALLING "Installation..." IDS_INVALID_SHA "La somme de contrôle du fichier téléchargé est erronée. Abandon de l'installation du fichier corrompu." + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/he-IL.rc b/dll/cpl/appwiz/lang/he-IL.rc index 948ede82ec..145a093bd5 100644 --- a/dll/cpl/appwiz/lang/he-IL.rc +++ b/dll/cpl/appwiz/lang/he-IL.rc @@ -79,4 +79,7 @@ BEGIN IDS_DOWNLOADING "Downloading..." IDS_INSTALLING "Installing..." IDS_INVALID_SHA "Unexpected checksum of downloaded file. Aborting installation of corrupted file." + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/it-IT.rc b/dll/cpl/appwiz/lang/it-IT.rc index 4cb79f9bf8..f7b388cebf 100644 --- a/dll/cpl/appwiz/lang/it-IT.rc +++ b/dll/cpl/appwiz/lang/it-IT.rc @@ -78,4 +78,7 @@ BEGIN IDS_DOWNLOADING "Scaricando..." IDS_INSTALLING "Installando..." IDS_INVALID_SHA "Checksum imprevisto del file scaricato. Interruzione installazione del file danneggiato." + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/ja-JP.rc b/dll/cpl/appwiz/lang/ja-JP.rc index f63d532fb0..c70ab86ff4 100644 --- a/dll/cpl/appwiz/lang/ja-JP.rc +++ b/dll/cpl/appwiz/lang/ja-JP.rc @@ -78,4 +78,7 @@ BEGIN IDS_DOWNLOADING "ダウンロード中..." IDS_INSTALLING "インストール中..." IDS_INVALID_SHA "ダウンロードしたファイルのチェックサムが合致しません。壊れたファイルのインストールを中止しています。" + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/no-NO.rc b/dll/cpl/appwiz/lang/no-NO.rc index 2cb892a1c7..26295693e1 100644 --- a/dll/cpl/appwiz/lang/no-NO.rc +++ b/dll/cpl/appwiz/lang/no-NO.rc @@ -78,4 +78,7 @@ BEGIN IDS_DOWNLOADING "Downloading..." IDS_INSTALLING "Installing..." IDS_INVALID_SHA "Unexpected checksum of downloaded file. Aborting installation of corrupted file." + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/pl-PL.rc b/dll/cpl/appwiz/lang/pl-PL.rc index 4f2cba6b4c..faf2be54fb 100644 --- a/dll/cpl/appwiz/lang/pl-PL.rc +++ b/dll/cpl/appwiz/lang/pl-PL.rc @@ -87,4 +87,7 @@ BEGIN IDS_DOWNLOADING "Ściąganie..." IDS_INSTALLING "Instalowanie..." IDS_INVALID_SHA "Nieoczekiwana suma kontrolna ściągniętego pliku. Przerwanie instalacji uszkodzonego pliku." + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/pt-BR.rc b/dll/cpl/appwiz/lang/pt-BR.rc index 26309f7e92..cbfebd02c4 100644 --- a/dll/cpl/appwiz/lang/pt-BR.rc +++ b/dll/cpl/appwiz/lang/pt-BR.rc @@ -80,4 +80,7 @@ BEGIN IDS_DOWNLOADING "Downloading..." IDS_INSTALLING "Installing..." IDS_INVALID_SHA "Unexpected checksum of downloaded file. Aborting installation of corrupted file." + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/ro-RO.rc b/dll/cpl/appwiz/lang/ro-RO.rc index 0df84c5609..20464bafef 100644 --- a/dll/cpl/appwiz/lang/ro-RO.rc +++ b/dll/cpl/appwiz/lang/ro-RO.rc @@ -84,4 +84,7 @@ BEGIN IDS_DOWNLOADING "În curs de descărcare…" IDS_INSTALLING "În curs de instalare…" IDS_INVALID_SHA "Suma de control a fișierului descărcat nu corespunde. Deoarece fișierul a fost corupt, instalarea trebuie abandonată." + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/ru-RU.rc b/dll/cpl/appwiz/lang/ru-RU.rc index 00dc080900..aae79bc685 100644 --- a/dll/cpl/appwiz/lang/ru-RU.rc +++ b/dll/cpl/appwiz/lang/ru-RU.rc @@ -78,4 +78,7 @@ BEGIN IDS_DOWNLOADING "Загрузка..." IDS_INSTALLING "Установка..." IDS_INVALID_SHA "Ошибка контрольной суммы загруженного файла. Прерывание установки поврежденного файла." + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/sk-SK.rc b/dll/cpl/appwiz/lang/sk-SK.rc index c20ab5fe6d..5fb25dd6d9 100644 --- a/dll/cpl/appwiz/lang/sk-SK.rc +++ b/dll/cpl/appwiz/lang/sk-SK.rc @@ -82,4 +82,7 @@ BEGIN IDS_DOWNLOADING "Downloading..." IDS_INSTALLING "Installing..." IDS_INVALID_SHA "Unexpected checksum of downloaded file. Aborting installation of corrupted file." + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/sq-AL.rc b/dll/cpl/appwiz/lang/sq-AL.rc index 6517d0b018..4bdac0270e 100644 --- a/dll/cpl/appwiz/lang/sq-AL.rc +++ b/dll/cpl/appwiz/lang/sq-AL.rc @@ -82,4 +82,7 @@ BEGIN IDS_DOWNLOADING "Shkarkim..." IDS_INSTALLING "Instalim..." IDS_INVALID_SHA "Kontroll i papritur ne shkarkimin e skedarit. Duke lënë instalimin e dokumentave të korruptuar." + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/tr-TR.rc b/dll/cpl/appwiz/lang/tr-TR.rc index 35c170a6c6..8c9f6573b9 100644 --- a/dll/cpl/appwiz/lang/tr-TR.rc +++ b/dll/cpl/appwiz/lang/tr-TR.rc @@ -80,4 +80,7 @@ BEGIN IDS_DOWNLOADING "İndiriliyor..." IDS_INSTALLING "Kuruluyor..." IDS_INVALID_SHA "İndirilen kütüğün sağlama toplamı beklenmeyen. Bozuk kütüğün kurulumu iptal ediliyor." + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/uk-UA.rc b/dll/cpl/appwiz/lang/uk-UA.rc index 4c276fd698..94d1d23ef4 100644 --- a/dll/cpl/appwiz/lang/uk-UA.rc +++ b/dll/cpl/appwiz/lang/uk-UA.rc @@ -86,4 +86,7 @@ BEGIN IDS_DOWNLOADING "Downloading..." IDS_INSTALLING "Installing..." IDS_INVALID_SHA "Unexpected checksum of downloaded file. Aborting installation of corrupted file." + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/zh-CN.rc b/dll/cpl/appwiz/lang/zh-CN.rc index 9a07ba1ecb..4be6c8bcef 100644 --- a/dll/cpl/appwiz/lang/zh-CN.rc +++ b/dll/cpl/appwiz/lang/zh-CN.rc @@ -87,4 +87,7 @@ BEGIN IDS_DOWNLOADING "正在下载..." IDS_INSTALLING "正在安装..." IDS_INVALID_SHA "下载的文件校验和错误。中止安装已损坏的文件。" + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/lang/zh-TW.rc b/dll/cpl/appwiz/lang/zh-TW.rc index 083365a0e2..b123d0f91e 100644 --- a/dll/cpl/appwiz/lang/zh-TW.rc +++ b/dll/cpl/appwiz/lang/zh-TW.rc @@ -85,4 +85,7 @@ BEGIN IDS_DOWNLOADING "下載中..." IDS_INSTALLING "安裝中..." IDS_INVALID_SHA "意外的下載了的檔案的校驗和。中止安裝已損壞的檔案。" + IDS_NEW_INTERNET_SHORTCUT "New Internet Shortcut" + IDS_CANTMAKEINETSHORTCUT "Failed to create internet shortcut." + IDS_CANTMAKESHORTCUT "Failed to create shortcut." END diff --git a/dll/cpl/appwiz/resource.h b/dll/cpl/appwiz/resource.h index 2f721adda8..3df2999642 100644 --- a/dll/cpl/appwiz/resource.h +++ b/dll/cpl/appwiz/resource.h @@ -22,6 +22,9 @@ #define IDS_CPLSYSTEMDESCRIPTION 2001 #define IDS_CREATE_SHORTCUT 2021 #define IDS_ERROR_NOT_FOUND 2022 +#define IDS_NEW_INTERNET_SHORTCUT 2023 +#define IDS_CANTMAKEINETSHORTCUT 2024 +#define IDS_CANTMAKESHORTCUT 2025 #define IDS_DOWNLOADING 14 #define IDS_INSTALLING 15
6 years, 5 months
1
0
0
0
01/01: [EXPLORER] Fix TrackCtxMenu about NULL ppt (#666)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=58825de892e24abff17bc…
commit 58825de892e24abff17bc842b12ec389173c0dd5 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Sun Jul 8 23:36:28 2018 +0900 Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Jul 8 16:36:28 2018 +0200 [EXPLORER] Fix TrackCtxMenu about NULL ppt (#666) CORE-14772 --- base/shell/explorer/traywnd.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/base/shell/explorer/traywnd.cpp b/base/shell/explorer/traywnd.cpp index f116f3b953..aec731d22d 100644 --- a/base/shell/explorer/traywnd.cpp +++ b/base/shell/explorer/traywnd.cpp @@ -709,8 +709,9 @@ public: IN BOOL TrackUp, IN PVOID Context OPTIONAL) { - INT x = ppt->x; - INT y = ppt->y; + POINT pt; + TPMPARAMS params; + RECT rc; HRESULT hr; UINT uCommand; HMENU popup = CreatePopupMenu(); @@ -718,6 +719,17 @@ public: if (popup == NULL) return E_FAIL; + if (ppt) + { + pt = *ppt; + } + else + { + ::GetWindowRect(m_hWnd, &rc); + pt.x = rc.left; + pt.y = rc.top; + } + TRACE("Before Query\n"); hr = contextMenu->QueryContextMenu(popup, 0, 0, UINT_MAX, CMF_NORMAL); if (FAILED_UNEXPECTEDLY(hr)) @@ -728,7 +740,20 @@ public: } TRACE("Before Tracking\n"); - uCommand = ::TrackPopupMenuEx(popup, TPM_RETURNCMD, x, y, m_hWnd, NULL); + ::SetForegroundWindow(m_hWnd); + if (hwndExclude) + { + ::GetWindowRect(hwndExclude, &rc); + ZeroMemory(¶ms, sizeof(params)); + params.cbSize = sizeof(params); + params.rcExclude = rc; + uCommand = ::TrackPopupMenuEx(popup, TPM_RETURNCMD, pt.x, pt.y, m_hWnd, ¶ms); + } + else + { + uCommand = ::TrackPopupMenuEx(popup, TPM_RETURNCMD, pt.x, pt.y, m_hWnd, NULL); + } + ::PostMessage(m_hWnd, WM_NULL, 0, 0); if (uCommand != 0) {
6 years, 5 months
1
0
0
0
01/01: [SHELL32][EXPLORER] Update system-wide environment variables (#663)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a882ec7a02ec220e2c22c…
commit a882ec7a02ec220e2c22c129c9e993900a1dc237 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Sun Jul 8 23:32:42 2018 +0900 Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Jul 8 16:32:42 2018 +0200 [SHELL32][EXPLORER] Update system-wide environment variables (#663) - Implement shell32 RegenerateUserEnvironment() function and use it. - CShellBrowser and CDesktopBrowser implements WM_SETTINGCHANGE actions. CORE-1459, CORE-14397 --- base/shell/explorer/traywnd.cpp | 4 +-- dll/win32/browseui/shellbrowser.cpp | 10 ++++-- dll/win32/shell32/precomp.h | 1 + dll/win32/shell32/shell32.cpp | 42 ++++++++++++++++++++++ dll/win32/shell32/shelldesktop/CDesktopBrowser.cpp | 3 ++ dll/win32/shell32/stubs.cpp | 11 ------ sdk/include/reactos/undocshell.h | 3 ++ 7 files changed, 58 insertions(+), 16 deletions(-) diff --git a/base/shell/explorer/traywnd.cpp b/base/shell/explorer/traywnd.cpp index 2484b23f77..f116f3b953 100644 --- a/base/shell/explorer/traywnd.cpp +++ b/base/shell/explorer/traywnd.cpp @@ -2849,12 +2849,12 @@ HandleTrayContextMenu: MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove) MESSAGE_HANDLER(WM_NCMOUSEMOVE, OnMouseMove) MESSAGE_HANDLER(WM_APP_TRAYDESTROY, OnAppTrayDestroy) - MESSAGE_HANDLER(TWM_OPENSTARTMENU, OnOpenStartMenu) - MESSAGE_HANDLER(TWM_DOEXITWINDOWS, OnDoExitWindows) MESSAGE_HANDLER(WM_CLOSE, OnDoExitWindows) MESSAGE_HANDLER(WM_HOTKEY, OnHotkey) MESSAGE_HANDLER(WM_NCCALCSIZE, OnNcCalcSize) MESSAGE_HANDLER(TWM_SETTINGSCHANGED, OnTaskbarSettingsChanged) + MESSAGE_HANDLER(TWM_OPENSTARTMENU, OnOpenStartMenu) + MESSAGE_HANDLER(TWM_DOEXITWINDOWS, OnDoExitWindows) ALT_MSG_MAP(1) END_MSG_MAP() diff --git a/dll/win32/browseui/shellbrowser.cpp b/dll/win32/browseui/shellbrowser.cpp index a0cac36427..5345ef3285 100644 --- a/dll/win32/browseui/shellbrowser.cpp +++ b/dll/win32/browseui/shellbrowser.cpp @@ -23,6 +23,7 @@ #include <shellapi.h> #include <htiframe.h> #include <strsafe.h> +#include <undocshell.h> extern HRESULT IUnknown_ShowDW(IUnknown * punk, BOOL fShow); @@ -599,7 +600,7 @@ public: LRESULT OnInitMenuPopup(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); LRESULT RelayMsgToShellView(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); - LRESULT PropagateMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnSettingChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); LRESULT OnClose(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled); LRESULT OnFolderOptions(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled); LRESULT OnMapNetworkDrive(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled); @@ -645,7 +646,7 @@ public: MESSAGE_HANDLER(WM_MEASUREITEM, RelayMsgToShellView) MESSAGE_HANDLER(WM_DRAWITEM, RelayMsgToShellView) MESSAGE_HANDLER(WM_MENUSELECT, RelayMsgToShellView) - MESSAGE_HANDLER(WM_WININICHANGE, PropagateMessage) + MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange) COMMAND_ID_HANDLER(IDM_FILE_CLOSE, OnClose) COMMAND_ID_HANDLER(IDM_TOOLS_FOLDEROPTIONS, OnFolderOptions) COMMAND_ID_HANDLER(IDM_TOOLS_MAPNETWORKDRIVE, OnMapNetworkDrive) @@ -3512,8 +3513,11 @@ LRESULT CShellBrowser::RelayMsgToShellView(UINT uMsg, WPARAM wParam, LPARAM lPar return 0; } -LRESULT CShellBrowser::PropagateMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) +LRESULT CShellBrowser::OnSettingChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) { + LPVOID lpEnvironment; + RegenerateUserEnvironment(&lpEnvironment, TRUE); + SHPropagateMessage(m_hWnd, uMsg, wParam, lParam, TRUE); return 0; } diff --git a/dll/win32/shell32/precomp.h b/dll/win32/shell32/precomp.h index f7d4fe2d18..75c136664d 100644 --- a/dll/win32/shell32/precomp.h +++ b/dll/win32/shell32/precomp.h @@ -17,6 +17,7 @@ #include <wincon.h> #include <commdlg.h> #include <ddeml.h> +#include <userenv.h> #include <shlwapi.h> #include <shlobj.h> diff --git a/dll/win32/shell32/shell32.cpp b/dll/win32/shell32/shell32.cpp index ac0a3bd08c..a1d11c27ff 100644 --- a/dll/win32/shell32/shell32.cpp +++ b/dll/win32/shell32/shell32.cpp @@ -63,6 +63,48 @@ AddCommasW(DWORD lValue, LPWSTR lpNumber) return lpNumber; } +/* + * Implemented + */ +EXTERN_C BOOL +WINAPI +RegenerateUserEnvironment(LPVOID *lpEnvironment, BOOL bUpdateSelf) +{ + HANDLE hUserToken; + if (!OpenProcessToken(GetCurrentProcess(), TOKEN_READ | TOKEN_WRITE, &hUserToken)) + return FALSE; + + BOOL bResult = CreateEnvironmentBlock(lpEnvironment, hUserToken, TRUE); + if (!bResult || !lpEnvironment) + { + CloseHandle(hUserToken); + return FALSE; + } + + if (bUpdateSelf) + { + LPWSTR pszz = (LPWSTR)*lpEnvironment; + if (!pszz) + return FALSE; + + while (*pszz) + { + size_t cch = wcslen(pszz); + LPWSTR pchEqual = wcschr(pszz, L'='); + if (pchEqual) + { + CStringW strName(pszz, pchEqual - pszz); + SetEnvironmentVariableW(strName, pchEqual + 1); + } + pszz += cch + 1; + } + } + + CloseHandle(hUserToken); + + return bResult; +} + /************************************************************************** * Default ClassFactory types */ diff --git a/dll/win32/shell32/shelldesktop/CDesktopBrowser.cpp b/dll/win32/shell32/shelldesktop/CDesktopBrowser.cpp index e452039aa6..934f53d17b 100644 --- a/dll/win32/shell32/shelldesktop/CDesktopBrowser.cpp +++ b/dll/win32/shell32/shelldesktop/CDesktopBrowser.cpp @@ -390,6 +390,9 @@ LRESULT CDesktopBrowser::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &b LRESULT CDesktopBrowser::OnSettingChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) { + LPVOID lpEnvironment; + RegenerateUserEnvironment(&lpEnvironment, TRUE); + if (m_hWndShellView) { /* Forward the message */ diff --git a/dll/win32/shell32/stubs.cpp b/dll/win32/shell32/stubs.cpp index f2019e5f2d..8bc2f65296 100644 --- a/dll/win32/shell32/stubs.cpp +++ b/dll/win32/shell32/stubs.cpp @@ -643,17 +643,6 @@ SHChangeNotifySuspendResume(BOOL bSuspend, return FALSE; } -/* - * Unimplemented - */ -EXTERN_C BOOL -WINAPI -RegenerateUserEnvironment(LPVOID *lpUnknown, BOOL bUnknown) -{ - FIXME("RegenerateUserEnvironment() stub\n"); - return FALSE; -} - /* * Unimplemented */ diff --git a/sdk/include/reactos/undocshell.h b/sdk/include/reactos/undocshell.h index e74f201f86..24d6e82f55 100644 --- a/sdk/include/reactos/undocshell.h +++ b/sdk/include/reactos/undocshell.h @@ -526,6 +526,9 @@ typedef struct * Misc Stuff */ +BOOL WINAPI +RegenerateUserEnvironment(LPVOID *lpEnvironment, BOOL bUpdateSelf); + /* SHWaitForFileToOpen flags */ #define SHWFF_ADD 0x01 #define SHWFF_REMOVE 0x02
6 years, 5 months
1
0
0
0
03/03: [WIN32K:NTUSER] Remove the hackish code that has been introduced in IntSendChildNCPaint() in r73532 (6d7fcc4b) to attempt to pseudo-fix CORE-12071 and CORE-12085 while breaking other stuff, amongst which CORE-14763 is one of the latest manifestations, and re-enable the correct original code.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=25004bb5b424960358fda…
commit 25004bb5b424960358fda4ba9d8438246c0bef9e Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Sun Jul 8 02:24:30 2018 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Jul 8 15:39:50 2018 +0200 [WIN32K:NTUSER] Remove the hackish code that has been introduced in IntSendChildNCPaint() in r73532 (6d7fcc4b) to attempt to pseudo-fix CORE-12071 and CORE-12085 while breaking other stuff, amongst which CORE-14763 is one of the latest manifestations, and re-enable the correct original code. This fixes painting hangs under diverse situations, while CORE-12071 and CORE-12085 remain fixed. --- win32ss/user/ntuser/painting.c | 42 ++++++++++-------------------------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/win32ss/user/ntuser/painting.c b/win32ss/user/ntuser/painting.c index 5b4d04ff20..6a8b2a9bf7 100644 --- a/win32ss/user/ntuser/painting.c +++ b/win32ss/user/ntuser/painting.c @@ -366,38 +366,16 @@ IntSendNCPaint(PWND pWnd, HRGN hRgn) VOID FASTCALL IntSendChildNCPaint(PWND pWnd) { - PWND Child; - HWND *List, *phWnd; - - List = IntWinListChildren(UserGetDesktopWindow()); - if ( List ) - { - for (phWnd = List; *phWnd; ++phWnd) - { - Child = ValidateHwndNoErr(*phWnd); - if ( Child && Child->hrgnUpdate == NULL && Child->state & WNDS_SENDNCPAINT) - { - USER_REFERENCE_ENTRY Ref; - UserRefObjectCo(Child, &Ref); - IntSendNCPaint(Child, HRGN_WINDOW); - UserDerefObjectCo(Child); - } - } - ExFreePoolWithTag(List, USERTAG_WINDOWLIST); - } -/* FIXME : Use snap shot mode until window death is fixed while surfing menus! Fix CORE-12085 and CORE-12071. - pWnd = pWnd->spwndChild; - while(pWnd) - { - if (pWnd->hrgnUpdate == NULL && pWnd->state & WNDS_SENDNCPAINT) - { - USER_REFERENCE_ENTRY Ref; - UserRefObjectCo(pWnd, &Ref); - IntSendNCPaint(pWnd, HRGN_WINDOW); - UserDerefObjectCo(pWnd); - } - pWnd = pWnd->spwndNext; - }*/ + for (pWnd = pWnd->spwndChild; pWnd; pWnd = pWnd->spwndNext) + { + if ((pWnd->hrgnUpdate == NULL) && (pWnd->state & WNDS_SENDNCPAINT)) + { + USER_REFERENCE_ENTRY Ref; + UserRefObjectCo(pWnd, &Ref); + IntSendNCPaint(pWnd, HRGN_WINDOW); + UserDerefObjectCo(pWnd); + } + } } /*
6 years, 5 months
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
9
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
Results per page:
10
25
50
100
200