https://git.reactos.org/?p=reactos.git;a=commitdiff;h=88733bca7733cec096b6b…
commit 88733bca7733cec096b6bd6d0fe09e6628c56057
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Fri Mar 17 07:25:51 2023 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Fri Mar 17 07:25:51 2023 +0900
[MSPAINT] Unlink HHCTRL.OCX and use dynamic load (#5165)
Unlink HHCTRL.OCX by modifying CMakeLists.txt. Add DoHtmlHelpW helper function.
CORE-18879, CORE-18867
---
base/applications/mspaint/CMakeLists.txt | 2 +-
base/applications/mspaint/winproc.cpp | 40 +++++++++++++++++++++++++++++---
2 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/base/applications/mspaint/CMakeLists.txt
b/base/applications/mspaint/CMakeLists.txt
index 99215c5295b..b4613246f45 100644
--- a/base/applications/mspaint/CMakeLists.txt
+++ b/base/applications/mspaint/CMakeLists.txt
@@ -36,6 +36,6 @@ add_executable(mspaint ${SOURCE} rsrc.rc)
set_module_type(mspaint win32gui UNICODE)
target_link_libraries(mspaint uuid cpprt atl_classes)
set_target_cpp_properties(mspaint WITH_EXCEPTIONS)
-add_importlibs(mspaint hhctrl comdlg32 shell32 user32 gdi32 advapi32 comctl32 msvcrt
kernel32 rpcrt4 shlwapi ntdll)
+add_importlibs(mspaint comdlg32 shell32 user32 gdi32 advapi32 comctl32 msvcrt kernel32
rpcrt4 shlwapi ntdll)
add_pch(mspaint precomp.h SOURCE)
add_cd_file(TARGET mspaint DESTINATION reactos/system32 FOR all)
diff --git a/base/applications/mspaint/winproc.cpp
b/base/applications/mspaint/winproc.cpp
index 77d74061aa8..5cb8cccf379 100644
--- a/base/applications/mspaint/winproc.cpp
+++ b/base/applications/mspaint/winproc.cpp
@@ -9,12 +9,36 @@
* Stanislav Motylkov
*/
-/* INCLUDES *********************************************************/
-
#include "precomp.h"
+typedef HWND (WINAPI *FN_HtmlHelpW)(HWND, LPCWSTR, UINT, DWORD_PTR);
+
+static HINSTANCE s_hHHCTRL_OCX = NULL; // HtmlHelpW needs "hhctrl.ocx"
+static FN_HtmlHelpW s_pHtmlHelpW = NULL;
+
/* FUNCTIONS ********************************************************/
+// A wrapper function for HtmlHelpW
+static HWND DoHtmlHelpW(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_PTR
dwData)
+{
+ WCHAR szPath[MAX_PATH];
+
+ if (!s_hHHCTRL_OCX && (uCommand != HH_CLOSE_ALL))
+ {
+ // The function loads the system library, not local
+ GetSystemDirectoryW(szPath, _countof(szPath));
+ wcscat(szPath, L"\\hhctrl.ocx");
+ s_hHHCTRL_OCX = LoadLibraryW(szPath);
+ if (s_hHHCTRL_OCX)
+ s_pHtmlHelpW = (FN_HtmlHelpW)GetProcAddress(s_hHHCTRL_OCX,
"HtmlHelpW");
+ }
+
+ if (!s_pHtmlHelpW)
+ return NULL;
+
+ return s_pHtmlHelpW(hwndCaller, pszFile, uCommand, dwData);
+}
+
BOOL
zoomTo(int newZoom, int mouseX, int mouseY)
{
@@ -235,6 +259,16 @@ LRESULT CMainWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM
lParam, BOOL& bHa
LRESULT CMainWindow::OnDestroy(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
{
GetWindowPlacement(&(registrySettings.WindowPlacement));
+
+ DoHtmlHelpW(NULL, NULL, HH_CLOSE_ALL, 0);
+
+ if (s_hHHCTRL_OCX)
+ {
+ FreeLibrary(s_hHHCTRL_OCX);
+ s_hHHCTRL_OCX = NULL;
+ s_pHtmlHelpW = NULL;
+ }
+
PostQuitMessage(0); /* send a WM_QUIT to the message queue */
return 0;
}
@@ -445,7 +479,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM
lParam, BOOL& bH
break;
}
case IDM_HELPHELPTOPICS:
- HtmlHelp(m_hWnd, _T("help\\Paint.chm"), 0, 0);
+ DoHtmlHelpW(m_hWnd, L"%SystemRoot%\\Help\\mspaint.chm",
HH_DISPLAY_TOPIC, 0);
break;
case IDM_FILEEXIT:
SendMessage(WM_CLOSE, wParam, lParam);