winhelp: Rewrite LookupHelpFile function.

Add ability for user to find file himself if winhelp cannot find it.
Update resources.
This commit is contained in:
Kirill K. Smirnov 2006-11-06 15:07:01 +03:00 committed by Alexandre Julliard
parent 7dd0eaa904
commit 4f2819f2e1
28 changed files with 94 additions and 61 deletions

View File

@ -65,4 +65,5 @@ STID_HISTORY, "&
STID_TOPICS, "&Òåìè" STID_TOPICS, "&Òåìè"
STID_ALL_FILES, "Âñè÷êè ôàéëîâå (*.*)" STID_ALL_FILES, "Âñè÷êè ôàéëîâå (*.*)"
STID_HELP_FILES_HLP, "Ïîìîùíè ôàéëîâå (*.hlp)" STID_HELP_FILES_HLP, "Ïîìîùíè ôàéëîâå (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -70,4 +70,5 @@ STID_HISTORY, "&Historie"
STID_TOPICS, "&Témata" STID_TOPICS, "&Témata"
STID_ALL_FILES, "Všechny soubory (*.*)" STID_ALL_FILES, "Všechny soubory (*.*)"
STID_HELP_FILES_HLP, "Soubory nápovìdy (*.hlp)" STID_HELP_FILES_HLP, "Soubory nápovìdy (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -68,4 +68,5 @@ STID_HISTORY, "&Oversigt"
STID_TOPICS, "To&pics" STID_TOPICS, "To&pics"
STID_ALL_FILES, "Alle filer (*.*)" STID_ALL_FILES, "Alle filer (*.*)"
STID_HELP_FILES_HLP, "Hjælpe filer (*.hlp)" STID_HELP_FILES_HLP, "Hjælpe filer (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -67,4 +67,5 @@ STID_HISTORY, "&Bisher"
STID_TOPICS, "&Topics" STID_TOPICS, "&Topics"
STID_ALL_FILES, "Alle Dateien (*.*)" STID_ALL_FILES, "Alle Dateien (*.*)"
STID_HELP_FILES_HLP, "Hilfe-Dateien (*.hlp)" STID_HELP_FILES_HLP, "Hilfe-Dateien (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -66,4 +66,5 @@ STID_HISTORY, "&History"
STID_TOPICS, "&Topics" STID_TOPICS, "&Topics"
STID_ALL_FILES, "All files (*.*)" STID_ALL_FILES, "All files (*.*)"
STID_HELP_FILES_HLP, "Help files (*.hlp)" STID_HELP_FILES_HLP, "Help files (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -68,4 +68,5 @@ STID_HISTORY, "Krono&logio"
STID_TOPICS, "&Temoj" STID_TOPICS, "&Temoj"
STID_ALL_FILES, "Tutaj dosieroj (*.*)" STID_ALL_FILES, "Tutaj dosieroj (*.*)"
STID_HELP_FILES_HLP, "Helpaj dosieroj (*.hlp)" STID_HELP_FILES_HLP, "Helpaj dosieroj (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -67,4 +67,5 @@ STID_HISTORY, "&Historial"
STID_TOPICS, "&Temas" STID_TOPICS, "&Temas"
STID_ALL_FILES, "Todos los archivos (*.*)" STID_ALL_FILES, "Todos los archivos (*.*)"
STID_HELP_FILES_HLP, "Archivos de ayuda (*.hlp)" STID_HELP_FILES_HLP, "Archivos de ayuda (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -68,4 +68,5 @@ STID_HISTORY, "&Luetut"
STID_TOPICS, "T&opics" STID_TOPICS, "T&opics"
STID_ALL_FILES, "Kaikki tiedostot (*.*)" STID_ALL_FILES, "Kaikki tiedostot (*.*)"
STID_HELP_FILES_HLP, "Ohjetiedostot (*.hlp)" STID_HELP_FILES_HLP, "Ohjetiedostot (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -68,4 +68,5 @@ STID_HISTORY, "&Historique"
STID_TOPICS, "&Sujets" STID_TOPICS, "&Sujets"
STID_ALL_FILES, "Tous fichiers (*.*)" STID_ALL_FILES, "Tous fichiers (*.*)"
STID_HELP_FILES_HLP, "Fichiers d'aide (*.hlp)" STID_HELP_FILES_HLP, "Fichiers d'aide (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -68,4 +68,5 @@ STID_HISTORY, "&El
STID_TOPICS, "&Témakörök" STID_TOPICS, "&Témakörök"
STID_ALL_FILES, "Minden fájl (*.*)" STID_ALL_FILES, "Minden fájl (*.*)"
STID_HELP_FILES_HLP, "Súgó fájlok (*.hlp)" STID_HELP_FILES_HLP, "Súgó fájlok (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -67,4 +67,5 @@ STID_HISTORY, "&Cronologia"
STID_TOPICS, "&Argomenti" STID_TOPICS, "&Argomenti"
STID_ALL_FILES, "Tutti i file (*.*)" STID_ALL_FILES, "Tutti i file (*.*)"
STID_HELP_FILES_HLP, "File della Guida (*.hlp)" STID_HELP_FILES_HLP, "File della Guida (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -67,4 +67,5 @@ STID_HISTORY, "
STID_TOPICS, "&Topics" STID_TOPICS, "&Topics"
STID_ALL_FILES, "모든 파일 (*.*)" STID_ALL_FILES, "모든 파일 (*.*)"
STID_HELP_FILES_HLP, "도움말 파일 (*.hlp)" STID_HELP_FILES_HLP, "도움말 파일 (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -65,4 +65,5 @@ STID_HISTORY, "&Geschiedenis"
STID_TOPICS, "&Onderwerpen" STID_TOPICS, "&Onderwerpen"
STID_ALL_FILES, "Alle bestanden (*.*)" STID_ALL_FILES, "Alle bestanden (*.*)"
STID_HELP_FILES_HLP, "Helpbestanden (*.hlp)" STID_HELP_FILES_HLP, "Helpbestanden (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -65,4 +65,5 @@ STID_HISTORY, "&Historikk"
STID_TOPICS, "&Emner" STID_TOPICS, "&Emner"
STID_ALL_FILES, "Alle filer (*.*)" STID_ALL_FILES, "Alle filer (*.*)"
STID_HELP_FILES_HLP, "Hjelp-filer (*.hlp)" STID_HELP_FILES_HLP, "Hjelp-filer (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -67,4 +67,5 @@ STID_HISTORY, "&Historia"
STID_TOPICS, "&Tematy" STID_TOPICS, "&Tematy"
STID_ALL_FILES, "Wszystkie pliki (*.*)" STID_ALL_FILES, "Wszystkie pliki (*.*)"
STID_HELP_FILES_HLP, "Pliki pomocy (*.hlp)" STID_HELP_FILES_HLP, "Pliki pomocy (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -106,6 +106,7 @@ STID_HISTORY, "&Hist
STID_TOPICS, "&Tópicos" STID_TOPICS, "&Tópicos"
STID_ALL_FILES, "Todos os arquivos (*.*)" STID_ALL_FILES, "Todos os arquivos (*.*)"
STID_HELP_FILES_HLP, "Arquivos de ajuda (*.hlp)" STID_HELP_FILES_HLP, "Arquivos de ajuda (*.hlp)"
STID_FILE_NOT_FOUND_s"Cannot find '%s'. Do you want to find this file yourself?"
} }
LANGUAGE LANG_PORTUGUESE, SUBLANG_PORTUGUESE LANGUAGE LANG_PORTUGUESE, SUBLANG_PORTUGUESE
@ -125,4 +126,5 @@ STID_HISTORY, "&Hist
STID_TOPICS, "&Tópicos" STID_TOPICS, "&Tópicos"
STID_ALL_FILES, "Todos os ficheiros (*.*)" STID_ALL_FILES, "Todos os ficheiros (*.*)"
STID_HELP_FILES_HLP, "Ficheiros de ajuda (*.hlp)" STID_HELP_FILES_HLP, "Ficheiros de ajuda (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -65,4 +65,5 @@ STID_HISTORY, "&
STID_TOPICS, "&Óêàçàòåëü" STID_TOPICS, "&Óêàçàòåëü"
STID_ALL_FILES, "Âñå ôàéëû (*.*)" STID_ALL_FILES, "Âñå ôàéëû (*.*)"
STID_HELP_FILES_HLP, "Ôàéëû ñïðàâêè (*.hlp)" STID_HELP_FILES_HLP, "Ôàéëû ñïðàâêè (*.hlp)"
STID_FILE_NOT_FOUND_s "Не могу найти '%s'. Вы хотите найти этот файл самостоятельно?"
} }

View File

@ -65,4 +65,5 @@ STID_HISTORY, "&Zgodovina"
STID_TOPICS, "&Vsebina" STID_TOPICS, "&Vsebina"
STID_ALL_FILES, "Vse datiteke (*.*)" STID_ALL_FILES, "Vse datiteke (*.*)"
STID_HELP_FILES_HLP, "Datoteke s pomoèjo (*.hlp)" STID_HELP_FILES_HLP, "Datoteke s pomoèjo (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -62,4 +62,5 @@ STID_HISTORY, "&Hist
STID_TOPICS, "&Topics" STID_TOPICS, "&Topics"
STID_ALL_FILES, "Všetky súbory (*.*)" STID_ALL_FILES, "Všetky súbory (*.*)"
STID_HELP_FILES_HLP, "Súbory pomoci (*.hlp)" STID_HELP_FILES_HLP, "Súbory pomoci (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -68,4 +68,5 @@ STID_HISTORY, "&
STID_TOPICS, "T&opics" STID_TOPICS, "T&opics"
STID_ALL_FILES, "Alla filer (*.*))" STID_ALL_FILES, "Alla filer (*.*))"
STID_HELP_FILES_HLP, "Hjälp filer (*.hlp)" STID_HELP_FILES_HLP, "Hjälp filer (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -65,4 +65,5 @@ STID_HISTORY, "Ge&
STID_TOPICS, "&Konular" STID_TOPICS, "&Konular"
STID_ALL_FILES, "Tüm dosyalar (*.*)" STID_ALL_FILES, "Tüm dosyalar (*.*)"
STID_HELP_FILES_HLP, "Yardým dosyalarý (*.hlp)" STID_HELP_FILES_HLP, "Yardým dosyalarý (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -72,4 +72,5 @@ HISTORY, "&Fin qua"
TOPICS, "T&opics" TOPICS, "T&opics"
ALL_FILES, "Tuot las datotecas (*.*)" ALL_FILES, "Tuot las datotecas (*.*)"
HELP_FILES_HLP, "Datotecas d'agüd (*.hlp)" HELP_FILES_HLP, "Datotecas d'agüd (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -70,6 +70,7 @@ STID_HISTORY, "&Istwere"
STID_TOPICS, "&Topics" STID_TOPICS, "&Topics"
STID_ALL_FILES, "Tos les fitchîs (*.*)" STID_ALL_FILES, "Tos les fitchîs (*.*)"
STID_HELP_FILES_HLP, "Fitchîs d' aide (*.hlp)" STID_HELP_FILES_HLP, "Fitchîs d' aide (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }
#endif /* LANG_WALON */ #endif /* LANG_WALON */

View File

@ -66,4 +66,5 @@ STID_HISTORY, "
STID_TOPICS, "主题(&T" STID_TOPICS, "主题(&T"
STID_ALL_FILES, "所有文件 (*.*)" STID_ALL_FILES, "所有文件 (*.*)"
STID_HELP_FILES_HLP, "帮助文件 (*.hlp)" STID_HELP_FILES_HLP, "帮助文件 (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
} }

View File

@ -505,52 +505,11 @@ BOOL CALLBACK MACRO_FileExist(LPCSTR str)
void CALLBACK MACRO_FileOpen(void) void CALLBACK MACRO_FileOpen(void)
{ {
OPENFILENAME openfilename; char szFile[MAX_PATH];
CHAR szPath[MAX_PATHNAME_LEN];
CHAR szDir[MAX_PATHNAME_LEN];
CHAR szzFilter[2 * MAX_STRING_LEN + 100];
LPSTR p = szzFilter;
WINE_TRACE("()\n"); if (WINHELP_GetOpenFileName(szFile, MAX_PATH))
LoadString(Globals.hInstance, STID_HELP_FILES_HLP, p, MAX_STRING_LEN);
p += strlen(p) + 1;
lstrcpy(p, "*.hlp");
p += strlen(p) + 1;
LoadString(Globals.hInstance, STID_ALL_FILES, p, MAX_STRING_LEN);
p += strlen(p) + 1;
lstrcpy(p, "*.*");
p += strlen(p) + 1;
*p = '\0';
GetCurrentDirectory(sizeof(szDir), szDir);
szPath[0]='\0';
openfilename.lStructSize = sizeof(OPENFILENAME);
openfilename.hwndOwner = Globals.active_win->hMainWnd;
openfilename.hInstance = Globals.hInstance;
openfilename.lpstrFilter = szzFilter;
openfilename.lpstrCustomFilter = 0;
openfilename.nMaxCustFilter = 0;
openfilename.nFilterIndex = 1;
openfilename.lpstrFile = szPath;
openfilename.nMaxFile = sizeof(szPath);
openfilename.lpstrFileTitle = 0;
openfilename.nMaxFileTitle = 0;
openfilename.lpstrInitialDir = szDir;
openfilename.lpstrTitle = 0;
openfilename.Flags = 0;
openfilename.nFileOffset = 0;
openfilename.nFileExtension = 0;
openfilename.lpstrDefExt = 0;
openfilename.lCustData = 0;
openfilename.lpfnHook = 0;
openfilename.lpTemplateName = 0;
if (GetOpenFileName(&openfilename))
{ {
HLPFILE* hlpfile = WINHELP_LookupHelpFile(szPath); HLPFILE* hlpfile = WINHELP_LookupHelpFile(szFile);
WINHELP_CreateHelpWindowByHash(hlpfile, 0, WINHELP_CreateHelpWindowByHash(hlpfile, 0,
WINHELP_GetWindowInfo(hlpfile, "main"), SW_SHOWNORMAL); WINHELP_GetWindowInfo(hlpfile, "main"), SW_SHOWNORMAL);

View File

@ -31,6 +31,7 @@
#include "winbase.h" #include "winbase.h"
#include "wingdi.h" #include "wingdi.h"
#include "winuser.h" #include "winuser.h"
#include "commdlg.h"
#include "winhelp.h" #include "winhelp.h"
#include "winhelp_res.h" #include "winhelp_res.h"
#include "shellapi.h" #include "shellapi.h"
@ -56,6 +57,58 @@ static WINHELP_LINE_PART* WINHELP_IsOverLink(WINHELP_WINDOW*, WPARAM, LPARAM);
WINHELP_GLOBALS Globals = {3, NULL, NULL, 0, TRUE, NULL, NULL, NULL, NULL}; WINHELP_GLOBALS Globals = {3, NULL, NULL, 0, TRUE, NULL, NULL, NULL, NULL};
/***********************************************************************
*
* WINHELP_GetOpenFileName
*/
BOOL WINHELP_GetOpenFileName(LPSTR lpszFile, int len)
{
OPENFILENAME openfilename;
CHAR szDir[MAX_PATH];
CHAR szzFilter[2 * MAX_STRING_LEN + 100];
LPSTR p = szzFilter;
WINE_TRACE("()\n");
LoadString(Globals.hInstance, STID_HELP_FILES_HLP, p, MAX_STRING_LEN);
p += strlen(p) + 1;
lstrcpy(p, "*.hlp");
p += strlen(p) + 1;
LoadString(Globals.hInstance, STID_ALL_FILES, p, MAX_STRING_LEN);
p += strlen(p) + 1;
lstrcpy(p, "*.*");
p += strlen(p) + 1;
*p = '\0';
GetCurrentDirectory(sizeof(szDir), szDir);
lpszFile[0]='\0';
openfilename.lStructSize = sizeof(OPENFILENAME);
openfilename.hwndOwner = NULL;
openfilename.hInstance = Globals.hInstance;
openfilename.lpstrFilter = szzFilter;
openfilename.lpstrCustomFilter = 0;
openfilename.nMaxCustFilter = 0;
openfilename.nFilterIndex = 1;
openfilename.lpstrFile = lpszFile;
openfilename.nMaxFile = len;
openfilename.lpstrFileTitle = 0;
openfilename.nMaxFileTitle = 0;
openfilename.lpstrInitialDir = szDir;
openfilename.lpstrTitle = 0;
openfilename.Flags = 0;
openfilename.nFileOffset = 0;
openfilename.nFileExtension = 0;
openfilename.lpstrDefExt = 0;
openfilename.lCustData = 0;
openfilename.lpfnHook = 0;
openfilename.lpTemplateName = 0;
return GetOpenFileName(&openfilename);
}
/*********************************************************************** /***********************************************************************
* *
* WINHELP_LookupHelpFile * WINHELP_LookupHelpFile
@ -63,25 +116,20 @@ WINHELP_GLOBALS Globals = {3, NULL, NULL, 0, TRUE, NULL, NULL, NULL, NULL};
HLPFILE* WINHELP_LookupHelpFile(LPCSTR lpszFile) HLPFILE* WINHELP_LookupHelpFile(LPCSTR lpszFile)
{ {
HLPFILE* hlpfile; HLPFILE* hlpfile;
char szFullName[MAX_PATH];
hlpfile = HLPFILE_ReadHlpFile(lpszFile); if (!SearchPath(NULL, lpszFile, ".hlp", MAX_PATH, szFullName, NULL))
/* Add Suffix `.hlp' */
if (!hlpfile && lstrcmpi(lpszFile + strlen(lpszFile) - 4, ".hlp") != 0)
{ {
char szFile_hlp[MAX_PATHNAME_LEN]; if (WINHELP_MessageBoxIDS_s(STID_FILE_NOT_FOUND_s, lpszFile, STID_WHERROR,
MB_YESNO|MB_ICONQUESTION) != IDYES)
lstrcpyn(szFile_hlp, lpszFile, sizeof(szFile_hlp) - 4); return NULL;
szFile_hlp[sizeof(szFile_hlp) - 5] = '\0'; if (!WINHELP_GetOpenFileName(szFullName, MAX_PATH))
lstrcat(szFile_hlp, ".hlp"); return NULL;
hlpfile = HLPFILE_ReadHlpFile(szFile_hlp);
} }
hlpfile = HLPFILE_ReadHlpFile(szFullName);
if (!hlpfile) if (!hlpfile)
{ WINHELP_MessageBoxIDS_s(STID_HLPFILE_ERROR_s, lpszFile,
WINHELP_MessageBoxIDS_s(STID_HLPFILE_ERROR_s, lpszFile, STID_WHERROR, MB_OK); STID_WHERROR, MB_OK|MB_ICONSTOP);
if (Globals.win_list) return NULL;
}
return hlpfile; return hlpfile;
} }
@ -1815,7 +1863,7 @@ INT WINHELP_MessageBoxIDS_s(UINT ids_text, LPCSTR str, UINT ids_title, WORD type
{ {
CHAR text[MAX_STRING_LEN]; CHAR text[MAX_STRING_LEN];
CHAR title[MAX_STRING_LEN]; CHAR title[MAX_STRING_LEN];
CHAR newtext[MAX_STRING_LEN + MAX_PATHNAME_LEN]; CHAR newtext[MAX_STRING_LEN + MAX_PATH];
LoadString(Globals.hInstance, ids_text, text, sizeof(text)); LoadString(Globals.hInstance, ids_text, text, sizeof(text));
LoadString(Globals.hInstance, ids_title, title, sizeof(title)); LoadString(Globals.hInstance, ids_title, title, sizeof(title));

View File

@ -21,7 +21,6 @@
*/ */
#define MAX_LANGUAGE_NUMBER 255 #define MAX_LANGUAGE_NUMBER 255
#define MAX_PATHNAME_LEN 1024
#define MAX_STRING_LEN 255 #define MAX_STRING_LEN 255
#define INTERNAL_BORDER_WIDTH 5 #define INTERNAL_BORDER_WIDTH 5
@ -174,6 +173,7 @@ extern FARPROC Callbacks[];
BOOL WINHELP_CreateHelpWindowByHash(HLPFILE*, LONG, HLPFILE_WINDOWINFO*, int); BOOL WINHELP_CreateHelpWindowByHash(HLPFILE*, LONG, HLPFILE_WINDOWINFO*, int);
BOOL WINHELP_CreateHelpWindowByMap(HLPFILE*, LONG, HLPFILE_WINDOWINFO*, int); BOOL WINHELP_CreateHelpWindowByMap(HLPFILE*, LONG, HLPFILE_WINDOWINFO*, int);
BOOL WINHELP_CreateHelpWindow(HLPFILE_PAGE*, HLPFILE_WINDOWINFO*, int); BOOL WINHELP_CreateHelpWindow(HLPFILE_PAGE*, HLPFILE_WINDOWINFO*, int);
BOOL WINHELP_GetOpenFileName(LPSTR, int);
INT WINHELP_MessageBoxIDS(UINT, UINT, WORD); INT WINHELP_MessageBoxIDS(UINT, UINT, WORD);
INT WINHELP_MessageBoxIDS_s(UINT, LPCSTR, UINT, WORD); INT WINHELP_MessageBoxIDS_s(UINT, LPCSTR, UINT, WORD);
HLPFILE* WINHELP_LookupHelpFile(LPCSTR lpszFile); HLPFILE* WINHELP_LookupHelpFile(LPCSTR lpszFile);

View File

@ -29,3 +29,4 @@
#define STID_ALL_FILES 0x12B #define STID_ALL_FILES 0x12B
#define STID_HELP_FILES_HLP 0x12C #define STID_HELP_FILES_HLP 0x12C
#define STID_DIALOG_TEST 0x12D #define STID_DIALOG_TEST 0x12D
#define STID_FILE_NOT_FOUND_s 0x12E