Commit 4f2819f2 authored by Kirill K. Smirnov's avatar Kirill K. Smirnov Committed by Alexandre Julliard

winhelp: Rewrite LookupHelpFile function.

Add ability for user to find file himself if winhelp cannot find it. Update resources.
parent 7dd0eaa9
......@@ -65,4 +65,5 @@ STID_HISTORY, "&"
STID_TOPICS, "&"
STID_ALL_FILES, " (*.*)"
STID_HELP_FILES_HLP, " (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -70,4 +70,5 @@ STID_HISTORY, "&Historie"
STID_TOPICS, "&Tmata"
STID_ALL_FILES, "Vechny soubory (*.*)"
STID_HELP_FILES_HLP, "Soubory npovdy (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -68,4 +68,5 @@ STID_HISTORY, "&Oversigt"
STID_TOPICS, "To&pics"
STID_ALL_FILES, "Alle filer (*.*)"
STID_HELP_FILES_HLP, "Hjlpe filer (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -67,4 +67,5 @@ STID_HISTORY, "&Bisher"
STID_TOPICS, "&Topics"
STID_ALL_FILES, "Alle Dateien (*.*)"
STID_HELP_FILES_HLP, "Hilfe-Dateien (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -66,4 +66,5 @@ STID_HISTORY, "&History"
STID_TOPICS, "&Topics"
STID_ALL_FILES, "All files (*.*)"
STID_HELP_FILES_HLP, "Help files (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -68,4 +68,5 @@ STID_HISTORY, "Krono&logio"
STID_TOPICS, "&Temoj"
STID_ALL_FILES, "Tutaj dosieroj (*.*)"
STID_HELP_FILES_HLP, "Helpaj dosieroj (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -67,4 +67,5 @@ STID_HISTORY, "&Historial"
STID_TOPICS, "&Temas"
STID_ALL_FILES, "Todos los archivos (*.*)"
STID_HELP_FILES_HLP, "Archivos de ayuda (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -68,4 +68,5 @@ STID_HISTORY, "&Luetut"
STID_TOPICS, "T&opics"
STID_ALL_FILES, "Kaikki tiedostot (*.*)"
STID_HELP_FILES_HLP, "Ohjetiedostot (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -68,4 +68,5 @@ STID_HISTORY, "&Historique"
STID_TOPICS, "&Sujets"
STID_ALL_FILES, "Tous fichiers (*.*)"
STID_HELP_FILES_HLP, "Fichiers d'aide (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -68,4 +68,5 @@ STID_HISTORY, "&Elzmny"
STID_TOPICS, "&Tmakrk"
STID_ALL_FILES, "Minden fjl (*.*)"
STID_HELP_FILES_HLP, "Sg fjlok (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -67,4 +67,5 @@ STID_HISTORY, "&Cronologia"
STID_TOPICS, "&Argomenti"
STID_ALL_FILES, "Tutti i file (*.*)"
STID_HELP_FILES_HLP, "File della Guida (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -67,4 +67,5 @@ STID_HISTORY, "히스토리(&H)"
STID_TOPICS, "&Topics"
STID_ALL_FILES, "모든 파일 (*.*)"
STID_HELP_FILES_HLP, "도움말 파일 (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -65,4 +65,5 @@ STID_HISTORY, "&Geschiedenis"
STID_TOPICS, "&Onderwerpen"
STID_ALL_FILES, "Alle bestanden (*.*)"
STID_HELP_FILES_HLP, "Helpbestanden (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -65,4 +65,5 @@ STID_HISTORY, "&Historikk"
STID_TOPICS, "&Emner"
STID_ALL_FILES, "Alle filer (*.*)"
STID_HELP_FILES_HLP, "Hjelp-filer (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -67,4 +67,5 @@ STID_HISTORY, "&Historia"
STID_TOPICS, "&Tematy"
STID_ALL_FILES, "Wszystkie pliki (*.*)"
STID_HELP_FILES_HLP, "Pliki pomocy (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -106,6 +106,7 @@ STID_HISTORY, "&Histrico"
STID_TOPICS, "&Tpicos"
STID_ALL_FILES, "Todos os arquivos (*.*)"
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
......@@ -125,4 +126,5 @@ STID_HISTORY, "&Histrico"
STID_TOPICS, "&Tpicos"
STID_ALL_FILES, "Todos os ficheiros (*.*)"
STID_HELP_FILES_HLP, "Ficheiros de ajuda (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -65,4 +65,5 @@ STID_HISTORY, "&"
STID_TOPICS, "&"
STID_ALL_FILES, " (*.*)"
STID_HELP_FILES_HLP, " (*.hlp)"
STID_FILE_NOT_FOUND_s " '%s'. ?"
}
......@@ -65,4 +65,5 @@ STID_HISTORY, "&Zgodovina"
STID_TOPICS, "&Vsebina"
STID_ALL_FILES, "Vse datiteke (*.*)"
STID_HELP_FILES_HLP, "Datoteke s pomojo (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -62,4 +62,5 @@ STID_HISTORY, "&Histria"
STID_TOPICS, "&Topics"
STID_ALL_FILES, "Vetky sbory (*.*)"
STID_HELP_FILES_HLP, "Sbory pomoci (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -68,4 +68,5 @@ STID_HISTORY, "&versikt"
STID_TOPICS, "T&opics"
STID_ALL_FILES, "Alla filer (*.*))"
STID_HELP_FILES_HLP, "Hjlp filer (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -65,4 +65,5 @@ STID_HISTORY, "Ge&mi"
STID_TOPICS, "&Konular"
STID_ALL_FILES, "Tm dosyalar (*.*)"
STID_HELP_FILES_HLP, "Yardm dosyalar (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -72,4 +72,5 @@ HISTORY, "&Fin qua"
TOPICS, "T&opics"
ALL_FILES, "Tuot las datotecas (*.*)"
HELP_FILES_HLP, "Datotecas d'agd (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -70,6 +70,7 @@ STID_HISTORY, "&Istwere"
STID_TOPICS, "&Topics"
STID_ALL_FILES, "Tos les fitchs (*.*)"
STID_HELP_FILES_HLP, "Fitchs d' aide (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
#endif /* LANG_WALON */
......@@ -66,4 +66,5 @@ STID_HISTORY, "历史(&H)"
STID_TOPICS, "主题(&T)"
STID_ALL_FILES, "所有文件 (*.*)"
STID_HELP_FILES_HLP, "帮助文件 (*.hlp)"
STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yourself?"
}
......@@ -505,52 +505,11 @@ BOOL CALLBACK MACRO_FileExist(LPCSTR str)
void CALLBACK MACRO_FileOpen(void)
{
OPENFILENAME openfilename;
CHAR szPath[MAX_PATHNAME_LEN];
CHAR szDir[MAX_PATHNAME_LEN];
CHAR szzFilter[2 * MAX_STRING_LEN + 100];
LPSTR p = szzFilter;
char szFile[MAX_PATH];
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);
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))
if (WINHELP_GetOpenFileName(szFile, MAX_PATH))
{
HLPFILE* hlpfile = WINHELP_LookupHelpFile(szPath);
HLPFILE* hlpfile = WINHELP_LookupHelpFile(szFile);
WINHELP_CreateHelpWindowByHash(hlpfile, 0,
WINHELP_GetWindowInfo(hlpfile, "main"), SW_SHOWNORMAL);
......
......@@ -31,6 +31,7 @@
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "commdlg.h"
#include "winhelp.h"
#include "winhelp_res.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_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
......@@ -63,25 +116,20 @@ WINHELP_GLOBALS Globals = {3, NULL, NULL, 0, TRUE, NULL, NULL, NULL, NULL};
HLPFILE* WINHELP_LookupHelpFile(LPCSTR lpszFile)
{
HLPFILE* hlpfile;
char szFullName[MAX_PATH];
hlpfile = HLPFILE_ReadHlpFile(lpszFile);
/* Add Suffix `.hlp' */
if (!hlpfile && lstrcmpi(lpszFile + strlen(lpszFile) - 4, ".hlp") != 0)
if (!SearchPath(NULL, lpszFile, ".hlp", MAX_PATH, szFullName, NULL))
{
char szFile_hlp[MAX_PATHNAME_LEN];
lstrcpyn(szFile_hlp, lpszFile, sizeof(szFile_hlp) - 4);
szFile_hlp[sizeof(szFile_hlp) - 5] = '\0';
lstrcat(szFile_hlp, ".hlp");
hlpfile = HLPFILE_ReadHlpFile(szFile_hlp);
if (WINHELP_MessageBoxIDS_s(STID_FILE_NOT_FOUND_s, lpszFile, STID_WHERROR,
MB_YESNO|MB_ICONQUESTION) != IDYES)
return NULL;
if (!WINHELP_GetOpenFileName(szFullName, MAX_PATH))
return NULL;
}
hlpfile = HLPFILE_ReadHlpFile(szFullName);
if (!hlpfile)
{
WINHELP_MessageBoxIDS_s(STID_HLPFILE_ERROR_s, lpszFile, STID_WHERROR, MB_OK);
if (Globals.win_list) return NULL;
}
WINHELP_MessageBoxIDS_s(STID_HLPFILE_ERROR_s, lpszFile,
STID_WHERROR, MB_OK|MB_ICONSTOP);
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 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_title, title, sizeof(title));
......
......@@ -21,7 +21,6 @@
*/
#define MAX_LANGUAGE_NUMBER 255
#define MAX_PATHNAME_LEN 1024
#define MAX_STRING_LEN 255
#define INTERNAL_BORDER_WIDTH 5
......@@ -174,6 +173,7 @@ extern FARPROC Callbacks[];
BOOL WINHELP_CreateHelpWindowByHash(HLPFILE*, LONG, HLPFILE_WINDOWINFO*, int);
BOOL WINHELP_CreateHelpWindowByMap(HLPFILE*, LONG, 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_s(UINT, LPCSTR, UINT, WORD);
HLPFILE* WINHELP_LookupHelpFile(LPCSTR lpszFile);
......
......@@ -29,3 +29,4 @@
#define STID_ALL_FILES 0x12B
#define STID_HELP_FILES_HLP 0x12C
#define STID_DIALOG_TEST 0x12D
#define STID_FILE_NOT_FOUND_s 0x12E
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment