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
August 2022
----- 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
11 participants
86 discussions
Start a n
N
ew thread
[reactos] 01/01: [RAPPS] Don't send WM_SETTEXT directly
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=844d447e03caee6e2c33c…
commit 844d447e03caee6e2c33cfdfe5664b5f4f8ebdb7 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Thu Aug 25 17:40:23 2022 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Thu Aug 25 17:40:23 2022 +0900 [RAPPS] Don't send WM_SETTEXT directly Use SetWindowText and SetDlgItemText. CORE-14686 --- base/applications/rapps/loaddlg.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/base/applications/rapps/loaddlg.cpp b/base/applications/rapps/loaddlg.cpp index 18d67d347c4..de35ef65aa0 100644 --- a/base/applications/rapps/loaddlg.cpp +++ b/base/applications/rapps/loaddlg.cpp @@ -174,7 +174,7 @@ public: /* and finally display it */ if (!IsWindow()) return; - SendMessage(WM_SETTEXT, 0, (LPARAM) ProgressText.GetString()); + SetWindowText(ProgressText.GetString()); } LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) @@ -524,7 +524,7 @@ VOID CDownloadManager::UpdateProgress( } /* paste it into our dialog and don't do it again in this instance */ - SendMessageW(Item, WM_SETTEXT, 0, (LPARAM) buf.GetString()); + ::SetWindowText(Item, buf.GetString()); UrlHasBeenCopied = TRUE; } } @@ -597,7 +597,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param) if (Item) { ProgressBar.SetMarquee(FALSE); - ProgressBar.SendMessage(WM_SETTEXT, 0, (LPARAM) L""); + ProgressBar.SetWindowText(L""); ProgressBar.SendMessage(PBM_SETPOS, 0, 0); } @@ -919,7 +919,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param) if (!IsWindow(hDlg)) goto end; SetWindowTextW(hDlg, szMsgText.GetString()); - SendMessageW(GetDlgItem(hDlg, IDC_DOWNLOAD_STATUS), WM_SETTEXT, 0, (LPARAM) Path.GetString()); + ::SetDlgItemText(hDlg, IDC_DOWNLOAD_STATUS, Path.GetString()); // this may take a while, depending on the file size if (!VerifyInteg(InfoArray[iAppId].szSHA1.GetString(), Path.GetString()))
2 years, 4 months
1
0
0
0
[reactos] 01/01: [KBSWITCH] Follow-up of 0991ced
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=261416ddb94384fca091d…
commit 261416ddb94384fca091d3a6cf123bb247ce24f6 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Thu Aug 25 14:19:50 2022 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Thu Aug 25 14:19:50 2022 +0900 [KBSWITCH] Follow-up of 0991ced - Used FW_NORMAL. - Added NULL checks. CORE-10667 --- base/applications/kbswitch/kbswitch.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/base/applications/kbswitch/kbswitch.c b/base/applications/kbswitch/kbswitch.c index aad89ed481a..c931aee98f5 100644 --- a/base/applications/kbswitch/kbswitch.c +++ b/base/applications/kbswitch/kbswitch.c @@ -169,13 +169,31 @@ CreateTrayIcon(LPTSTR szLCID) hdc = CreateCompatibleDC(NULL); hbmColor = CreateCompatibleBitmap(hdc, CX_ICON, CY_ICON); hbmMono = CreateBitmap(CX_ICON, CY_ICON, 1, 1, NULL); + if (!hdc || !hbmColor || !hbmMono) + { + if (hdc) + DeleteDC(hdc); + if (hbmColor) + DeleteObject(hbmColor); + if (hbmMono) + DeleteObject(hbmMono); + return NULL; + } /* Create a font */ ZeroMemory(&lf, sizeof(lf)); lf.lfHeight = -11; lf.lfCharSet = ANSI_CHARSET; + lf.lfWeight = FW_NORMAL; StringCchCopy(lf.lfFaceName, ARRAYSIZE(lf.lfFaceName), _T("Tahoma")); hFont = CreateFontIndirect(&lf); + if (!hFont) + { + DeleteDC(hdc); + DeleteObject(hbmColor); + DeleteObject(hbmMono); + return NULL; + } SetRect(&rect, 0, 0, CX_ICON, CY_ICON);
2 years, 4 months
1
0
0
0
[reactos] 01/01: [NTUSER] Follow-up of 9e7c2ba
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c7ba53e3fbca233059d4d…
commit c7ba53e3fbca233059d4d8e391e6c246bb9323de Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Thu Aug 25 12:07:32 2022 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Thu Aug 25 12:07:32 2022 +0900 [NTUSER] Follow-up of 9e7c2ba CORE-11700 --- win32ss/user/ntuser/ime.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/win32ss/user/ntuser/ime.c b/win32ss/user/ntuser/ime.c index 424c18c44fe..35d8b66bda5 100644 --- a/win32ss/user/ntuser/ime.c +++ b/win32ss/user/ntuser/ime.c @@ -991,18 +991,12 @@ UserGetImeInfoEx( { do { - if (_wcsnicmp(pkl->piiex->wszImeFile, pInfoEx->wszImeFile, + if (pkl->piiex && + _wcsnicmp(pkl->piiex->wszImeFile, pInfoEx->wszImeFile, RTL_NUMBER_OF(pkl->piiex->wszImeFile)) == 0) { - if (pkl->piiex) - { - *pInfoEx = *pkl->piiex; - return TRUE; - } - else - { - ERR("!pkl->piiex at %p\n", pkl->hkl); - } + *pInfoEx = *pkl->piiex; + return TRUE; } pkl = pkl->pklNext; @@ -1010,7 +1004,7 @@ UserGetImeInfoEx( } else { - /* Do nothing */ + ERR("SearchType: %d\n", SearchType); } return FALSE;
2 years, 4 months
1
0
0
0
[reactos] 01/01: [NTUSER] Improve NtUserGetImeInfoEx / NtUserSetImeInfoEx
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9e7c2ba4608f320a04571…
commit 9e7c2ba4608f320a04571c8c545c4b2aa3c6569d Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Thu Aug 25 10:20:42 2022 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Thu Aug 25 10:20:42 2022 +0900 [NTUSER] Improve NtUserGetImeInfoEx / NtUserSetImeInfoEx CORE-11700 --- win32ss/user/ntuser/ime.c | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/win32ss/user/ntuser/ime.c b/win32ss/user/ntuser/ime.c index 1cdabee6638..424c18c44fe 100644 --- a/win32ss/user/ntuser/ime.c +++ b/win32ss/user/ntuser/ime.c @@ -954,11 +954,15 @@ Quit: } // Win: GetImeInfoEx -BOOL FASTCALL UserGetImeInfoEx(LPVOID pUnknown, PIMEINFOEX pInfoEx, IMEINFOEXCLASS SearchType) +BOOL FASTCALL +UserGetImeInfoEx( + _Inout_ PWINSTATION_OBJECT pWinSta, + _Inout_ PIMEINFOEX pInfoEx, + _In_ IMEINFOEXCLASS SearchType) { PKL pkl, pklHead; - if (!gspklBaseLayout) + if (!pWinSta || !gspklBaseLayout) return FALSE; pkl = pklHead = gspklBaseLayout; @@ -971,7 +975,10 @@ BOOL FASTCALL UserGetImeInfoEx(LPVOID pUnknown, PIMEINFOEX pInfoEx, IMEINFOEXCLA if (pInfoEx->hkl == pkl->hkl) { if (!pkl->piiex) + { + ERR("!pkl->piiex at %p\n", pkl->hkl); break; + } *pInfoEx = *pkl->piiex; return TRUE; @@ -984,12 +991,18 @@ BOOL FASTCALL UserGetImeInfoEx(LPVOID pUnknown, PIMEINFOEX pInfoEx, IMEINFOEXCLA { do { - if (pkl->piiex && - _wcsnicmp(pkl->piiex->wszImeFile, pInfoEx->wszImeFile, + if (_wcsnicmp(pkl->piiex->wszImeFile, pInfoEx->wszImeFile, RTL_NUMBER_OF(pkl->piiex->wszImeFile)) == 0) { - *pInfoEx = *pkl->piiex; - return TRUE; + if (pkl->piiex) + { + *pInfoEx = *pkl->piiex; + return TRUE; + } + else + { + ERR("!pkl->piiex at %p\n", pkl->hkl); + } } pkl = pkl->pklNext; @@ -1011,6 +1024,7 @@ NtUserGetImeInfoEx( { IMEINFOEX ImeInfoEx; BOOL ret = FALSE; + PWINSTATION_OBJECT pWinSta; UserEnterShared(); @@ -1031,7 +1045,8 @@ NtUserGetImeInfoEx( } _SEH2_END; - ret = UserGetImeInfoEx(NULL, &ImeInfoEx, SearchType); + pWinSta = IntGetProcessWindowStation(NULL); + ret = UserGetImeInfoEx(pWinSta, &ImeInfoEx, SearchType); if (!ret) goto Quit; @@ -1081,10 +1096,16 @@ Quit: } // Win: SetImeInfoEx -BOOL FASTCALL UserSetImeInfoEx(LPVOID pUnknown, PIMEINFOEX pImeInfoEx) +BOOL FASTCALL +UserSetImeInfoEx( + _Inout_ PWINSTATION_OBJECT pWinSta, + _Inout_ PIMEINFOEX pImeInfoEx) { PKL pklHead, pkl; + if (!pWinSta || !gspklBaseLayout) + return FALSE; + pkl = pklHead = gspklBaseLayout; do @@ -1096,7 +1117,10 @@ BOOL FASTCALL UserSetImeInfoEx(LPVOID pUnknown, PIMEINFOEX pImeInfoEx) } if (!pkl->piiex) + { + ERR("!pkl->piiex at %p\n", pkl->hkl); return FALSE; + } if (!pkl->piiex->fLoadFlag) *pkl->piiex = *pImeInfoEx; @@ -1113,6 +1137,7 @@ NtUserSetImeInfoEx(PIMEINFOEX pImeInfoEx) { BOOL ret = FALSE; IMEINFOEX ImeInfoEx; + PWINSTATION_OBJECT pWinSta; UserEnterExclusive(); @@ -1133,7 +1158,8 @@ NtUserSetImeInfoEx(PIMEINFOEX pImeInfoEx) } _SEH2_END; - ret = UserSetImeInfoEx(NULL, &ImeInfoEx); + pWinSta = IntGetProcessWindowStation(NULL); + ret = UserSetImeInfoEx(pWinSta, &ImeInfoEx); Quit: UserLeave();
2 years, 4 months
1
0
0
0
[reactos] 01/01: [INPUT] Refactor LayoutList_Create (#4626)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4d724b6fbbae3043f0bfd…
commit 4d724b6fbbae3043f0bfd8de56b6115eb2b65e90 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Thu Aug 25 08:38:49 2022 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Thu Aug 25 08:38:49 2022 +0900 [INPUT] Refactor LayoutList_Create (#4626) LayoutList_Create function was too complicated. CORE-11700 --- dll/cpl/input/layout_list.c | 217 ++++++++++++++++++-------------------------- 1 file changed, 87 insertions(+), 130 deletions(-) diff --git a/dll/cpl/input/layout_list.c b/dll/cpl/input/layout_list.c index 3541a81f300..7a06ea77f70 100644 --- a/dll/cpl/input/layout_list.c +++ b/dll/cpl/input/layout_list.c @@ -80,158 +80,115 @@ LayoutList_Destroy(VOID) _LayoutList = NULL; } - -VOID -LayoutList_Create(VOID) +static BOOL +LayoutList_ReadLayout(HKEY hLayoutKey, LPCWSTR szLayoutId, LPCWSTR szSystemDirectory) { - WCHAR szSystemDirectory[MAX_PATH]; - WCHAR szLayoutId[MAX_PATH]; - DWORD dwIndex = 0; - DWORD dwSize; - HKEY hKey; - - if (!GetSystemDirectoryW(szSystemDirectory, ARRAYSIZE(szSystemDirectory))) + WCHAR szBuffer[MAX_PATH], szFilePath[MAX_PATH], szDllPath[MAX_PATH]; + INT iIndex, iLength = 0; + DWORD dwSize, dwSpecialId, dwLayoutId = DWORDfromString(szLayoutId); + HINSTANCE hDllInst; + + dwSize = sizeof(szBuffer); + if (RegQueryValueExW(hLayoutKey, L"Layout File", NULL, NULL, + (LPBYTE)szBuffer, &dwSize) != ERROR_SUCCESS) { - return; + return FALSE; /* No "Layout File" value */ } - if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, - L"SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts", - 0, - KEY_ENUMERATE_SUB_KEYS, - &hKey) != ERROR_SUCCESS) + /* Build the "Layout File" full path and check existence */ + StringCchPrintfW(szFilePath, ARRAYSIZE(szFilePath), L"%s\\%s", szSystemDirectory, szBuffer); + if (GetFileAttributesW(szFilePath) == INVALID_FILE_ATTRIBUTES) + return FALSE; /* No layout file found */ + + /* Get the special ID */ + dwSpecialId = 0; + dwSize = sizeof(szBuffer); + if (RegQueryValueExW(hLayoutKey, L"Layout Id", NULL, NULL, + (LPBYTE)szBuffer, &dwSize) == ERROR_SUCCESS) { - return; + dwSpecialId = DWORDfromString(szBuffer); } - dwSize = ARRAYSIZE(szLayoutId); - - while (RegEnumKeyExW(hKey, dwIndex, szLayoutId, &dwSize, - NULL, NULL, NULL, NULL) == ERROR_SUCCESS) + /* If there is a valid "Layout Display Name", then use it as the entry name */ + dwSize = sizeof(szBuffer); + if (RegQueryValueExW(hLayoutKey, L"Layout Display Name", NULL, NULL, + (LPBYTE)szBuffer, &dwSize) == ERROR_SUCCESS && szBuffer[0] == L'@') { - HKEY hLayoutKey; + /* FIXME: Use shlwapi!SHLoadRegUIStringW instead if it had fully implemented */ - if (RegOpenKeyExW(hKey, - szLayoutId, - 0, - KEY_QUERY_VALUE, - &hLayoutKey) == ERROR_SUCCESS) - { - WCHAR szBuffer[MAX_PATH]; + /* Move to the position after the character "@" */ + WCHAR *pBuffer = szBuffer + 1; - dwSize = sizeof(szBuffer); + /* Get a pointer to the beginning ",-" */ + WCHAR *pIndex = wcsstr(pBuffer, L",-"); - if (RegQueryValueExW(hLayoutKey, - L"Layout File", - NULL, NULL, - (LPBYTE)szBuffer, &dwSize) == ERROR_SUCCESS) - { - WCHAR szFilePath[MAX_PATH]; + if (pIndex) + { + /* Convert the number in the string after the ",-" */ + iIndex = _wtoi(pIndex + 2); - StringCchPrintfW(szFilePath, ARRAYSIZE(szFilePath), - L"%s\\%s", szSystemDirectory, szBuffer); + *pIndex = 0; /* Cut the string */ - if (GetFileAttributesW(szFilePath) != INVALID_FILE_ATTRIBUTES) + if (ExpandEnvironmentStringsW(pBuffer, szDllPath, ARRAYSIZE(szDllPath)) != 0) + { + hDllInst = LoadLibraryW(szDllPath); + if (hDllInst) { - DWORD dwSpecialId = 0; - - dwSize = sizeof(szBuffer); - - if (RegQueryValueExW(hLayoutKey, - L"Layout Id", - NULL, NULL, - (LPBYTE)szBuffer, &dwSize) == ERROR_SUCCESS) - { - dwSpecialId = DWORDfromString(szBuffer); - } - - dwSize = sizeof(szBuffer); + iLength = LoadStringW(hDllInst, iIndex, szBuffer, ARRAYSIZE(szBuffer)); + FreeLibrary(hDllInst); - if (RegQueryValueExW(hLayoutKey, - L"Layout Display Name", - NULL, NULL, - (LPBYTE)szBuffer, &dwSize) == ERROR_SUCCESS && - szBuffer[0] == L'@') + if (iLength > 0) { - WCHAR *pBuffer; - WCHAR *pIndex; - - /* Move to the position after the character "@" */ - pBuffer = szBuffer + 1; - - /* Get a pointer to the beginning ",-" */ - pIndex = wcsstr(pBuffer, L",-"); - - if (pIndex != NULL) - { - WCHAR szPath[MAX_PATH]; - INT iIndex; - - /* Convert the number in the string after the ",-" */ - iIndex = _wtoi(pIndex + 2); - - pIndex[0] = 0; - - if (ExpandEnvironmentStringsW(pBuffer, szPath, ARRAYSIZE(szPath)) != 0) - { - HANDLE hHandle; - - hHandle = LoadLibraryW(szPath); - if (hHandle != NULL) - { - INT iLength = LoadStringW(hHandle, iIndex, szBuffer, ARRAYSIZE(szBuffer)); - - FreeLibrary(hHandle); - - if (iLength != 0) - { - DWORD dwLayoutId = DWORDfromString(szLayoutId); - - LayoutList_AppendNode(dwLayoutId, dwSpecialId, szBuffer); - } - else - { - goto NotTranslated; - } - } - else - { - goto NotTranslated; - } - } - else - { - goto NotTranslated; - } - } - else - { - goto NotTranslated; - } - } - else - { -NotTranslated: - dwSize = sizeof(szBuffer); - - if (RegQueryValueExW(hLayoutKey, - L"Layout Text", - NULL, NULL, - (LPBYTE)szBuffer, &dwSize) == ERROR_SUCCESS) - { - DWORD dwLayoutId = DWORDfromString(szLayoutId); - - LayoutList_AppendNode(dwLayoutId, dwSpecialId, szBuffer); - } + LayoutList_AppendNode(dwLayoutId, dwSpecialId, szBuffer); + return TRUE; } } } - - RegCloseKey(hLayoutKey); } + } + /* Otherwise, use "Layout Text" value as the entry name */ + dwSize = sizeof(szBuffer); + if (RegQueryValueExW(hLayoutKey, L"Layout Text", NULL, NULL, + (LPBYTE)szBuffer, &dwSize) == ERROR_SUCCESS) + { + LayoutList_AppendNode(dwLayoutId, dwSpecialId, szBuffer); + return TRUE; + } + + return FALSE; +} + +VOID +LayoutList_Create(VOID) +{ + WCHAR szSystemDirectory[MAX_PATH], szLayoutId[MAX_PATH]; + DWORD dwSize, dwIndex; + HKEY hKey, hLayoutKey; + + if (!GetSystemDirectoryW(szSystemDirectory, ARRAYSIZE(szSystemDirectory))) + return; + + if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts", + 0, KEY_ENUMERATE_SUB_KEYS, &hKey) != ERROR_SUCCESS) + { + return; + } + + for (dwIndex = 0; ; ++dwIndex) + { dwSize = ARRAYSIZE(szLayoutId); - ++dwIndex; + if (RegEnumKeyExW(hKey, dwIndex, szLayoutId, &dwSize, NULL, NULL, + NULL, NULL) != ERROR_SUCCESS) + { + break; + } + + if (RegOpenKeyExW(hKey, szLayoutId, 0, KEY_QUERY_VALUE, &hLayoutKey) == ERROR_SUCCESS) + { + LayoutList_ReadLayout(hLayoutKey, szLayoutId, szSystemDirectory); + RegCloseKey(hLayoutKey); + } } RegCloseKey(hKey);
2 years, 4 months
1
0
0
0
[reactos] 01/01: [INPUT] Use MAKEINTRESOURCE instead of LoadString (#4628)
by Thamatip Chitpong
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0ed302ef656ed39c932e0…
commit 0ed302ef656ed39c932e084508ffa506b47c463b Author: Thamatip Chitpong <tangaming123456(a)outlook.com> AuthorDate: Wed Aug 24 13:17:14 2022 +0700 Commit: GitHub <noreply(a)github.com> CommitDate: Wed Aug 24 15:17:14 2022 +0900 [INPUT] Use MAKEINTRESOURCE instead of LoadString (#4628) --- dll/cpl/input/input.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/dll/cpl/input/input.c b/dll/cpl/input/input.c index 1896eb8552a..f169e97c151 100644 --- a/dll/cpl/input/input.c +++ b/dll/cpl/input/input.c @@ -58,9 +58,6 @@ SystemApplet(HWND hwnd, UINT uMsg, LPARAM lParam1, LPARAM lParam2) { PROPSHEETPAGEW page[2]; PROPSHEETHEADERW header; - WCHAR szCaption[MAX_STR_LEN]; - - LoadStringW(hApplet, IDS_CPLSYSTEMNAME, szCaption, ARRAYSIZE(szCaption)); ZeroMemory(&header, sizeof(header)); @@ -69,7 +66,7 @@ SystemApplet(HWND hwnd, UINT uMsg, LPARAM lParam1, LPARAM lParam2) header.hwndParent = hwnd; header.hInstance = hApplet; header.pszIcon = MAKEINTRESOURCEW(IDI_KEY_SHORT_ICO); - header.pszCaption = szCaption; + header.pszCaption = MAKEINTRESOURCEW(IDS_CPLSYSTEMNAME); header.nPages = ARRAYSIZE(page); header.nStartPage = 0; header.ppsp = page;
2 years, 4 months
1
0
0
0
[reactos] 01/01: [KBSWITCH] Total refactoring
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d4ed449ca24c60462c241…
commit d4ed449ca24c60462c2413310c3435203b0ed9a8 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Wed Aug 24 13:26:54 2022 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Wed Aug 24 13:26:54 2022 +0900 [KBSWITCH] Total refactoring --- base/applications/kbswitch/kbswitch.c | 374 +++++++++++++++++----------------- 1 file changed, 184 insertions(+), 190 deletions(-) diff --git a/base/applications/kbswitch/kbswitch.c b/base/applications/kbswitch/kbswitch.c index 6a5680a4212..aad89ed481a 100644 --- a/base/applications/kbswitch/kbswitch.c +++ b/base/applications/kbswitch/kbswitch.c @@ -13,22 +13,136 @@ #define CX_ICON 16 #define CY_ICON 16 -PKBSWITCHSETHOOKS KbSwitchSetHooks = NULL; +PKBSWITCHSETHOOKS KbSwitchSetHooks = NULL; PKBSWITCHDELETEHOOKS KbSwitchDeleteHooks = NULL; UINT ShellHookMessage = 0; DWORD dwAltShiftHotKeyId = 0, dwShiftAltHotKeyId = 0; +HINSTANCE hInst; +HANDLE hProcessHeap; +HMODULE g_hHookDLL = NULL; +ULONG ulCurrentLayoutNum = 1; +HICON g_hTrayIcon = NULL; + static BOOL -GetLayoutID(LPTSTR szLayoutNum, LPTSTR szLCID, SIZE_T LCIDLength); +GetLayoutID(LPCTSTR szLayoutNum, LPTSTR szLCID, SIZE_T LCIDLength) +{ + DWORD dwBufLen, dwRes; + HKEY hKey; + TCHAR szTempLCID[CCH_LAYOUT_ID + 1]; + + /* Get the Layout ID */ + if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Preload"), 0, KEY_QUERY_VALUE, + &hKey) == ERROR_SUCCESS) + { + dwBufLen = sizeof(szTempLCID); + dwRes = RegQueryValueEx(hKey, szLayoutNum, NULL, NULL, (LPBYTE)szTempLCID, &dwBufLen); + if (dwRes != ERROR_SUCCESS) + { + RegCloseKey(hKey); + return FALSE; + } + + RegCloseKey(hKey); + } + + /* Look for a substitute of this layout */ + if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Substitutes"), 0, + KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + { + dwBufLen = sizeof(szTempLCID); + if (RegQueryValueEx(hKey, szTempLCID, NULL, NULL, (LPBYTE)szLCID, &dwBufLen) != ERROR_SUCCESS) + { + /* No substitute found, then use the old LCID */ + StringCchCopy(szLCID, LCIDLength, szTempLCID); + } + + RegCloseKey(hKey); + } + else + { + /* Substitutes key couldn't be opened, so use the old LCID */ + StringCchCopy(szLCID, LCIDLength, szTempLCID); + } + + return TRUE; +} static BOOL -GetLayoutName(LPTSTR szLayoutNum, LPTSTR szName, SIZE_T NameLength); +GetLayoutName(LPCTSTR szLayoutNum, LPTSTR szName, SIZE_T NameLength) +{ + HKEY hKey; + DWORD dwBufLen; + TCHAR szBuf[MAX_PATH], szDispName[MAX_PATH], szIndex[MAX_PATH], szPath[MAX_PATH]; + TCHAR szLCID[CCH_LAYOUT_ID + 1]; + HANDLE hLib; + UINT i, j, k; -HINSTANCE hInst; -HANDLE hProcessHeap; -HMODULE hDllLib; -ULONG ulCurrentLayoutNum = 1; -HICON g_hNotifyIcon = NULL; + if (!GetLayoutID(szLayoutNum, szLCID, ARRAYSIZE(szLCID))) + return FALSE; + + StringCchPrintf(szBuf, ARRAYSIZE(szBuf), + _T("SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\%s"), szLCID); + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, szBuf, 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS) + { + return FALSE; + } + + /* Use "Layout Display Name" value as an entry name if possible */ + dwBufLen = sizeof(szDispName); + if (RegQueryValueEx(hKey, _T("Layout Display Name"), NULL, NULL, + (LPBYTE)szDispName, &dwBufLen) == ERROR_SUCCESS) + { + /* FIXME: Use shlwapi!SHLoadRegUIStringW instead if it was implemented */ + if (szDispName[0] == '@') + { + size_t len = _tcslen(szDispName); + + for (i = 0; i < len; i++) + { + if ((szDispName[i] == ',') && (szDispName[i + 1] == '-')) + { + for (j = i + 2, k = 0; j < _tcslen(szDispName)+1; j++, k++) + { + szIndex[k] = szDispName[j]; + } + szDispName[i - 1] = '\0'; + break; + } + else szDispName[i] = szDispName[i + 1]; + } + + if (ExpandEnvironmentStrings(szDispName, szPath, ARRAYSIZE(szPath))) + { + hLib = LoadLibrary(szPath); + if (hLib) + { + if (LoadString(hLib, _ttoi(szIndex), szPath, ARRAYSIZE(szPath))) + { + StringCchCopy(szName, NameLength, szPath); + RegCloseKey(hKey); + FreeLibrary(hLib); + return TRUE; + } + FreeLibrary(hLib); + } + } + } + } + + /* Otherwise, use "Layout Text" value as an entry name */ + dwBufLen = NameLength * sizeof(TCHAR); + if (RegQueryValueEx(hKey, _T("Layout Text"), NULL, NULL, + (LPBYTE)szName, &dwBufLen) == ERROR_SUCCESS) + { + RegCloseKey(hKey); + return TRUE; + } + + RegCloseKey(hKey); + return FALSE; +} static HICON CreateTrayIcon(LPTSTR szLCID) @@ -38,9 +152,9 @@ CreateTrayIcon(LPTSTR szLCID) HDC hdc; HBITMAP hbmColor, hbmMono, hBmpOld; RECT rect; - HFONT hFontOld, hFont = NULL; + HFONT hFontOld, hFont; ICONINFO IconInfo; - HICON hIcon = NULL; + HICON hIcon; LOGFONT lf; /* Getting "EN", "FR", etc. from English, French, ... */ @@ -100,8 +214,7 @@ static VOID AddTrayIcon(HWND hwnd) { NOTIFYICONDATA tnid = { sizeof(tnid), hwnd, 1, NIF_ICON | NIF_MESSAGE | NIF_TIP }; - TCHAR szLCID[CCH_LAYOUT_ID + 1]; - TCHAR szName[MAX_PATH]; + TCHAR szLCID[CCH_LAYOUT_ID + 1], szName[MAX_PATH]; GetLayoutID(_T("1"), szLCID, ARRAYSIZE(szLCID)); GetLayoutName(_T("1"), szName, ARRAYSIZE(szName)); @@ -112,9 +225,9 @@ AddTrayIcon(HWND hwnd) Shell_NotifyIcon(NIM_ADD, &tnid); - if (g_hNotifyIcon) - DestroyIcon(g_hNotifyIcon); - g_hNotifyIcon = tnid.hIcon; + if (g_hTrayIcon) + DestroyIcon(g_hTrayIcon); + g_hTrayIcon = tnid.hIcon; } static VOID @@ -123,10 +236,10 @@ DeleteTrayIcon(HWND hwnd) NOTIFYICONDATA tnid = { sizeof(tnid), hwnd, 1 }; Shell_NotifyIcon(NIM_DELETE, &tnid); - if (g_hNotifyIcon) + if (g_hTrayIcon) { - DestroyIcon(g_hNotifyIcon); - g_hNotifyIcon = NULL; + DestroyIcon(g_hTrayIcon); + g_hTrayIcon = NULL; } } @@ -140,138 +253,18 @@ UpdateTrayIcon(HWND hwnd, LPTSTR szLCID, LPTSTR szName) Shell_NotifyIcon(NIM_MODIFY, &tnid); - if (g_hNotifyIcon) - DestroyIcon(g_hNotifyIcon); - g_hNotifyIcon = tnid.hIcon; + if (g_hTrayIcon) + DestroyIcon(g_hTrayIcon); + g_hTrayIcon = tnid.hIcon; } -static BOOL -GetLayoutID(LPTSTR szLayoutNum, LPTSTR szLCID, SIZE_T LCIDLength) -{ - DWORD dwBufLen; - DWORD dwRes; - HKEY hKey; - TCHAR szTempLCID[CCH_LAYOUT_ID + 1]; - - // Get the Layout ID - if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Preload"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) - { - dwBufLen = sizeof(szTempLCID); - dwRes = RegQueryValueEx(hKey, szLayoutNum, NULL, NULL, (LPBYTE)szTempLCID, &dwBufLen); - - if (dwRes != ERROR_SUCCESS) - { - RegCloseKey(hKey); - return FALSE; - } - - RegCloseKey(hKey); - } - - // Look for a substitute of this layout - if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Substitutes"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) - { - dwBufLen = sizeof(szTempLCID); - - if (RegQueryValueEx(hKey, szTempLCID, NULL, NULL, (LPBYTE)szLCID, &dwBufLen) != ERROR_SUCCESS) - { - // No substitute found, then use the old LCID - StringCchCopy(szLCID, LCIDLength, szTempLCID); - } - - RegCloseKey(hKey); - } - else - { - // Substitutes key couldn't be opened, so use the old LCID - StringCchCopy(szLCID, LCIDLength, szTempLCID); - } - - return TRUE; -} - -VOID +static VOID GetLayoutIDByHkl(HKL hKl, LPTSTR szLayoutID, SIZE_T LayoutIDLength) { - /* - FIXME!!! This way of getting layout ID incorrect! - This will not work correctly for 0001040a, 00010410, etc - */ - StringCchPrintf(szLayoutID, LayoutIDLength, _T("%08x"), LOWORD(hKl)); + StringCchPrintf(szLayoutID, LayoutIDLength, _T("%08lx"), (DWORD)(DWORD_PTR)(hKl)); } -static BOOL -GetLayoutName(LPTSTR szLayoutNum, LPTSTR szName, SIZE_T NameLength) -{ - HKEY hKey; - DWORD dwBufLen; - TCHAR szBuf[MAX_PATH], szDispName[MAX_PATH], szIndex[MAX_PATH], szPath[MAX_PATH]; - TCHAR szLCID[CCH_LAYOUT_ID + 1]; - HANDLE hLib; - UINT i, j, k; - - if (!GetLayoutID(szLayoutNum, szLCID, ARRAYSIZE(szLCID))) - return FALSE; - - StringCchPrintf(szBuf, ARRAYSIZE(szBuf), _T("SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\%s"), szLCID); - - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCTSTR)szBuf, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) - { - dwBufLen = sizeof(szDispName); - - if (RegQueryValueEx(hKey, _T("Layout Display Name"), NULL, NULL, (LPBYTE)szDispName, &dwBufLen) == ERROR_SUCCESS) - { - if (szDispName[0] == '@') - { - size_t len = _tcslen(szDispName); - - for (i = 0; i < len; i++) - { - if ((szDispName[i] == ',') && (szDispName[i + 1] == '-')) - { - for (j = i + 2, k = 0; j < _tcslen(szDispName)+1; j++, k++) - { - szIndex[k] = szDispName[j]; - } - szDispName[i - 1] = '\0'; - break; - } - else szDispName[i] = szDispName[i + 1]; - } - - if (ExpandEnvironmentStrings(szDispName, szPath, ARRAYSIZE(szPath))) - { - hLib = LoadLibrary(szPath); - if (hLib) - { - if (LoadString(hLib, _ttoi(szIndex), szPath, ARRAYSIZE(szPath)) != 0) - { - StringCchCopy(szName, NameLength, szPath); - RegCloseKey(hKey); - FreeLibrary(hLib); - return TRUE; - } - FreeLibrary(hLib); - } - } - } - } - - dwBufLen = NameLength * sizeof(TCHAR); - - if (RegQueryValueEx(hKey, _T("Layout Text"), NULL, NULL, (LPBYTE)szName, &dwBufLen) == ERROR_SUCCESS) - { - RegCloseKey(hKey); - return TRUE; - } - - RegCloseKey(hKey); - } - - return FALSE; -} - -BOOL CALLBACK +static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) { PostMessage(hwnd, WM_INPUTLANGCHANGEREQUEST, 0, lParam); @@ -282,18 +275,22 @@ static VOID ActivateLayout(HWND hwnd, ULONG uLayoutNum) { HKL hKl; - TCHAR szLayoutNum[CCH_ULONG_DEC + 1]; - TCHAR szLCID[CCH_LAYOUT_ID + 1]; - TCHAR szLangName[MAX_PATH]; + TCHAR szLayoutNum[CCH_ULONG_DEC + 1], szLCID[CCH_LAYOUT_ID + 1], szLangName[MAX_PATH]; + LANGID LangID; + + if (uLayoutNum == (ULONG)-1 || uLayoutNum > 0xFF) /* Invalid */ + return; _ultot(uLayoutNum, szLayoutNum, 10); GetLayoutID(szLayoutNum, szLCID, ARRAYSIZE(szLCID)); + LangID = (LANGID)_tcstoul(szLCID, NULL, 16); - // Switch to the new keyboard layout - GetLocaleInfo((LANGID)_tcstoul(szLCID, NULL, 16), LOCALE_SLANGUAGE, (LPTSTR)szLangName, ARRAYSIZE(szLangName)); + /* Switch to the new keyboard layout */ + GetLocaleInfo(LangID, LOCALE_SLANGUAGE, szLangName, ARRAYSIZE(szLangName)); UpdateTrayIcon(hwnd, szLCID, szLangName); hKl = LoadKeyboardLayout(szLCID, KLF_ACTIVATE); + /* Post WM_INPUTLANGCHANGEREQUEST to every top-level window */ EnumWindows(EnumWindowsProc, (LPARAM) hKl); ulCurrentLayoutNum = uLayoutNum; @@ -302,22 +299,23 @@ ActivateLayout(HWND hwnd, ULONG uLayoutNum) static HMENU BuildLeftPopupMenu(VOID) { - HMENU hMenu; + HMENU hMenu = CreatePopupMenu(); HKEY hKey; DWORD dwIndex, dwSize; - TCHAR szLayoutNum[CCH_ULONG_DEC + 1]; - TCHAR szName[MAX_PATH]; - - hMenu = CreatePopupMenu(); + TCHAR szLayoutNum[CCH_ULONG_DEC + 1], szName[MAX_PATH]; - // Add the keyboard layouts to the popup menu - if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Preload"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + /* Add the keyboard layouts to the popup menu */ + if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Preload"), 0, + KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { for (dwIndex = 0; ; dwIndex++) { dwSize = sizeof(szLayoutNum); - if (RegEnumValue(hKey, dwIndex, szLayoutNum, &dwSize, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) + if (RegEnumValue(hKey, dwIndex, szLayoutNum, &dwSize, NULL, NULL, + NULL, NULL) != ERROR_SUCCESS) + { break; + } if (!GetLayoutName(szLayoutNum, szName, ARRAYSIZE(szName))) break; @@ -336,14 +334,14 @@ BuildLeftPopupMenu(VOID) BOOL SetHooks(VOID) { - hDllLib = LoadLibrary(_T("kbsdll.dll")); - if (!hDllLib) + g_hHookDLL = LoadLibrary(_T("kbsdll.dll")); + if (!g_hHookDLL) { return FALSE; } - KbSwitchSetHooks = (PKBSWITCHSETHOOKS) GetProcAddress(hDllLib, "KbSwitchSetHooks"); - KbSwitchDeleteHooks = (PKBSWITCHDELETEHOOKS) GetProcAddress(hDllLib, "KbSwitchDeleteHooks"); + KbSwitchSetHooks = (PKBSWITCHSETHOOKS) GetProcAddress(g_hHookDLL, "KbSwitchSetHooks"); + KbSwitchDeleteHooks = (PKBSWITCHDELETEHOOKS) GetProcAddress(g_hHookDLL, "KbSwitchDeleteHooks"); if (KbSwitchSetHooks == NULL || KbSwitchDeleteHooks == NULL) { @@ -357,7 +355,7 @@ VOID DeleteHooks(VOID) { if (KbSwitchDeleteHooks) KbSwitchDeleteHooks(); - if (hDllLib) FreeLibrary(hDllLib); + if (g_hHookDLL) FreeLibrary(g_hHookDLL); } ULONG @@ -378,14 +376,10 @@ GetNextLayout(VOID) { return (Ret + 1); } - else - { - _ultot(Ret - 1, szLayoutNum, 10); - if (GetLayoutID(szLayoutNum, szLayoutID, ARRAYSIZE(szLayoutID))) - return (Ret - 1); - else - return -1; - } + + _ultot(Ret - 1, szLayoutNum, 10); + if (GetLayoutID(szLayoutNum, szLayoutID, ARRAYSIZE(szLayoutID))) + return (Ret - 1); return -1; } @@ -393,10 +387,12 @@ GetNextLayout(VOID) LRESULT UpdateLanguageDisplay(HWND hwnd, HKL hKl) { - static TCHAR szLCID[MAX_PATH], szLangName[MAX_PATH]; + TCHAR szLCID[MAX_PATH], szLangName[MAX_PATH]; + LANGID LangID; GetLayoutIDByHkl(hKl, szLCID, ARRAYSIZE(szLCID)); - GetLocaleInfo((LANGID)_tcstoul(szLCID, NULL, 16), LOCALE_SLANGUAGE, (LPTSTR)szLangName, ARRAYSIZE(szLangName)); + LangID = (LANGID)_tcstoul(szLCID, NULL, 16); + GetLocaleInfo(LangID, LOCALE_SLANGUAGE, szLangName, ARRAYSIZE(szLangName)); UpdateTrayIcon(hwnd, szLCID, szLangName); return 0; @@ -405,7 +401,9 @@ UpdateLanguageDisplay(HWND hwnd, HKL hKl) LRESULT UpdateLanguageDisplayCurrent(HWND hwnd, WPARAM wParam) { - return UpdateLanguageDisplay(hwnd, GetKeyboardLayout(GetWindowThreadProcessId((HWND)wParam, 0))); + DWORD dwThreadID = GetWindowThreadProcessId((HWND)wParam, 0); + HKL hKL = GetKeyboardLayout(dwThreadID); + return UpdateLanguageDisplay(hwnd, hKL); } VOID DoRegisterAltShiftHotKeys(HWND hwnd) @@ -430,8 +428,7 @@ VOID DoUnregisterAltShiftHotKeys(HWND hwnd) LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { - static HMENU s_hMenu; - static HMENU s_hRightPopupMenu; + static HMENU s_hMenu = NULL, s_hRightPopupMenu = NULL; static UINT s_uTaskbarRestart; POINT pt; HMENU hLeftPopupMenu; @@ -440,11 +437,10 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { case WM_CREATE: { - SetHooks(); - AddTrayIcon(hwnd); + if (!SetHooks()) + return -1; - s_hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_POPUP)); - s_hRightPopupMenu = GetSubMenu(s_hMenu, 0); + AddTrayIcon(hwnd); ActivateLayout(hwnd, ulCurrentLayoutNum); s_uTaskbarRestart = RegisterWindowMessage(TEXT("TaskbarCreated")); @@ -498,6 +494,11 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) } else { + if (!s_hRightPopupMenu) + { + s_hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_POPUP)); + s_hRightPopupMenu = GetSubMenu(s_hMenu, 0); + } TrackPopupMenu(s_hRightPopupMenu, 0, pt.x, pt.y, 0, hwnd, NULL); } @@ -583,7 +584,7 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) INT WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT nCmdShow) { - WNDCLASS WndClass = {0}; + WNDCLASS WndClass; MSG msg; HANDLE hMutex; HWND hwnd; @@ -610,17 +611,11 @@ _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT nCmdSh hInst = hInstance; hProcessHeap = GetProcessHeap(); - WndClass.style = 0; + ZeroMemory(&WndClass, sizeof(WndClass)); WndClass.lpfnWndProc = WndProc; - WndClass.cbClsExtra = 0; - WndClass.cbWndExtra = 0; WndClass.hInstance = hInstance; - WndClass.hIcon = NULL; - WndClass.hCursor = NULL; - WndClass.hbrBackground = NULL; - WndClass.lpszMenuName = NULL; + WndClass.hCursor = LoadCursor(NULL, IDC_ARROW); WndClass.lpszClassName = szKbSwitcherName; - if (!RegisterClass(&WndClass)) { CloseHandle(hMutex); @@ -631,13 +626,12 @@ _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT nCmdSh ShellHookMessage = RegisterWindowMessage(L"SHELLHOOK"); RegisterShellHookWindow(hwnd); - while(GetMessage(&msg,NULL,0,0)) + while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } CloseHandle(hMutex); - return 0; }
2 years, 4 months
1
0
0
0
[reactos] 01/01: [KBSWITCH] Fix notification icon handle leak
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=82db0523e4c1e6c53fbe8…
commit 82db0523e4c1e6c53fbe8c8eadc813b429dce3b5 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Wed Aug 24 12:18:59 2022 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Wed Aug 24 12:18:59 2022 +0900 [KBSWITCH] Fix notification icon handle leak --- base/applications/kbswitch/kbswitch.c | 44 ++++++++++++++++------------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/base/applications/kbswitch/kbswitch.c b/base/applications/kbswitch/kbswitch.c index 6f4413f8f03..6a5680a4212 100644 --- a/base/applications/kbswitch/kbswitch.c +++ b/base/applications/kbswitch/kbswitch.c @@ -28,6 +28,7 @@ HINSTANCE hInst; HANDLE hProcessHeap; HMODULE hDllLib; ULONG ulCurrentLayoutNum = 1; +HICON g_hNotifyIcon = NULL; static HICON CreateTrayIcon(LPTSTR szLCID) @@ -98,55 +99,50 @@ CreateTrayIcon(LPTSTR szLCID) static VOID AddTrayIcon(HWND hwnd) { - NOTIFYICONDATA tnid; + NOTIFYICONDATA tnid = { sizeof(tnid), hwnd, 1, NIF_ICON | NIF_MESSAGE | NIF_TIP }; TCHAR szLCID[CCH_LAYOUT_ID + 1]; TCHAR szName[MAX_PATH]; GetLayoutID(_T("1"), szLCID, ARRAYSIZE(szLCID)); GetLayoutName(_T("1"), szName, ARRAYSIZE(szName)); - memset(&tnid, 0, sizeof(tnid)); - tnid.cbSize = sizeof(NOTIFYICONDATA); - tnid.hWnd = hwnd; - tnid.uID = 1; - tnid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; tnid.uCallbackMessage = WM_NOTIFYICONMSG; tnid.hIcon = CreateTrayIcon(szLCID); - StringCchCopy(tnid.szTip, ARRAYSIZE(tnid.szTip), szName); Shell_NotifyIcon(NIM_ADD, &tnid); + + if (g_hNotifyIcon) + DestroyIcon(g_hNotifyIcon); + g_hNotifyIcon = tnid.hIcon; } static VOID -DelTrayIcon(HWND hwnd) +DeleteTrayIcon(HWND hwnd) { - NOTIFYICONDATA tnid; - - memset(&tnid, 0, sizeof(tnid)); - tnid.cbSize = sizeof(NOTIFYICONDATA); - tnid.hWnd = hwnd; - tnid.uID = 1; - + NOTIFYICONDATA tnid = { sizeof(tnid), hwnd, 1 }; Shell_NotifyIcon(NIM_DELETE, &tnid); + + if (g_hNotifyIcon) + { + DestroyIcon(g_hNotifyIcon); + g_hNotifyIcon = NULL; + } } static VOID UpdateTrayIcon(HWND hwnd, LPTSTR szLCID, LPTSTR szName) { - NOTIFYICONDATA tnid; - - memset(&tnid, 0, sizeof(tnid)); - tnid.cbSize = sizeof(NOTIFYICONDATA); - tnid.hWnd = hwnd; - tnid.uID = 1; - tnid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; + NOTIFYICONDATA tnid = { sizeof(tnid), hwnd, 1, NIF_ICON | NIF_MESSAGE | NIF_TIP }; tnid.uCallbackMessage = WM_NOTIFYICONMSG; tnid.hIcon = CreateTrayIcon(szLCID); - StringCchCopy(tnid.szTip, ARRAYSIZE(tnid.szTip), szName); Shell_NotifyIcon(NIM_MODIFY, &tnid); + + if (g_hNotifyIcon) + DestroyIcon(g_hNotifyIcon); + g_hNotifyIcon = tnid.hIcon; } static BOOL @@ -560,7 +556,7 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) DoUnregisterAltShiftHotKeys(hwnd); DeleteHooks(); DestroyMenu(s_hMenu); - DelTrayIcon(hwnd); + DeleteTrayIcon(hwnd); PostQuitMessage(0); break; }
2 years, 4 months
1
0
0
0
[reactos] 01/01: [KBSWITCH] Refactor WndProc
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=eca08cfe98f192c2072ab…
commit eca08cfe98f192c2072ab74d07a15af0bc8f2870 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Wed Aug 24 11:57:29 2022 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Wed Aug 24 11:57:29 2022 +0900 [KBSWITCH] Refactor WndProc --- base/applications/kbswitch/kbswitch.c | 54 +++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/base/applications/kbswitch/kbswitch.c b/base/applications/kbswitch/kbswitch.c index 09f4829eb19..6f4413f8f03 100644 --- a/base/applications/kbswitch/kbswitch.c +++ b/base/applications/kbswitch/kbswitch.c @@ -437,6 +437,8 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) static HMENU s_hMenu; static HMENU s_hRightPopupMenu; static UINT s_uTaskbarRestart; + POINT pt; + HMENU hLeftPopupMenu; switch (Message) { @@ -452,7 +454,7 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) s_uTaskbarRestart = RegisterWindowMessage(TEXT("TaskbarCreated")); DoRegisterAltShiftHotKeys(hwnd); - return 0; + break; } case WM_LANG_CHANGED: @@ -473,7 +475,7 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) ULONG uNextNum = GetNextLayout(); if (ulCurrentLayoutNum != uNextNum) ActivateLayout(hwnd, uNextNum); - return 0; + break; } case WM_WINDOW_ACTIVATE: @@ -482,19 +484,17 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) } case WM_NOTIFYICONMSG: + { switch (lParam) { case WM_RBUTTONUP: case WM_LBUTTONUP: { - POINT pt; - GetCursorPos(&pt); SetForegroundWindow(hwnd); if (lParam == WM_LBUTTONUP) { - HMENU hLeftPopupMenu; /* Rebuild the left popup menu on every click to take care of keyboard layout changes */ hLeftPopupMenu = BuildLeftPopupMenu(); TrackPopupMenu(hLeftPopupMenu, 0, pt.x, pt.y, 0, hwnd, NULL); @@ -506,38 +506,39 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) } PostMessage(hwnd, WM_NULL, 0, 0); - - return 0; + break; } } break; + } case WM_COMMAND: switch (LOWORD(wParam)) { case ID_EXIT: + { SendMessage(hwnd, WM_CLOSE, 0, 0); - return 0; + break; + } case ID_PREFERENCES: { - SHELLEXECUTEINFO shInputDll = {0}; - - shInputDll.cbSize = sizeof(shInputDll); + SHELLEXECUTEINFO shInputDll = { sizeof(shInputDll) }; shInputDll.hwnd = hwnd; shInputDll.lpVerb = _T("open"); shInputDll.lpFile = _T("rundll32.exe"); shInputDll.lpParameters = _T("shell32.dll,Control_RunDLL input.dll"); - if (!ShellExecuteEx(&shInputDll)) MessageBox(hwnd, _T("Can't start input.dll"), NULL, MB_OK | MB_ICONERROR); - return 0; + break; } default: + { ActivateLayout(hwnd, LOWORD(wParam)); - return 0; + break; + } } break; @@ -561,23 +562,26 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) DestroyMenu(s_hMenu); DelTrayIcon(hwnd); PostQuitMessage(0); - - return 0; + break; } default: - if(Message == s_uTaskbarRestart) + { + if (Message == s_uTaskbarRestart) + { AddTrayIcon(hwnd); - break; - } - - if (Message == ShellHookMessage && wParam == HSHELL_LANGUAGE) - { - PostMessage(hwnd, WM_LANG_CHANGED, wParam, lParam); - return 0; + break; + } + else if (Message == ShellHookMessage && wParam == HSHELL_LANGUAGE) + { + PostMessage(hwnd, WM_LANG_CHANGED, wParam, lParam); + break; + } + return DefWindowProc(hwnd, Message, wParam, lParam); + } } - return DefWindowProc(hwnd, Message, wParam, lParam); + return 0; } INT WINAPI
2 years, 4 months
1
0
0
0
[reactos] 01/01: [USER32] Get/SetWindowLongPtr about PIMEUI (#4625)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7151c30079b741c750dfa…
commit 7151c30079b741c750dfad23f24eec97e697f249 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Wed Aug 24 11:10:23 2022 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Wed Aug 24 11:10:23 2022 +0900 [USER32] Get/SetWindowLongPtr about PIMEUI (#4625) In ImeWndProc_common, correctly get/set the PIMEUI value by Get/SetWindowLongPtrW. CORE-11700 --- win32ss/user/user32/misc/imm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/win32ss/user/user32/misc/imm.c b/win32ss/user/user32/misc/imm.c index 0bf16913d54..857ae50ae1f 100644 --- a/win32ss/user/user32/misc/imm.c +++ b/win32ss/user/user32/misc/imm.c @@ -959,6 +959,7 @@ ImeWndProc_common(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicod NtUserSetWindowFNID(hwnd, FNID_IME); pimeui = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMEUI)); pimeui->spwnd = pWnd; + SetWindowLongPtrW(hwnd, 0, (LONG_PTR)pimeui); } else { @@ -967,7 +968,7 @@ ImeWndProc_common(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicod ERR("Wrong window class for Ime! fnId 0x%x\n",pWnd->fnid); return 0; } - pimeui = ((PIMEWND)pWnd)->pimeui; + pimeui = (PIMEUI)GetWindowLongPtrW(hwnd, 0); if (pimeui == NULL) { ERR("Window is not set to IME!\n");
2 years, 4 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