]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Update Help file support
authorToni Wilen <twilen@winuae.net>
Sun, 30 Oct 2022 14:11:33 +0000 (16:11 +0200)
committerToni Wilen <twilen@winuae.net>
Sun, 30 Oct 2022 14:11:33 +0000 (16:11 +0200)
od-win32/win32.cpp
od-win32/win32.h
od-win32/win32gui.cpp
od-win32/win32gui.h

index 8654f628bde7467a377148d640064e0c5fbdac81..eca5bf06c77287673a0be1d1568165c9c3dae27f 100644 (file)
@@ -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];
index 022da6ea954569ff295e4a1f593c8ca313369149..291d161e4991d8f7a0ce61ea37b093ad07b5de81 100644 (file)
@@ -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);
index e79480938767bf9f4a8efbd0b5a00dcd4d5b07c6..0bd1c1425ff19f7afc7c2c3e3bf7e6a982ab009b 100644 (file)
@@ -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);
index de294b33418c23decf80554a8a169d2b7b861959..94a0ae19d7202fdd8fb1d33103d34876bf9d5ddb 100644 (file)
@@ -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