Main window title was incorrect in a couple of cases: - the value displayed when the .HLP file didn't contain nor the main window caption nor the default help file title was incorrect (they are different patterns used, but the trigger was incorrect) - some titles were cropped (because incorrectly stored in main window caption - which is of fixed size)
Changes made: - never generate a caption when none present on file, but always fallback to the help file title in this case - generate default titles when none are present on file (title pattern depends on file version) - in pattern displaying filename, only show the basename.
These changes give the same result for the main window's title on all the .hlp files from my test database. (except for some cases where 'Wine help' is used instead of 'help', but I didn't bother adding a new entry in string table).
Signed-off-by: Eric Pouech epouech@codeweavers.com
From: Eric Pouech epouech@codeweavers.com
Main window title was incorrect in a couple of cases: - the value displayed when the .HLP file didn't contain nor the main window caption nor the default help file title was incorrect (they are different patterns used, but the trigger was incorrect) - some titles were cropped (because incorrectly stored in main window caption - which is of fixed size)
Changes made: - never generate a caption when none present on file, but always fallback to the help file title in this case - generate default titles when none are present on file (title pattern depends on file version) - in pattern displaying filename, only show the basename.
These changes give the same result for the main window's title on all the .hlp files from my test database. (except for some cases where 'Wine help' is used instead of 'help', but I didn't bother adding a new entry in string table).
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/winhlp32/hlpfile.c | 22 ++++++++++++++++++---- programs/winhlp32/winhelp.c | 10 +--------- 2 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/programs/winhlp32/hlpfile.c b/programs/winhlp32/hlpfile.c index 4fb6853cfe6..1fd66ed48e0 100644 --- a/programs/winhlp32/hlpfile.c +++ b/programs/winhlp32/hlpfile.c @@ -2055,9 +2055,16 @@ static BOOL HLPFILE_SystemCommands(HLPFILE* hlpfile) if (hlpfile->version <= 16) { char *str = (char*)buf + 0x15; + char tmp[40]; + LPCSTR filename = strrchr(hlpfile->lpszPath, '\'); + size_t len; + + if (!filename) filename = hlpfile->lpszPath; else filename++; + LoadStringA(Globals.hInstance, STID_WINE_HELP, tmp, sizeof(tmp)); + len = strlen(str) + 1 + strlen(tmp) + 3 + strlen(filename) + 1; + if (!(hlpfile->lpszTitle = malloc(len))) return FALSE; + _snprintf(hlpfile->lpszTitle, len, "%s %s - %s", str, tmp, filename);
- hlpfile->lpszTitle = strdup(str); - if (!hlpfile->lpszTitle) return FALSE; WINE_TRACE("Title: %s\n", debugstr_a(hlpfile->lpszTitle)); /* Nothing more to parse */ return TRUE; @@ -2069,7 +2076,14 @@ static BOOL HLPFILE_SystemCommands(HLPFILE* hlpfile) { case 1: if (hlpfile->lpszTitle) {WINE_WARN("title\n"); break;} - hlpfile->lpszTitle = strdup(str); + if (*str) + hlpfile->lpszTitle = strdup(str); + else + { + char tmp[40]; + LoadStringA(Globals.hInstance, STID_WINE_HELP, tmp, sizeof(tmp)); + hlpfile->lpszTitle = strdup(tmp); + } if (!hlpfile->lpszTitle) return FALSE; WINE_TRACE("Title: %s\n", debugstr_a(hlpfile->lpszTitle)); break; @@ -2123,7 +2137,7 @@ static BOOL HLPFILE_SystemCommands(HLPFILE* hlpfile) if (flags & 0x0002) strcpy(wi->name, &str[12]); else wi->name[0] = '\0'; if (flags & 0x0004) strcpy(wi->caption, &str[21]); - else lstrcpynA(wi->caption, hlpfile->lpszTitle, sizeof(wi->caption)); + else wi->caption[0] = '\0'; wi->origin.x = (flags & 0x0008) ? GET_USHORT(ptr, 76) : CW_USEDEFAULT; wi->origin.y = (flags & 0x0010) ? GET_USHORT(ptr, 78) : CW_USEDEFAULT; wi->size.cx = (flags & 0x0020) ? GET_USHORT(ptr, 80) : CW_USEDEFAULT; diff --git a/programs/winhlp32/winhelp.c b/programs/winhlp32/winhelp.c index d648cab7982..7f518bd25ea 100644 --- a/programs/winhlp32/winhelp.c +++ b/programs/winhlp32/winhelp.c @@ -271,15 +271,7 @@ HLPFILE_WINDOWINFO* WINHELP_GetWindowInfo(HLPFILE* hlpfile, LPCSTR name) { strcpy(mwi.type, "primary"); strcpy(mwi.name, "main"); - if (hlpfile && hlpfile->lpszTitle[0]) - { - char tmp[40]; - LoadStringA(Globals.hInstance, STID_WINE_HELP, tmp, sizeof(tmp)); - _snprintf(mwi.caption, sizeof(mwi.caption), "%s %s - %s", - hlpfile->lpszTitle, tmp, hlpfile->lpszPath); - } - else - LoadStringA(Globals.hInstance, STID_WINE_HELP, mwi.caption, sizeof(mwi.caption)); + mwi.caption[0] = '\0'; mwi.origin.x = mwi.origin.y = mwi.size.cx = mwi.size.cy = CW_USEDEFAULT; mwi.style = SW_SHOW; mwi.win_style = WS_OVERLAPPEDWINDOW;