[PATCH v12 0/1] MR11400: winhlp32: MACRO_PopupContext for bug #56516
https://bugs.winehq.org/show_bug.cgi?id=56516#c1 -- v12: winhlp32: MACRO_PopupContext for bug #56516 https://gitlab.winehq.org/wine/wine/-/merge_requests/11400
From: Stian Low <wineryyyyy@gmail.com> --- dlls/riched20/wrap.c | 4 ++-- programs/winhlp32/macro.c | 18 +++++++++++++++++- programs/winhlp32/winhelp.c | 10 ++++++---- programs/winhlp32/winhelp.h | 1 + 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c index a4d638aec3d..001ea2dff87 100644 --- a/dlls/riched20/wrap.c +++ b/dlls/riched20/wrap.c @@ -1150,8 +1150,8 @@ ME_SendRequestResize(ME_TextEditor *editor, BOOL force) info.nmhdr.idFrom = 0; info.nmhdr.code = EN_REQUESTRESIZE; info.rc = rc; - info.rc.right = editor->nTotalWidth; - info.rc.bottom = editor->nTotalLength; + info.rc.right = rc.left + editor->nTotalWidth; + info.rc.bottom = rc.bottom + editor->nTotalLength; editor->nEventMask &= ~ENM_REQUESTRESIZE; ITextHost_TxNotify(editor->texthost, info.nmhdr.code, &info); diff --git a/programs/winhlp32/macro.c b/programs/winhlp32/macro.c index 36bda654afd..967ccb10b4c 100644 --- a/programs/winhlp32/macro.c +++ b/programs/winhlp32/macro.c @@ -671,7 +671,23 @@ static void CALLBACK MACRO_NoShow(void) void CALLBACK MACRO_PopupContext(LPCSTR str, LONG u) { - WINE_FIXME("(%s, %lu)\n", debugstr_a(str), u); + HLPFILE_WINDOWINFO* wi; + HLPFILE *hlpfile; + POINT origin; + + WINE_TRACE("(%s, %lu)\n", debugstr_a(str), u); + + if (!(hlpfile = WINHELP_LookupHelpFile(str))) + { + WINE_ERR("Failed to load .hlp file.\n"); + return; + } + + if (!GetCursorPos(&origin)) + WINE_FIXME("GetCursorPos failed so popup context help may appear misplaced.\n"); + + wi = WINHELP_GetPopupWindowInfo(hlpfile, MACRO_CurrentWindow(), MAKELPARAM(origin.x, origin.y)); + WINHELP_OpenHelpWindow(HLPFILE_PageByMap, hlpfile, u, wi, SW_NORMAL); } static void CALLBACK MACRO_PopupHash(LPCSTR str, LONG u) diff --git a/programs/winhlp32/winhelp.c b/programs/winhlp32/winhelp.c index 1c112f08aaf..4ab3fee7950 100644 --- a/programs/winhlp32/winhelp.c +++ b/programs/winhlp32/winhelp.c @@ -293,7 +293,7 @@ HLPFILE_WINDOWINFO* WINHELP_GetWindowInfo(HLPFILE* hlpfile, LPCSTR name) * * */ -static HLPFILE_WINDOWINFO* WINHELP_GetPopupWindowInfo(HLPFILE* hlpfile, +HLPFILE_WINDOWINFO* WINHELP_GetPopupWindowInfo(HLPFILE* hlpfile, WINHELP_WINDOW* parent, LPARAM mouse) { static HLPFILE_WINDOWINFO wi; @@ -305,7 +305,7 @@ static HLPFILE_WINDOWINFO* WINHELP_GetPopupWindowInfo(HLPFILE* hlpfile, /* Calculate horizontal size and position of a popup window */ GetWindowRect(parent->hMainWnd, &parent_rect); wi.size.cx = (parent_rect.right - parent_rect.left) / 2; - wi.size.cy = 10; /* need a non null value, so that borders are taken into account while computing */ + wi.size.cy = (parent_rect.bottom - parent_rect.top) / 2; wi.origin.x = (short)LOWORD(mouse); wi.origin.y = (short)HIWORD(mouse); @@ -316,10 +316,13 @@ static HLPFILE_WINDOWINFO* WINHELP_GetPopupWindowInfo(HLPFILE* hlpfile, wi.style = SW_SHOW; wi.win_style = WS_POPUP | WS_BORDER; - if (parent->page->file->has_popup_color) + if (hlpfile->has_popup_color) + wi.sr_color = hlpfile->popup_color; + else if (parent->page && parent->page->file->has_popup_color) wi.sr_color = parent->page->file->popup_color; else wi.sr_color = parent->info->sr_color; + wi.nsr_color = 0xFFFFFF; return &wi; @@ -812,7 +815,6 @@ BOOL WINHELP_CreateHelpWindow(WINHELP_WNDPAGE* wpage, int nCmdShow, BOOL remembe /* Create button box and text Window */ CreateWindowA(BUTTON_BOX_WIN_CLASS_NAME, "", WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, win->hMainWnd, (HMENU)CTL_ID_BUTTON, Globals.hInstance, NULL); - hTextWnd = CreateWindowA(RICHEDIT_CLASS20A, NULL, ES_MULTILINE | ES_READONLY | WS_CHILD | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE, 0, 0, 0, 0, win->hMainWnd, (HMENU)CTL_ID_TEXT, Globals.hInstance, NULL); diff --git a/programs/winhlp32/winhelp.h b/programs/winhlp32/winhelp.h index 519dec215a9..6d2f0ebc01f 100644 --- a/programs/winhlp32/winhelp.h +++ b/programs/winhlp32/winhelp.h @@ -170,6 +170,7 @@ BOOL WINHELP_CreateIndexWindow(BOOL); void WINHELP_DeleteBackSet(WINHELP_WINDOW*); HLPFILE* WINHELP_LookupHelpFile(LPCSTR lpszFile); HLPFILE_WINDOWINFO* WINHELP_GetWindowInfo(HLPFILE* hlpfile, LPCSTR name); +HLPFILE_WINDOWINFO* WINHELP_GetPopupWindowInfo(HLPFILE* hlpfile, WINHELP_WINDOW* parent, LPARAM mouse); void WINHELP_LayoutMainWindow(WINHELP_WINDOW* win); WINHELP_WINDOW* WINHELP_GrabWindow(WINHELP_WINDOW*); BOOL WINHELP_ReleaseWindow(WINHELP_WINDOW*); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11400
spent some time investigation richedit about the wrong layout of the popup: - basically, richedit expects that the rect returned by requestsize can be used as client area and layout will be done without scrollbars. this is not the case, and doing so generates a vertical scrollbar. - this will require more testing to check if richedit current behavior matches native (or not) - hacking shamelessly richedit with [p](/uploads/25ac6287081ebec51a7a353fc15a9baf/p) seems to get some more correct results (even if some local examples still show a wrong height computation, implying again a vertical scrollbar) since the popup layout issue appears orthogonally of this MR (I repro it on almost all local .hlp files with popups), I suggest reducing this MR to only implementing the MACRO_PopupContext() part (and leave the popup layout for a further MR) -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11400#note_146069
On Sun Jul 19 16:52:35 2026 +0000, eric pouech wrote:
spent some time investigation richedit about the wrong layout of the popup: - basically, richedit expects that the rect returned by requestsize can be used as client area and layout will be done without scrollbars. this is not the case, and doing so generates a vertical scrollbar. - this will require more testing to check if richedit current behavior matches native (or not) - hacking shamelessly richedit with [p](/uploads/25ac6287081ebec51a7a353fc15a9baf/p) seems to get some more correct results (even if some local examples still show a wrong height computation, implying again a vertical scrollbar) since the popup layout issue appears orthogonally of this MR (I repro it on almost all local .hlp files with popups), I suggest reducing this MR to only implementing the MACRO_PopupContext() part (and leave the popup layout for a further MR) Thanks for confirming something else in the pipeline may be bugged that breaks popup layout which matches my tests.
I'll remove hacks to improve popup layout and reduce this MR to just `MACRO_PopupContext` and leave layout fixes for a separate MR. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11400#note_146070
participants (3)
-
eric pouech (@epo) -
Stian Low -
Stian Low (@stianlow)