From c11cd895465f591e4509f1e38d5df2f4e3923859 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 30 Oct 2022 16:11:33 +0200 Subject: [PATCH] Update Help file support --- od-win32/win32.cpp | 39 ++++----------------------- od-win32/win32.h | 2 -- od-win32/win32gui.cpp | 61 +++++++++++++++++++++++++++++-------------- od-win32/win32gui.h | 1 + 4 files changed, 47 insertions(+), 56 deletions(-) diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index 8654f628..eca5bf06 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -151,7 +151,6 @@ int max_uae_height; HINSTANCE hInst = NULL; HMODULE hUIDLL = NULL; -HWND (WINAPI *pHtmlHelp)(HWND, LPCWSTR, UINT, LPDWORD); HWND hHiddenWnd, hGUIWnd; #if KBHOOK static HHOOK hhook; @@ -208,7 +207,6 @@ TCHAR start_path_exe[MAX_DPATH]; TCHAR start_path_plugins[MAX_DPATH]; TCHAR start_path_new1[MAX_DPATH]; /* AF2005 */ TCHAR start_path_new2[MAX_DPATH]; /* AMIGAFOREVERDATA */ -TCHAR help_file[MAX_DPATH]; TCHAR bootlogpath[MAX_DPATH]; TCHAR logpath[MAX_DPATH]; bool winuaelog_temporary_enable; @@ -3006,7 +3004,7 @@ static LRESULT CALLBACK HiddenWindowProc (HWND hWnd, UINT message, WPARAM wParam inputdevice_add_inputcode (AKS_ENTERGUI, 1, NULL); break; case ID_ST_HELP: - HtmlHelp (NULL, help_file, 0, NULL); + HtmlHelp(NULL); break; case ID_ST_QUIT: uae_quit (); @@ -3264,39 +3262,14 @@ static int WIN32_RegisterClasses (void) return 1; } -static HINSTANCE hRichEdit = NULL, hHtmlHelp = NULL; - -int WIN32_CleanupLibraries (void) +static int WIN32_CleanupLibraries(void) { - if (hRichEdit) - FreeLibrary (hRichEdit); - - if (hHtmlHelp) - FreeLibrary (hHtmlHelp); - if (hUIDLL) - FreeLibrary (hUIDLL); - CoUninitialize (); + FreeLibrary(hUIDLL); + CoUninitialize(); return 1; } -/* HtmlHelp Initialization - optional component */ -int WIN32_InitHtmlHelp (void) -{ - const TCHAR *chm = _T("WinUAE.chm"); - int result = 0; - _stprintf(help_file, _T("%s%s"), start_path_data, chm); - if (!zfile_exists (help_file)) - _stprintf(help_file, _T("%s%s"), start_path_exe, chm); - if (zfile_exists (help_file)) { - if (hHtmlHelp = LoadLibrary (_T("HHCTRL.OCX"))) { - pHtmlHelp = (HWND(WINAPI *)(HWND, LPCWSTR, UINT, LPDWORD))GetProcAddress (hHtmlHelp, "HtmlHelpW"); - result = 1; - } - } - return result; -} - const struct winuae_lang langs[] = { { LANG_AFRIKAANS, _T("Afrikaans") }, @@ -3515,7 +3488,6 @@ static int WIN32_InitLibraries (void) if (pSetCurrentProcessExplicitAppUserModelID) pSetCurrentProcessExplicitAppUserModelID (WINUAEAPPNAME); - hRichEdit = LoadLibrary (_T("RICHED32.DLL")); return 1; } @@ -7158,7 +7130,6 @@ static int PASCAL WinMain2 (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR } #endif WIN32_InitLang (); - WIN32_InitHtmlHelp (); unicode_init (); can_D3D11(false); if (betamessage ()) { @@ -7654,7 +7625,7 @@ static void systraymenu (HWND hwnd) menu2 = GetSubMenu (menu, 0); drvmenu = GetSubMenu (menu2, 1); cdmenu = GetSubMenu (menu2, 2); - EnableMenuItem (menu2, ID_ST_HELP, pHtmlHelp ? MF_ENABLED : MF_GRAYED); + EnableMenuItem (menu2, ID_ST_HELP, MF_ENABLED); i = 0; while (drvs[i] >= 0) { TCHAR s[MAX_DPATH]; diff --git a/od-win32/win32.h b/od-win32/win32.h index 022da6ea..291d161e 100644 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -57,9 +57,7 @@ extern int getcapslock (void); void releasecapture (struct AmigaMonitor*); int WIN32_RegisterClasses (void); -int WIN32_InitHtmlHelp (void); int WIN32_InitLibraries (void); -int WIN32_CleanupLibraries (void); void WIN32_HandleRegistryStuff (void); extern void setup_brkhandler (void); extern void remove_brkhandler (void); diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index e7948093..0bd1c142 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -134,28 +134,50 @@ static int qs_override; int gui_active, gui_left; static struct newresource *panelresource; int dialog_inhibit; +static HMODULE hHtmlHelp; -#undef HtmlHelp -#ifndef HH_DISPLAY_TOPIC -#define HH_DISPLAY_TOPIC 0 -#endif - -extern HWND(WINAPI *pHtmlHelp)(HWND, LPCWSTR, UINT, LPDWORD); - -void HtmlHelp(HWND a, LPCWSTR b, UINT c, const TCHAR *d) +void HtmlHelp(const TCHAR *panel) { - if (pHtmlHelp) { - (*pHtmlHelp)(a, b, c, (LPDWORD)d); - } else { - if (gui_message_multibutton(1, _T("Help file is not installed locally, do you want to open online version? (http://www.winuae.net/help/)")) == 1) { - HINSTANCE h = ShellExecute(NULL, _T("open"), _T("http://www.winuae.net/help/"), NULL, NULL, SW_SHOWNORMAL); - if ((INT_PTR)h <= 32) { - TCHAR szMessage[MAX_DPATH]; - WIN32GUI_LoadUIString(IDS_NOHELP, szMessage, MAX_DPATH); - gui_message(szMessage); + TCHAR help_file[MAX_DPATH]; + int found = -1; + const TCHAR *ext[] = { _T("chm"), _T("pdf"), NULL }; + const TCHAR *chm = _T("WinUAE"); + for (int i = 0; ext[i] != NULL; i++) { + _stprintf(help_file, _T("%s%s.%s"), start_path_data, chm, ext[i]); + if (!zfile_exists(help_file)) { + _stprintf(help_file, _T("%s%s.%s"), start_path_exe, chm, ext[i]); + } + if (zfile_exists(help_file)) { + found = i; + break; + } + } + if (found == 0) { + if (!hHtmlHelp) { + hHtmlHelp = LoadLibrary(_T("HHCTRL.OCX")); + } + if (hHtmlHelp) { + HWND(WINAPI * pHtmlHelp)(HWND, LPCWSTR, UINT, LPDWORD); + pHtmlHelp = (HWND(WINAPI *)(HWND, LPCWSTR, UINT, LPDWORD))GetProcAddress(hHtmlHelp, "HtmlHelpW"); + if (pHtmlHelp) { + pHtmlHelp(NULL, help_file, 0, (LPDWORD)panel); + return; } } } + if (found <= 0) { + _tcscpy(help_file, _T("https://www.winuae.net/help/")); + if (panel) { + _tcscat(help_file, _T("#")); + _tcscat(help_file, panel); + } + } + HINSTANCE h = ShellExecute(NULL, _T("open"), help_file, NULL, NULL, SW_SHOWNORMAL); + if ((INT_PTR)h <= 32) { + TCHAR szMessage[MAX_DPATH]; + WIN32GUI_LoadUIString(IDS_NOHELP, szMessage, MAX_DPATH); + gui_message(szMessage); + } } extern TCHAR help_file[MAX_DPATH]; @@ -21433,7 +21455,7 @@ static HWND updatePanel (int id, UINT action) ShowWindow (GetDlgItem (hDlg, IDC_PANEL_FRAME_OUTER), !fullpanel ? SW_SHOW : SW_HIDE); ShowWindow (GetDlgItem (hDlg, IDC_PANELTREE), !fullpanel ? SW_SHOW : SW_HIDE); ShowWindow (panelDlg, SW_SHOW); - ew (hDlg, IDHELP, (pHtmlHelp && ppage[currentpage].help) || !pHtmlHelp ? TRUE : FALSE); + ew (hDlg, IDHELP, TRUE); ToolTipHWND = CreateWindowEx (WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, @@ -22203,8 +22225,7 @@ static INT_PTR CALLBACK DialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l exit_gui (1); return TRUE; case IDHELP: - if ((pHtmlHelp && ppage[currentpage].help) || !pHtmlHelp) - HtmlHelp(NULL, help_file, HH_DISPLAY_TOPIC, ppage[currentpage].help); + HtmlHelp(ppage[currentpage].help); return TRUE; case IDOK: updatePanel (-1, 0); diff --git a/od-win32/win32gui.h b/od-win32/win32gui.h index de294b33..94a0ae19 100644 --- a/od-win32/win32gui.h +++ b/od-win32/win32gui.h @@ -17,6 +17,7 @@ extern void gui_message_id (int id); int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int currentpage); UAEREG *read_disk_history (int type); void write_disk_history (void); +void HtmlHelp(const TCHAR*); #define MAX_GUIIDPARAMS 16 #define MAX_DLGID 100 -- 2.47.3