[PATCH] [WinHelp]: handle more than one page listed for a given keyword
Eric Pouech
eric.pouech at orange.fr
Tue Jun 8 14:44:32 CDT 2010
A+
---
programs/winhlp32/En.rc | 11 ++++++
programs/winhlp32/Fr.rc | 11 ++++++
programs/winhlp32/winhelp.c | 69 +++++++++++++++++++++++++++++++++------
programs/winhlp32/winhelp_res.h | 2 +
4 files changed, 83 insertions(+), 10 deletions(-)
diff --git a/programs/winhlp32/En.rc b/programs/winhlp32/En.rc
index a4e9d8a..ddf6607 100644
--- a/programs/winhlp32/En.rc
+++ b/programs/winhlp32/En.rc
@@ -129,6 +129,17 @@ CAPTION "Search"
LTEXT "Not implemented yet", -1, 10, 10, 180, 150
}
+IDD_CHOOSETOPIC DIALOG DISCARDABLE 0, 0, 200, 190 LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+FONT 8, "MS Shell Dlg"
+CAPTION "Found topics"
+{
+ LTEXT "Pick-up the topic:", -1, 10, 10, 180, 22
+ LISTBOX IDC_TOPICLIST, 10, 25, 180, 130, LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_BORDER
+ PUSHBUTTON "&Show",IDOK,90,160,40,12
+ PUSHBUTTON "&Cancel",IDCANCEL,140,160,40,12
+}
+
/* Strings */
STRINGTABLE DISCARDABLE LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
{
diff --git a/programs/winhlp32/Fr.rc b/programs/winhlp32/Fr.rc
index cedb0f6..ab19d39 100644
--- a/programs/winhlp32/Fr.rc
+++ b/programs/winhlp32/Fr.rc
@@ -90,6 +90,17 @@ CAPTION "Recherche"
LTEXT "Pas encore implémenté", -1, 10, 10, 180, 150
}
+IDD_CHOOSETOPIC DIALOG DISCARDABLE 0, 0, 200, 190 LANGUAGE LANG_FRENCH, SUBLANG_DEFAULT
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+FONT 8, "MS Shell Dlg"
+CAPTION "Rubriques trouvées"
+{
+ LTEXT "Choisissez la rubrique:", -1, 10, 10, 180, 22
+ LISTBOX IDC_TOPICLIST, 10, 25, 180, 130, LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_BORDER
+ PUSHBUTTON "&Afficher",IDOK,90,160,40,12
+ PUSHBUTTON "&Annuler",IDCANCEL,140,160,40,12
+}
+
/* Strings */
STRINGTABLE DISCARDABLE LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL
{
diff --git a/programs/winhlp32/winhelp.c b/programs/winhlp32/winhelp.c
index a5a0f31..0bd88cf 100644
--- a/programs/winhlp32/winhelp.c
+++ b/programs/winhlp32/winhelp.c
@@ -1213,6 +1213,52 @@ static void cb_KWBTree(void *p, void **next, void *cookie)
*next = (char*)p + strlen((char*)p) + 7;
}
+struct choose_topic
+{
+ HLPFILE* hlpfile;
+ ULONG* topics;
+ unsigned count;
+};
+
+static INT_PTR CALLBACK WINHELP_ChooseTopicDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ {
+ struct choose_topic* ct = (struct choose_topic*)lParam;
+ unsigned i;
+ HLPFILE_PAGE* page;
+ ULONG rel;
+
+ for (i = 0; i < ct->count; i++)
+ {
+ page = HLPFILE_PageByOffset(ct->hlpfile, ct->topics[i], &rel);
+ SendDlgItemMessage(hwndDlg, IDC_TOPICLIST, LB_INSERTSTRING,
+ -1, (LPARAM)(DWORD_PTR)(page ? page->lpszTitle : ""));
+ }
+ SendDlgItemMessage(hwndDlg, IDC_TOPICLIST, LB_SETSEL, TRUE, 0);
+ }
+ return TRUE;
+ case WM_COMMAND:
+ if (LOWORD(wParam) == IDOK || wParam == MAKELONG(IDC_TOPICLIST, LBN_DBLCLK))
+ {
+ INT_PTR ret = SendDlgItemMessage(hwndDlg, IDC_TOPICLIST, LB_GETCURSEL, 0, 0);
+ EndDialog(hwndDlg, ret == LB_ERR ? -1 : ret);
+ return TRUE;
+ }
+ if (LOWORD(wParam) == IDCANCEL)
+ {
+ EndDialog(hwndDlg, -1);
+ return TRUE;
+ }
+ break;
+ default:
+ break;
+ }
+ return FALSE;
+}
+
struct index_data
{
HLPFILE* hlpfile;
@@ -1251,23 +1297,26 @@ static INT_PTR CALLBACK WINHELP_IndexDlgProc(HWND hWnd, UINT msg, WPARAM wParam,
switch (((NMHDR*)lParam)->code)
{
case PSN_APPLY:
- sel = SendDlgItemMessage(hWnd, IDC_INDEXLIST, LB_GETCURSEL, 0, 0);
- if (sel != LB_ERR)
+ if ((sel = SendDlgItemMessage(hWnd, IDC_INDEXLIST, LB_GETCURSEL, 0, 0)) != LB_ERR)
{
BYTE *p;
- int count;
+ struct choose_topic ct;
+ INT_PTR ret = 0;
p = (BYTE*)SendDlgItemMessage(hWnd, IDC_INDEXLIST,
LB_GETITEMDATA, sel, 0);
- count = *(short*)((char *)p + strlen((char *)p) + 1);
- if (count > 1)
+ p += strlen((char *)p) + 1;
+ ct.hlpfile = id->hlpfile;
+ ct.count = *(short*)p;
+ ct.topics = (ULONG*)(id->hlpfile->kwdata + 9 + *(ULONG*)(p + 2));
+ if (ct.count > 1)
{
- MessageBox(hWnd, "count > 1 not supported yet", "Error", MB_OK | MB_ICONSTOP);
- SetWindowLongPtr(hWnd, DWLP_MSGRESULT, PSNRET_INVALID);
- return TRUE;
+ ret = DialogBoxParamW(Globals.hInstance, MAKEINTRESOURCEW(IDD_CHOOSETOPIC), hWnd,
+ WINHELP_ChooseTopicDlgProc, (LPARAM)(DWORD_PTR)&ct);
+ if (ret == -1)
+ SetWindowLongPtr(hWnd, DWLP_MSGRESULT, PSNRET_INVALID);
}
- id->offset = *(ULONG*)((char *)p + strlen((char *)p) + 3);
- id->offset = *(long*)(id->hlpfile->kwdata + id->offset + 9);
+ id->offset = ct.topics[ret];
if (id->offset == 0xFFFFFFFF)
{
MessageBox(hWnd, "macro keywords not supported yet", "Error", MB_OK | MB_ICONSTOP);
diff --git a/programs/winhlp32/winhelp_res.h b/programs/winhlp32/winhelp_res.h
index ba2f979..efd9359 100644
--- a/programs/winhlp32/winhelp_res.h
+++ b/programs/winhlp32/winhelp_res.h
@@ -58,5 +58,7 @@
#define IDD_INDEX 0x150
#define IDC_INDEXLIST 0x151
#define IDD_SEARCH 0x152
+#define IDD_CHOOSETOPIC 0x153
+#define IDC_TOPICLIST 0x154
#define IDI_WINHELP 0xF00
More information about the wine-patches
mailing list