https://git.reactos.org/?p=reactos.git;a=commitdiff;h=72c56c2f1fbd4581b9150…
commit 72c56c2f1fbd4581b91504c32115771d72f1e0e6
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Thu Oct 20 12:32:45 2022 +0900
Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
CommitDate: Thu Oct 20 12:32:45 2022 +0900
[IMM32] Improve ImmAssociateContext readability
CORE-11700
---
dll/win32/imm32/imm.c | 26 +++++++++++++++-----------
dll/win32/imm32/utils.c | 2 ++
2 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index 8f7f14764d9..e8498d9163d 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -513,19 +513,23 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
return hIMC;
dwValue = NtUserAssociateInputContext(hWnd, hIMC, 0);
- if (dwValue == 0)
- return hOldIMC;
- if (dwValue != 1)
- return NULL;
-
- hwndFocus = (HWND)NtUserQueryWindow(hWnd, QUERY_WINDOW_FOCUS);
- if (hwndFocus == hWnd)
+ switch (dwValue)
{
- ImmSetActiveContext(hWnd, hOldIMC, FALSE);
- ImmSetActiveContext(hWnd, hIMC, TRUE);
- }
+ case 0:
+ return hOldIMC;
- return hOldIMC;
+ case 1:
+ hwndFocus = (HWND)NtUserQueryWindow(hWnd, QUERY_WINDOW_FOCUS);
+ if (hwndFocus == hWnd)
+ {
+ ImmSetActiveContext(hWnd, hOldIMC, FALSE);
+ ImmSetActiveContext(hWnd, hIMC, TRUE);
+ }
+ return hOldIMC;
+
+ default:
+ return NULL;
+ }
}
/***********************************************************************
diff --git a/dll/win32/imm32/utils.c b/dll/win32/imm32/utils.c
index 3616f7ea39c..d2271fbabe0 100644
--- a/dll/win32/imm32/utils.c
+++ b/dll/win32/imm32/utils.c
@@ -207,6 +207,7 @@ LPSTR APIENTRY Imm32AnsiFromWide(LPCWSTR pszW)
}
/* Converts the character index */
+/* Win: CalcCharacterPositionAtoW */
LONG APIENTRY IchWideFromAnsi(LONG cchAnsi, LPCSTR pchAnsi, UINT uCodePage)
{
LONG cchWide;
@@ -227,6 +228,7 @@ LONG APIENTRY IchWideFromAnsi(LONG cchAnsi, LPCSTR pchAnsi, UINT
uCodePage)
}
/* Converts the character index */
+/* Win: CalcCharacterPositionWtoA */
LONG APIENTRY IchAnsiFromWide(LONG cchWide, LPCWSTR pchWide, UINT uCodePage)
{
LONG cb, cchAnsi;