When using an IME on Windows and the caret is near the bottom of the screen, candidate windows may not fit below the caret so are flipped up in an effort to not obscure the composition text. However, the current code only provides a position for the candidate window and this often leaves the composition text obscured like this image:

This can be fixed by setting an exclusion rectangle for the caret's line of text.
const Point pos = PointMainCaret();
const PRectangle rcClient = GetTextRectangle();
CANDIDATEFORM CandForm{};
CandForm.dwIndex = 0;
CandForm.dwStyle = CFS_EXCLUDE;
CandForm.ptCurrentPos.x = static_cast<int>(pos.x);
CandForm.ptCurrentPos.y = static_cast<int>(pos.y + vs.lineHeight);
// Exclude the area of the whole caret line
CandForm.rcArea.top = static_cast<int>(pos.y);
CandForm.rcArea.bottom = static_cast<int>(pos.y + vs.lineHeight);
CandForm.rcArea.left = static_cast<int>(rcClient.left);
CandForm.rcArea.right = static_cast<int>(rcClient.right);
::ImmSetCandidateWindow(imc.hIMC, &CandForm);
This results in the candidate appeaing higher with all of the composition text visible.

This change was initially discussed for a feature [feature-requests:#1300] but is useful independently so should be applied before #1300.
This was observed and fixed on Windows 10 1903.
A patch is attached.
I will try it.
Somthing is hidden in lineHeight.
Last edit: johnsonj 2019-07-14
I think this can be considered as one of the three changes in cand-pos-0714.diff.
1. (By John) Move SetCandidateWindowPos() into
if (initialCompose)fixed candidate window moving bug except for Google Japanese IME on Win7.2. (By Me) Update CandForm.ptCurrentPos.y fixed candidate window been placed below second line instead of current input text.
3. (By Neil) Change CFS_CANDIDATEPOS to CFS_EXCLUDE, this bug.
The three changes can be committed independently.
MoveImeCarets() will need another two or three commits.
As commnetd on https://sourceforge.net/p/scintilla/feature-requests/1300/?page=3&limit=25#6e9d
This change (CFS_CANDIDATEPOS to CFS_EXCLUDE) also fixed Google Chinese IME bug on Win7.
I second that too.
It works good.
tested on windows ime and google ime under win7.
Fix committed as [b99264].
Related
Commit: [b99264]
Fix committed as [b99264].
Related
Commit: [b99264]