mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[MSPAINT] Unlink HHCTRL.OCX and use dynamic load (#5165)
Unlink HHCTRL.OCX by modifying CMakeLists.txt. Add DoHtmlHelpW helper function. CORE-18879, CORE-18867
This commit is contained in:
parent
eb7550f767
commit
88733bca77
2 changed files with 38 additions and 4 deletions
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue