4 * Copyright 1996 Ulrich Schmid <uschmid@mail.hh.provi.de>
5 * 2002 Sylvain Petreolle <spetreolle@yahoo.fr>
6 * 2002, 2008 Eric Pouech <eric.pouech@wanadoo.fr>
7 * 2004 Ken Belleau <jamez@ivic.qc.ca>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
36 #include "winhelp_res.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(winhelp);
44 static BOOL WINHELP_RegisterWinClasses(void);
45 static LRESULT CALLBACK WINHELP_MainWndProc(HWND, UINT, WPARAM, LPARAM);
46 static LRESULT CALLBACK WINHELP_TextWndProc(HWND, UINT, WPARAM, LPARAM);
47 static LRESULT CALLBACK WINHELP_ButtonBoxWndProc(HWND, UINT, WPARAM, LPARAM);
48 static LRESULT CALLBACK WINHELP_ButtonWndProc(HWND, UINT, WPARAM, LPARAM);
49 static LRESULT CALLBACK WINHELP_HistoryWndProc(HWND, UINT, WPARAM, LPARAM);
50 static LRESULT CALLBACK WINHELP_ShadowWndProc(HWND, UINT, WPARAM, LPARAM);
51 static BOOL WINHELP_CheckPopup(HWND, UINT, WPARAM, LPARAM, LRESULT*);
52 static BOOL WINHELP_SplitLines(HWND hWnd, LPSIZE);
53 static void WINHELP_InitFonts(HWND hWnd);
54 static void WINHELP_DeleteLines(WINHELP_WINDOW*);
55 static void WINHELP_DeleteWindow(WINHELP_WINDOW*);
56 static void WINHELP_DeleteButtons(WINHELP_WINDOW*);
57 static void WINHELP_SetupText(HWND hWnd, WINHELP_WINDOW *win, ULONG relative);
58 static void WINHELP_DeletePageLinks(HLPFILE_PAGE* page);
59 static WINHELP_LINE_PART* WINHELP_IsOverLink(WINHELP_WINDOW*, WPARAM, LPARAM);
61 WINHELP_GLOBALS Globals = {3, NULL, TRUE, NULL, NULL, NULL, NULL, NULL, {{{NULL,NULL}},0}};
63 static BOOL use_richedit;
65 #define CTL_ID_BUTTON 0x700
66 #define CTL_ID_TEXT 0x701
68 /***********************************************************************
70 * WINHELP_GetOpenFileName
72 BOOL WINHELP_GetOpenFileName(LPSTR lpszFile, int len)
74 OPENFILENAME openfilename;
76 CHAR szzFilter[2 * MAX_STRING_LEN + 100];
81 LoadString(Globals.hInstance, STID_HELP_FILES_HLP, p, MAX_STRING_LEN);
85 LoadString(Globals.hInstance, STID_ALL_FILES, p, MAX_STRING_LEN);
91 GetCurrentDirectory(sizeof(szDir), szDir);
95 openfilename.lStructSize = sizeof(OPENFILENAME);
96 openfilename.hwndOwner = NULL;
97 openfilename.hInstance = Globals.hInstance;
98 openfilename.lpstrFilter = szzFilter;
99 openfilename.lpstrCustomFilter = 0;
100 openfilename.nMaxCustFilter = 0;
101 openfilename.nFilterIndex = 1;
102 openfilename.lpstrFile = lpszFile;
103 openfilename.nMaxFile = len;
104 openfilename.lpstrFileTitle = 0;
105 openfilename.nMaxFileTitle = 0;
106 openfilename.lpstrInitialDir = szDir;
107 openfilename.lpstrTitle = 0;
108 openfilename.Flags = 0;
109 openfilename.nFileOffset = 0;
110 openfilename.nFileExtension = 0;
111 openfilename.lpstrDefExt = 0;
112 openfilename.lCustData = 0;
113 openfilename.lpfnHook = 0;
114 openfilename.lpTemplateName = 0;
116 return GetOpenFileName(&openfilename);
119 static char* WINHELP_GetCaption(WINHELP_WNDPAGE* wpage)
121 if (wpage->wininfo->caption[0]) return wpage->wininfo->caption;
122 return wpage->page->file->lpszTitle;
125 /***********************************************************************
127 * WINHELP_LookupHelpFile
129 HLPFILE* WINHELP_LookupHelpFile(LPCSTR lpszFile)
132 char szFullName[MAX_PATH];
133 char szAddPath[MAX_PATH];
137 * NOTE: This is needed by popup windows only.
138 * In other cases it's not needed but does not hurt though.
140 if (Globals.active_win && Globals.active_win->page && Globals.active_win->page->file)
142 strcpy(szAddPath, Globals.active_win->page->file->lpszPath);
143 p = strrchr(szAddPath, '\\');
148 * FIXME: Should we swap conditions?
150 if (!SearchPath(NULL, lpszFile, ".hlp", MAX_PATH, szFullName, NULL) &&
151 !SearchPath(szAddPath, lpszFile, ".hlp", MAX_PATH, szFullName, NULL))
153 if (WINHELP_MessageBoxIDS_s(STID_FILE_NOT_FOUND_s, lpszFile, STID_WHERROR,
154 MB_YESNO|MB_ICONQUESTION) != IDYES)
156 if (!WINHELP_GetOpenFileName(szFullName, MAX_PATH))
159 hlpfile = HLPFILE_ReadHlpFile(szFullName);
161 WINHELP_MessageBoxIDS_s(STID_HLPFILE_ERROR_s, lpszFile,
162 STID_WHERROR, MB_OK|MB_ICONSTOP);
166 /******************************************************************
167 * WINHELP_GetWindowInfo
171 HLPFILE_WINDOWINFO* WINHELP_GetWindowInfo(HLPFILE* hlpfile, LPCSTR name)
173 static HLPFILE_WINDOWINFO mwi;
176 if (!name || !name[0])
177 name = Globals.active_win->lpszName;
180 for (i = 0; i < hlpfile->numWindows; i++)
181 if (!strcmp(hlpfile->windows[i].name, name))
182 return &hlpfile->windows[i];
184 if (strcmp(name, "main") != 0)
186 WINE_FIXME("Couldn't find window info for %s\n", name);
192 strcpy(mwi.type, "primary");
193 strcpy(mwi.name, "main");
194 if (!LoadString(Globals.hInstance, STID_WINE_HELP,
195 mwi.caption, sizeof(mwi.caption)))
196 strcpy(mwi.caption, hlpfile->lpszTitle);
197 mwi.origin.x = mwi.origin.y = mwi.size.cx = mwi.size.cy = CW_USEDEFAULT;
199 mwi.win_style = WS_OVERLAPPEDWINDOW;
200 mwi.sr_color = mwi.sr_color = 0xFFFFFF;
205 /******************************************************************
206 * HLPFILE_GetPopupWindowInfo
210 static HLPFILE_WINDOWINFO* WINHELP_GetPopupWindowInfo(HLPFILE* hlpfile,
211 WINHELP_WINDOW* parent, LPARAM mouse)
213 static HLPFILE_WINDOWINFO wi;
217 wi.type[0] = wi.name[0] = wi.caption[0] = '\0';
219 /* Calculate horizontal size and position of a popup window */
220 GetWindowRect(parent->hMainWnd, &parent_rect);
221 wi.size.cx = (parent_rect.right - parent_rect.left) / 2;
222 wi.size.cy = 10; /* need a non null value, so that border are taken into account while computing */
224 wi.origin.x = (short)LOWORD(mouse);
225 wi.origin.y = (short)HIWORD(mouse);
226 ClientToScreen(parent->hMainWnd, &wi.origin);
227 wi.origin.x -= wi.size.cx / 2;
228 wi.origin.x = min(wi.origin.x, GetSystemMetrics(SM_CXSCREEN) - wi.size.cx);
229 wi.origin.x = max(wi.origin.x, 0);
232 wi.win_style = WS_POPUP | WS_BORDER;
233 wi.sr_color = parent->info->sr_color;
234 wi.nsr_color = 0xFFFFFF;
239 /***********************************************************************
243 int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show)
248 static CHAR default_wndname[] = "main";
249 LPSTR wndname = default_wndname;
252 Globals.hInstance = hInstance;
254 use_richedit = getenv("WINHELP_RICHEDIT") != NULL;
255 if (use_richedit && LoadLibrary("riched20.dll") == NULL)
256 return MessageBox(0, MAKEINTRESOURCE(STID_NO_RICHEDIT),
257 MAKEINTRESOURCE(STID_WHERROR), MB_OK);
260 while (*cmdline && (*cmdline == ' ' || *cmdline == '-'))
264 if (*cmdline++ == ' ') continue;
267 if (option) cmdline++;
268 while (*cmdline && *cmdline == ' ') cmdline++;
274 while (*cmdline && *cmdline != ' ') cmdline++;
275 if (*cmdline) *cmdline++ = '\0';
276 lHash = HLPFILE_Hash(topic_id);
281 Globals.wVersion = option - '0';
286 Globals.isBook = FALSE;
290 WINE_FIXME("Unsupported cmd line: %s\n", cmdline);
295 /* Create primary window */
296 if (!WINHELP_RegisterWinClasses())
298 WINE_FIXME("Couldn't register classes\n");
305 if ((*cmdline == '"') && (ptr = strchr(cmdline+1, '"')))
310 if ((ptr = strchr(cmdline, '>')))
315 hlpfile = WINHELP_LookupHelpFile(cmdline);
316 if (!hlpfile) return 0;
319 WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, lHash,
320 WINHELP_GetWindowInfo(hlpfile, wndname), show);
323 while (GetMessage(&msg, 0, 0, 0))
325 TranslateMessage(&msg);
326 DispatchMessage(&msg);
328 for (dll = Globals.dlls; dll; dll = dll->next)
330 if (dll->class & DC_INITTERM) dll->handler(DW_TERM, 0, 0);
335 /***********************************************************************
339 static BOOL WINHELP_RegisterWinClasses(void)
341 WNDCLASS class_main, class_button_box, class_text, class_shadow, class_history;
343 class_main.style = CS_HREDRAW | CS_VREDRAW;
344 class_main.lpfnWndProc = WINHELP_MainWndProc;
345 class_main.cbClsExtra = 0;
346 class_main.cbWndExtra = sizeof(LONG);
347 class_main.hInstance = Globals.hInstance;
348 class_main.hIcon = LoadIcon(Globals.hInstance, MAKEINTRESOURCE(IDI_WINHELP));
349 class_main.hCursor = LoadCursor(0, IDC_ARROW);
350 class_main.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
351 class_main.lpszMenuName = 0;
352 class_main.lpszClassName = MAIN_WIN_CLASS_NAME;
354 class_button_box = class_main;
355 class_button_box.lpfnWndProc = WINHELP_ButtonBoxWndProc;
356 class_button_box.cbWndExtra = 0;
357 class_button_box.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
358 class_button_box.lpszClassName = BUTTON_BOX_WIN_CLASS_NAME;
360 class_text = class_main;
361 class_text.lpfnWndProc = WINHELP_TextWndProc;
362 class_text.hbrBackground = 0;
363 class_text.lpszClassName = TEXT_WIN_CLASS_NAME;
365 class_shadow = class_main;
366 class_shadow.lpfnWndProc = WINHELP_ShadowWndProc;
367 class_shadow.cbWndExtra = 0;
368 class_shadow.hbrBackground = (HBRUSH)(COLOR_3DDKSHADOW+1);
369 class_shadow.lpszClassName = SHADOW_WIN_CLASS_NAME;
371 class_history = class_main;
372 class_history.lpfnWndProc = WINHELP_HistoryWndProc;
373 class_history.lpszClassName = HISTORY_WIN_CLASS_NAME;
375 return (RegisterClass(&class_main) &&
376 RegisterClass(&class_button_box) &&
377 RegisterClass(&class_text) &&
378 RegisterClass(&class_shadow) &&
379 RegisterClass(&class_history));
390 } WINHELP,*LPWINHELP;
392 /******************************************************************
393 * WINHELP_HandleCommand
397 static LRESULT WINHELP_HandleCommand(HWND hSrcWnd, LPARAM lParam)
399 COPYDATASTRUCT* cds = (COPYDATASTRUCT*)lParam;
402 if (cds->dwData != 0xA1DE505)
404 WINE_FIXME("Wrong magic number (%08lx)\n", cds->dwData);
408 wh = (WINHELP*)cds->lpData;
412 char* ptr = (wh->ofsFilename) ? (LPSTR)wh + wh->ofsFilename : NULL;
414 WINE_TRACE("Got[%u]: cmd=%u data=%08x fn=%s\n",
415 wh->size, wh->command, wh->data, ptr);
421 MACRO_JumpContext(ptr, "main", wh->data);
430 MACRO_JumpContents(ptr, "main");
433 case HELP_HELPONHELP:
436 /* case HELP_SETINDEX: */
437 case HELP_SETCONTENTS:
440 MACRO_SetContents(ptr, wh->data);
443 case HELP_CONTEXTPOPUP:
446 MACRO_PopupContext(ptr, wh->data);
449 /* case HELP_FORCEFILE:*/
450 /* case HELP_CONTEXTMENU: */
452 /* in fact, should be the topic dialog box */
453 WINE_FIXME("HELP_FINDER: stub\n");
456 MACRO_JumpHash(ptr, "main", 0);
459 /* case HELP_WM_HELP: */
460 /* case HELP_SETPOPUP_POS: */
462 /* case HELP_COMMAND: */
463 /* case HELP_PARTIALKEY: */
464 /* case HELP_MULTIKEY: */
465 /* case HELP_SETWINPOS: */
467 WINE_FIXME("Unhandled command (%x) for remote winhelp control\n", wh->command);
471 /* Always return success for now */
475 void WINHELP_LayoutMainWindow(WINHELP_WINDOW* win)
477 RECT rect, button_box_rect;
479 HWND hButtonBoxWnd = GetDlgItem(win->hMainWnd, CTL_ID_BUTTON);
480 HWND hTextWnd = GetDlgItem(win->hMainWnd, CTL_ID_TEXT);
482 GetClientRect(win->hMainWnd, &rect);
484 /* Update button box and text Window */
485 SetWindowPos(hButtonBoxWnd, HWND_TOP,
487 rect.right - rect.left,
488 rect.bottom - rect.top, 0);
490 if (GetWindowRect(hButtonBoxWnd, &button_box_rect))
491 text_top = rect.top + button_box_rect.bottom - button_box_rect.top;
493 SetWindowPos(hTextWnd, HWND_TOP,
495 rect.right - rect.left,
496 rect.bottom - text_top, 0);
500 static void WINHELP_RememberPage(WINHELP_WINDOW* win, WINHELP_WNDPAGE* wpage)
504 if (!Globals.history.index || Globals.history.set[0].page != wpage->page)
506 num = sizeof(Globals.history.set) / sizeof(Globals.history.set[0]);
507 /* we're full, remove latest entry */
508 if (Globals.history.index == num)
510 HLPFILE_FreeHlpFile(Globals.history.set[num - 1].page->file);
511 Globals.history.index--;
513 memmove(&Globals.history.set[1], &Globals.history.set[0],
514 Globals.history.index * sizeof(Globals.history.set[0]));
515 Globals.history.set[0] = *wpage;
516 Globals.history.index++;
517 wpage->page->file->wRefCount++;
519 if (win->hHistoryWnd) InvalidateRect(win->hHistoryWnd, NULL, TRUE);
521 num = sizeof(win->back.set) / sizeof(win->back.set[0]);
522 if (win->back.index == num)
524 /* we're full, remove latest entry */
525 HLPFILE_FreeHlpFile(win->back.set[0].page->file);
526 memmove(&win->back.set[0], &win->back.set[1],
527 (num - 1) * sizeof(win->back.set[0]));
530 win->back.set[win->back.index++] = *wpage;
531 wpage->page->file->wRefCount++;
534 /***********************************************************************
536 * WINHELP_CreateHelpWindow
538 BOOL WINHELP_CreateHelpWindow(WINHELP_WNDPAGE* wpage, int nCmdShow, BOOL remember)
540 WINHELP_WINDOW* win = NULL;
541 BOOL bPrimary, bPopup, bReUsed = FALSE;
544 HWND hTextWnd = NULL;
546 bPrimary = !lstrcmpi(wpage->wininfo->name, "main");
547 bPopup = !bPrimary && (wpage->wininfo->win_style & WS_POPUP);
549 if (wpage->page && !wpage->page->first_paragraph) HLPFILE_BrowsePage(wpage->page, NULL);
553 for (win = Globals.win_list; win; win = win->next)
555 if (!lstrcmpi(win->lpszName, wpage->wininfo->name))
559 DWORD flags = SWP_NOSIZE | SWP_NOMOVE;
561 WINHELP_DeleteButtons(win);
563 SetWindowText(win->hMainWnd, WINHELP_GetCaption(wpage));
564 if (wpage->wininfo->origin.x != CW_USEDEFAULT &&
565 wpage->wininfo->origin.y != CW_USEDEFAULT)
567 pt = wpage->wininfo->origin;
568 flags &= ~SWP_NOSIZE;
570 if (wpage->wininfo->size.cx != CW_USEDEFAULT &&
571 wpage->wininfo->size.cy != CW_USEDEFAULT)
573 sz = wpage->wininfo->size;
574 flags &= ~SWP_NOMOVE;
576 SetWindowPos(win->hMainWnd, HWND_TOP, pt.x, pt.y, sz.cx, sz.cy, flags);
578 if (wpage->page && wpage->page->file != win->page->file)
579 WINHELP_DeleteBackSet(win);
580 WINHELP_InitFonts(win->hMainWnd);
582 win->page = wpage->page;
583 win->info = wpage->wininfo;
584 hTextWnd = GetDlgItem(win->hMainWnd, CTL_ID_TEXT);
585 WINHELP_SetupText(hTextWnd, win, wpage->relative);
587 InvalidateRect(win->hMainWnd, NULL, TRUE);
588 if (win->hHistoryWnd) InvalidateRect(win->hHistoryWnd, NULL, TRUE);
596 /* Initialize WINHELP_WINDOW struct */
597 win = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
598 sizeof(WINHELP_WINDOW) + strlen(wpage->wininfo->name) + 1);
599 if (!win) return FALSE;
600 win->next = Globals.win_list;
601 Globals.win_list = win;
603 name = (char*)win + sizeof(WINHELP_WINDOW);
604 lstrcpy(name, wpage->wininfo->name);
605 win->lpszName = name;
606 win->hHandCur = LoadCursorW(0, (LPWSTR)IDC_HAND);
609 win->page = wpage->page;
610 win->info = wpage->wininfo;
612 win->hArrowCur = LoadCursorA(0, (LPSTR)IDC_ARROW);
613 win->hHandCur = LoadCursorA(0, (LPSTR)IDC_HAND);
615 if (!bPopup && wpage->page && remember)
617 WINHELP_RememberPage(win, wpage);
621 Globals.active_popup = win;
623 Globals.active_win = win;
625 /* Initialize default pushbuttons */
626 if (bPrimary && wpage->page)
628 CHAR buffer[MAX_STRING_LEN];
630 LoadString(Globals.hInstance, STID_CONTENTS, buffer, sizeof(buffer));
631 MACRO_CreateButton("BTN_CONTENTS", buffer, "Contents()");
632 LoadString(Globals.hInstance, STID_SEARCH,buffer, sizeof(buffer));
633 MACRO_CreateButton("BTN_SEARCH", buffer, "Search()");
634 LoadString(Globals.hInstance, STID_BACK, buffer, sizeof(buffer));
635 MACRO_CreateButton("BTN_BACK", buffer, "Back()");
636 if (win->back.index <= 1) MACRO_DisableButton("BTN_BACK");
637 LoadString(Globals.hInstance, STID_HISTORY, buffer, sizeof(buffer));
638 MACRO_CreateButton("BTN_HISTORY", buffer, "History()");
639 LoadString(Globals.hInstance, STID_TOPICS, buffer, sizeof(buffer));
640 MACRO_CreateButton("BTN_TOPICS", buffer, "Finder()");
645 win->hMainWnd = CreateWindowEx((bPopup) ? WS_EX_TOOLWINDOW : 0, MAIN_WIN_CLASS_NAME,
646 WINHELP_GetCaption(wpage),
647 bPrimary ? WS_OVERLAPPEDWINDOW : wpage->wininfo->win_style,
648 wpage->wininfo->origin.x, wpage->wininfo->origin.y,
649 wpage->wininfo->size.cx, wpage->wininfo->size.cy,
650 bPopup ? Globals.active_win->hMainWnd : NULL,
651 bPrimary ? LoadMenu(Globals.hInstance, MAKEINTRESOURCE(MAIN_MENU)) : 0,
652 Globals.hInstance, win);
654 /* Create button box and text Window */
655 CreateWindow(BUTTON_BOX_WIN_CLASS_NAME, "", WS_CHILD | WS_VISIBLE,
656 0, 0, 0, 0, win->hMainWnd, (HMENU)CTL_ID_BUTTON, Globals.hInstance, NULL);
659 hTextWnd = CreateWindow(TEXT_WIN_CLASS_NAME, "", WS_CHILD | WS_VISIBLE,
660 0, 0, 0, 0, win->hMainWnd, (HMENU)CTL_ID_TEXT, Globals.hInstance, win);
663 hTextWnd = CreateWindow(RICHEDIT_CLASS, NULL,
664 ES_MULTILINE | ES_READONLY | WS_CHILD | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE,
665 0, 0, 0, 0, win->hMainWnd, (HMENU)CTL_ID_TEXT, Globals.hInstance, NULL);
666 SendMessage(hTextWnd, EM_SETEVENTMASK, 0,
667 SendMessage(hTextWnd, EM_GETEVENTMASK, 0, 0) | ENM_MOUSEEVENTS);
671 hIcon = (wpage->page) ? wpage->page->file->hIcon : NULL;
672 if (!hIcon) hIcon = LoadIcon(Globals.hInstance, MAKEINTRESOURCE(IDI_WINHELP));
673 SendMessage(win->hMainWnd, WM_SETICON, ICON_SMALL, (DWORD_PTR)hIcon);
675 /* Initialize file specific pushbuttons */
676 if (!(wpage->wininfo->win_style & WS_POPUP) && wpage->page)
678 HLPFILE_MACRO *macro;
679 for (macro = wpage->page->file->first_macro; macro; macro = macro->next)
680 MACRO_ExecuteMacro(macro->lpszMacro);
682 for (macro = wpage->page->first_macro; macro; macro = macro->next)
683 MACRO_ExecuteMacro(macro->lpszMacro);
686 if (bPopup && use_richedit)
688 DWORD mask = SendMessage(hTextWnd, EM_GETEVENTMASK, 0, 0);
691 WINHELP_SetupText(hTextWnd, win, wpage->relative);
693 /* we need the window to be shown for richedit to compute the size */
694 ShowWindow(win->hMainWnd, nCmdShow);
695 SendMessage(hTextWnd, EM_SETEVENTMASK, 0, mask | ENM_REQUESTRESIZE);
696 SendMessage(hTextWnd, EM_REQUESTRESIZE, 0, 0);
697 SendMessage(hTextWnd, EM_SETEVENTMASK, 0, mask);
699 GetWindowRect(win->hMainWnd, &rect);
700 win->hShadowWnd = CreateWindowEx(WS_EX_TOOLWINDOW, SHADOW_WIN_CLASS_NAME,
701 "", WS_POPUP | WS_VISIBLE,
702 rect.left + SHADOW_DX, rect.top + SHADOW_DY,
703 rect.right - rect.left,
704 rect.bottom - rect.top,
705 Globals.active_win->hMainWnd, 0,
706 Globals.hInstance, NULL);
707 SetWindowPos(win->hMainWnd, win->hShadowWnd, 0, 0, 0, 0,
708 SWP_NOSIZE | SWP_NOMOVE);
712 WINHELP_SetupText(hTextWnd, win, wpage->relative);
713 WINHELP_LayoutMainWindow(win);
714 ShowWindow(win->hMainWnd, nCmdShow);
720 /******************************************************************
721 * WINHELP_OpenHelpWindow
722 * Main function to search for a page and display it in a window
724 BOOL WINHELP_OpenHelpWindow(HLPFILE_PAGE* (*lookup)(HLPFILE*, LONG, ULONG*),
725 HLPFILE* hlpfile, LONG val, HLPFILE_WINDOWINFO* wi,
728 WINHELP_WNDPAGE wpage;
730 wpage.page = lookup(hlpfile, val, &wpage.relative);
731 if (wpage.page) wpage.page->file->wRefCount++;
733 return WINHELP_CreateHelpWindow(&wpage, nCmdShow, TRUE);
736 /***********************************************************************
740 static HLPFILE_LINK* WINHELP_FindLink(WINHELP_WINDOW* win, LPARAM pos)
743 POINTL mouse_ptl, char_ptl, char_next_ptl;
746 if (!win->page) return NULL;
748 mouse_ptl.x = (short)LOWORD(pos);
749 mouse_ptl.y = (short)HIWORD(pos);
750 cp = SendMessageW(GetDlgItem(win->hMainWnd, CTL_ID_TEXT), EM_CHARFROMPOS,
751 0, (LPARAM)&mouse_ptl);
753 for (link = win->page->first_link; link; link = link->next)
755 if (link->cpMin <= cp && cp <= link->cpMax)
757 /* check whether we're at end of line */
758 SendMessageW(GetDlgItem(win->hMainWnd, CTL_ID_TEXT), EM_POSFROMCHAR,
759 (LPARAM)&char_ptl, cp);
760 SendMessageW(GetDlgItem(win->hMainWnd, CTL_ID_TEXT), EM_POSFROMCHAR,
761 (LPARAM)&char_next_ptl, cp + 1);
762 if (char_next_ptl.y != char_ptl.y || mouse_ptl.x >= char_next_ptl.x)
770 /******************************************************************
771 * WINHELP_HandleTextMouse
774 static BOOL WINHELP_HandleTextMouse(WINHELP_WINDOW* win, UINT msg, LPARAM lParam)
783 if (WINHELP_FindLink(win, lParam))
784 SetCursor(win->hHandCur);
786 SetCursor(LoadCursor(0, IDC_ARROW));
790 if ((win->current_link = WINHELP_FindLink(win, lParam)))
795 if ((link = WINHELP_FindLink(win, lParam)) && link == win->current_link)
797 HLPFILE_WINDOWINFO* wi;
799 switch (link->cookie)
802 if ((hlpfile = WINHELP_LookupHelpFile(link->string)))
804 if (link->window == -1)
806 else if ((link->window >= 0) && (link->window < hlpfile->numWindows))
807 wi = &hlpfile->windows[link->window];
810 WINE_WARN("link to window %d/%d\n", link->window, hlpfile->numWindows);
813 WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, link->hash, wi, SW_NORMAL);
817 if ((hlpfile = WINHELP_LookupHelpFile(link->string)))
818 WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, link->hash,
819 WINHELP_GetPopupWindowInfo(hlpfile, win, lParam),
823 MACRO_ExecuteMacro(link->string);
826 WINE_FIXME("Unknown link cookie %d\n", link->cookie);
830 win->current_link = NULL;
836 /***********************************************************************
838 * WINHELP_MainWndProc
840 static LRESULT CALLBACK WINHELP_MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
843 WINHELP_BUTTON *button;
845 INT curPos, min, max, dy, keyDelta;
849 if (WINHELP_CheckPopup(hWnd, msg, wParam, lParam, &ret)) return ret;
854 win = (WINHELP_WINDOW*) ((LPCREATESTRUCT) lParam)->lpCreateParams;
855 SetWindowLongPtr(hWnd, 0, (ULONG_PTR) win);
856 if (!win->page && Globals.isBook)
857 PostMessage(hWnd, WM_COMMAND, MNID_FILE_OPEN, 0);
858 win->hMainWnd = hWnd;
861 case WM_WINDOWPOSCHANGED:
862 WINHELP_LayoutMainWindow((WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0));
866 win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
870 case MNID_FILE_OPEN: MACRO_FileOpen(); break;
871 case MNID_FILE_PRINT: MACRO_Print(); break;
872 case MNID_FILE_SETUP: MACRO_PrinterSetup(); break;
873 case MNID_FILE_EXIT: MACRO_Exit(); break;
876 case MNID_EDIT_COPYDLG: MACRO_CopyDialog(); break;
877 case MNID_EDIT_ANNOTATE:MACRO_Annotate(); break;
880 case MNID_BKMK_DEFINE: MACRO_BookmarkDefine(); break;
883 case MNID_HELP_HELPON: MACRO_HelpOn(); break;
884 case MNID_HELP_HELPTOP: MACRO_HelpOnTop(); break;
885 case MNID_HELP_ABOUT: MACRO_About(); break;
886 case MNID_HELP_WINE: ShellAbout(hWnd, "WINE", "Help", 0); break;
890 for (button = win->first_button; button; button = button->next)
891 if (wParam == button->wParam) break;
893 MACRO_ExecuteMacro(button->lpszMacro);
894 else if (!HIWORD(wParam))
895 MessageBox(0, MAKEINTRESOURCE(STID_NOT_IMPLEMENTED),
896 MAKEINTRESOURCE(STID_WHERROR), MB_OK);
900 /* EPP case WM_DESTROY: */
901 /* EPP if (Globals.hPopupWnd) DestroyWindow(Globals.hPopupWnd); */
904 return WINHELP_HandleCommand((HWND)wParam, lParam);
913 keyDelta = GetSystemMetrics(SM_CXVSCROLL);
915 keyDelta = -keyDelta;
919 win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
920 hTextWnd = GetDlgItem(win->hMainWnd, CTL_ID_TEXT);
921 curPos = GetScrollPos(hTextWnd, SB_VERT);
922 GetScrollRange(hTextWnd, SB_VERT, &min, &max);
926 GetClientRect(hTextWnd, &rect);
927 keyDelta = (rect.bottom - rect.top) / 2;
928 if (wParam == VK_PRIOR)
929 keyDelta = -keyDelta;
935 else if (curPos < min)
938 dy = GetScrollPos(hTextWnd, SB_VERT) - curPos;
939 SetScrollPos(hTextWnd, SB_VERT, curPos, TRUE);
940 ScrollWindow(hTextWnd, 0, dy, NULL, NULL);
941 UpdateWindow(hTextWnd);
951 if (wParam == CTL_ID_TEXT)
955 switch (((NMHDR*)lParam)->code)
959 const MSGFILTER* msgf = (const MSGFILTER*)lParam;
960 return WINHELP_HandleTextMouse((WINHELP_WINDOW*)GetWindowLong(hWnd, 0),
961 msgf->msg, msgf->lParam);
965 case EN_REQUESTRESIZE:
966 rc = ((REQRESIZE*)lParam)->rc;
967 win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
968 AdjustWindowRect(&rc, GetWindowLong(win->hMainWnd, GWL_STYLE),
970 SetWindowPos(win->hMainWnd, HWND_TOP, 0, 0,
971 rc.right - rc.left, rc.bottom - rc.top,
972 SWP_NOMOVE | SWP_NOZORDER);
973 WINHELP_LayoutMainWindow(win);
982 win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
983 bExit = (Globals.wVersion >= 4 && !lstrcmpi(win->lpszName, "main"));
984 WINHELP_DeleteWindow(win);
986 if (bExit) MACRO_Exit();
987 if (!Globals.win_list)
992 return DefWindowProc(hWnd, msg, wParam, lParam);
995 static DWORD CALLBACK WINHELP_RtfStreamIn(DWORD_PTR cookie, BYTE* buff,
998 struct RtfData* rd = (struct RtfData*)cookie;
1000 if (rd->where >= rd->ptr) return 1;
1001 if (rd->where + cb > rd->ptr)
1002 cb = rd->ptr - rd->where;
1003 memcpy(buff, rd->where, cb);
1009 static void WINHELP_FillRichEdit(HWND hTextWnd, WINHELP_WINDOW *win, ULONG relative)
1011 SendMessage(hTextWnd, WM_SETREDRAW, FALSE, 0);
1012 SendMessage(hTextWnd, EM_SETBKGNDCOLOR, 0, (LPARAM)win->info->sr_color);
1013 /* set word-wrap to window size (undocumented) */
1014 SendMessage(hTextWnd, EM_SETTARGETDEVICE, 0, 0);
1020 if (HLPFILE_BrowsePage(win->page, &rd))
1023 es.dwCookie = (DWORD_PTR)&rd;
1025 es.pfnCallback = WINHELP_RtfStreamIn;
1027 SendMessageW(hTextWnd, EM_STREAMIN, SF_RTF, (LPARAM)&es);
1029 /* FIXME: else leaking potentially the rd.first_link chain */
1030 HeapFree(GetProcessHeap(), 0, rd.data);
1034 SendMessage(hTextWnd, WM_SETTEXT, 0, (LPARAM)"");
1036 SendMessage(hTextWnd, WM_SETREDRAW, TRUE, 0);
1037 SendMessage(hTextWnd, EM_SETSEL, 0, 0);
1038 SendMessage(hTextWnd, EM_SCROLLCARET, 0, 0);
1039 InvalidateRect(hTextWnd, NULL, TRUE);
1042 /***********************************************************************
1044 * WINHELP_ButtonBoxWndProc
1046 static LRESULT CALLBACK WINHELP_ButtonBoxWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
1049 WINHELP_WINDOW *win;
1050 WINHELP_BUTTON *button;
1054 if (WINHELP_CheckPopup(hWnd, msg, wParam, lParam, NULL)) return 0L;
1058 case WM_WINDOWPOSCHANGING:
1059 winpos = (WINDOWPOS*) lParam;
1060 win = (WINHELP_WINDOW*) GetWindowLongPtr(GetParent(hWnd), 0);
1062 /* Update buttons */
1065 for (button = win->first_button; button; button = button->next)
1071 button->hWnd = CreateWindow(STRING_BUTTON, button->lpszName,
1072 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
1074 hWnd, (HMENU) button->wParam,
1075 Globals.hInstance, 0);
1077 if (Globals.button_proc == NULL)
1078 Globals.button_proc = (WNDPROC) GetWindowLongPtr(button->hWnd, GWLP_WNDPROC);
1079 SetWindowLongPtr(button->hWnd, GWLP_WNDPROC, (LONG_PTR) WINHELP_ButtonWndProc);
1082 hDc = GetDC(button->hWnd);
1083 GetTextExtentPoint(hDc, button->lpszName,
1084 lstrlen(button->lpszName), &textsize);
1085 ReleaseDC(button->hWnd, hDc);
1087 button_size.cx = max(button_size.cx, textsize.cx + BUTTON_CX);
1088 button_size.cy = max(button_size.cy, textsize.cy + BUTTON_CY);
1093 for (button = win->first_button; button; button = button->next)
1095 SetWindowPos(button->hWnd, HWND_TOP, x, y, button_size.cx, button_size.cy, 0);
1097 if (x + 2 * button_size.cx <= winpos->cx)
1098 x += button_size.cx;
1100 x = 0, y += button_size.cy;
1102 winpos->cy = y + (x ? button_size.cy : 0);
1106 SendMessage(GetParent(hWnd), msg, wParam, lParam);
1117 return SendMessage(GetParent(hWnd), msg, wParam, lParam);
1122 return DefWindowProc(hWnd, msg, wParam, lParam);
1125 /***********************************************************************
1127 * WINHELP_ButtonWndProc
1129 static LRESULT CALLBACK WINHELP_ButtonWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
1131 if (WINHELP_CheckPopup(hWnd, msg, wParam, lParam, NULL)) return 0;
1133 if (msg == WM_KEYDOWN)
1142 return SendMessage(GetParent(hWnd), msg, wParam, lParam);
1146 return CallWindowProc(Globals.button_proc, hWnd, msg, wParam, lParam);
1149 /***********************************************************************
1151 * WINHELP_TextWndProc
1153 static LRESULT CALLBACK WINHELP_TextWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
1155 WINHELP_WINDOW *win;
1157 WINHELP_LINE_PART *part;
1164 if (msg != WM_LBUTTONDOWN)
1165 WINHELP_CheckPopup(hWnd, msg, wParam, lParam, NULL);
1170 win = (WINHELP_WINDOW*) ((LPCREATESTRUCT) lParam)->lpCreateParams;
1171 SetWindowLongPtr(hWnd, 0, (ULONG_PTR) win);
1172 win->hBrush = CreateSolidBrush(win->info->sr_color);
1173 WINHELP_InitFonts(hWnd);
1177 win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
1179 /* Calculate vertical size and position of a popup window */
1180 if (win->info->win_style & WS_POPUP)
1183 RECT old_window_rect;
1184 RECT old_client_rect;
1185 SIZE old_window_size;
1186 SIZE old_client_size;
1187 SIZE new_client_size;
1188 SIZE new_window_size;
1190 GetWindowRect(GetParent(hWnd), &old_window_rect);
1191 origin.x = old_window_rect.left;
1192 origin.y = old_window_rect.top;
1193 old_window_size.cx = old_window_rect.right - old_window_rect.left;
1194 old_window_size.cy = old_window_rect.bottom - old_window_rect.top;
1196 WINHELP_LayoutMainWindow(win);
1197 GetClientRect(hWnd, &old_client_rect);
1198 old_client_size.cx = old_client_rect.right - old_client_rect.left;
1199 old_client_size.cy = old_client_rect.bottom - old_client_rect.top;
1201 new_client_size = old_client_size;
1202 WINHELP_SplitLines(hWnd, &new_client_size);
1204 if (origin.y + POPUP_YDISTANCE + new_client_size.cy <= GetSystemMetrics(SM_CYSCREEN))
1205 origin.y += POPUP_YDISTANCE;
1207 origin.y -= POPUP_YDISTANCE + new_client_size.cy;
1209 new_window_size.cx = old_window_size.cx - old_client_size.cx + new_client_size.cx;
1210 new_window_size.cy = old_window_size.cy - old_client_size.cy + new_client_size.cy;
1213 CreateWindowEx(WS_EX_TOOLWINDOW, SHADOW_WIN_CLASS_NAME, "", WS_POPUP,
1214 origin.x + SHADOW_DX, origin.y + SHADOW_DY,
1215 new_window_size.cx, new_window_size.cy,
1216 0, 0, Globals.hInstance, 0);
1218 SetWindowPos(GetParent(hWnd), HWND_TOP, origin.x, origin.y,
1219 new_window_size.cx, new_window_size.cy,
1221 SetWindowPos(win->hShadowWnd, hWnd, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
1222 ShowWindow(win->hShadowWnd, SW_NORMAL);
1223 SetActiveWindow(hWnd);
1227 case WM_WINDOWPOSCHANGED:
1228 winpos = (WINDOWPOS*) lParam;
1230 if (!(winpos->flags & SWP_NOSIZE)) WINHELP_SetupText(hWnd, NULL, 0);
1236 UINT scrollLines = 3;
1237 int curPos = GetScrollPos(hWnd, SB_VERT);
1240 GetScrollRange(hWnd, SB_VERT, &min, &max);
1242 SystemParametersInfo(SPI_GETWHEELSCROLLLINES,0, &scrollLines, 0);
1243 if (wParam & (MK_SHIFT | MK_CONTROL))
1244 return DefWindowProc(hWnd, msg, wParam, lParam);
1245 wheelDelta -= GET_WHEEL_DELTA_WPARAM(wParam);
1246 if (abs(wheelDelta) >= WHEEL_DELTA && scrollLines) {
1249 curPos += wheelDelta;
1252 else if (curPos < min)
1255 dy = GetScrollPos(hWnd, SB_VERT) - curPos;
1256 SetScrollPos(hWnd, SB_VERT, curPos, TRUE);
1257 ScrollWindow(hWnd, 0, dy, NULL, NULL);
1268 INT CurPos = GetScrollPos(hWnd, SB_VERT);
1271 GetScrollRange(hWnd, SB_VERT, &Min, &Max);
1272 GetClientRect(hWnd, &rect);
1274 switch (wParam & 0xffff)
1277 case SB_THUMBPOSITION: CurPos = wParam >> 16; break;
1278 case SB_TOP: CurPos = Min; break;
1279 case SB_BOTTOM: CurPos = Max; break;
1280 case SB_PAGEUP: CurPos -= (rect.bottom - rect.top) / 2; break;
1281 case SB_PAGEDOWN: CurPos += (rect.bottom - rect.top) / 2; break;
1282 case SB_LINEUP: CurPos -= GetSystemMetrics(SM_CXVSCROLL); break;
1283 case SB_LINEDOWN: CurPos += GetSystemMetrics(SM_CXVSCROLL); break;
1284 default: update = FALSE;
1290 else if (CurPos < Min)
1292 dy = GetScrollPos(hWnd, SB_VERT) - CurPos;
1293 SetScrollPos(hWnd, SB_VERT, CurPos, TRUE);
1294 ScrollWindow(hWnd, 0, dy, NULL, NULL);
1301 hDc = BeginPaint(hWnd, &ps);
1302 win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
1303 scroll_pos = GetScrollPos(hWnd, SB_VERT);
1305 /* No DPtoLP needed - MM_TEXT map mode */
1306 if (ps.fErase) FillRect(hDc, &ps.rcPaint, win->hBrush);
1307 for (line = win->first_line; line; line = line->next)
1309 for (part = &line->first_part; part; part = part->next)
1311 switch (part->cookie)
1313 case hlp_line_part_text:
1314 SelectObject(hDc, part->u.text.hFont);
1315 SetTextColor(hDc, part->u.text.color);
1316 SetBkColor(hDc, win->info->sr_color);
1317 TextOut(hDc, part->rect.left, part->rect.top - scroll_pos,
1318 part->u.text.lpsText, part->u.text.wTextLen);
1319 if (part->u.text.wUnderline)
1323 switch (part->u.text.wUnderline)
1325 case 1: /* simple */
1326 case 2: /* double */
1327 hPen = CreatePen(PS_SOLID, 1, part->u.text.color);
1329 case 3: /* dotted */
1330 hPen = CreatePen(PS_DOT, 1, part->u.text.color);
1333 WINE_FIXME("Unknow underline type\n");
1337 SelectObject(hDc, hPen);
1338 MoveToEx(hDc, part->rect.left, part->rect.bottom - scroll_pos - 1, NULL);
1339 LineTo(hDc, part->rect.right, part->rect.bottom - scroll_pos - 1);
1340 if (part->u.text.wUnderline == 2)
1342 MoveToEx(hDc, part->rect.left, part->rect.bottom - scroll_pos + 1, NULL);
1343 LineTo(hDc, part->rect.right, part->rect.bottom - scroll_pos + 1);
1348 case hlp_line_part_bitmap:
1352 hMemDC = CreateCompatibleDC(hDc);
1353 SelectObject(hMemDC, part->u.bitmap.hBitmap);
1354 BitBlt(hDc, part->rect.left, part->rect.top - scroll_pos,
1355 part->rect.right - part->rect.left, part->rect.bottom - part->rect.top,
1356 hMemDC, 0, 0, SRCCOPY);
1360 case hlp_line_part_metafile:
1367 sz.cx = part->rect.right - part->rect.left;
1368 sz.cy = part->rect.bottom - part->rect.top;
1369 hMemDC = CreateCompatibleDC(hDc);
1370 hBitmap = CreateCompatibleBitmap(hDc, sz.cx, sz.cy);
1371 SelectObject(hMemDC, hBitmap);
1372 SelectObject(hMemDC, win->hBrush);
1377 FillRect(hMemDC, &rc, win->hBrush);
1378 SetMapMode(hMemDC, part->u.metafile.mm);
1379 SetWindowExtEx(hMemDC, sz.cx, sz.cy, 0);
1380 SetViewportExtEx(hMemDC, sz.cx, sz.cy, 0);
1381 SetWindowOrgEx(hMemDC, 0, 0, 0);
1382 SetViewportOrgEx(hMemDC, 0, 0, 0);
1383 PlayMetaFile(hMemDC, part->u.metafile.hMetaFile);
1384 SetMapMode(hMemDC, MM_TEXT);
1385 SetWindowOrgEx(hMemDC, 0, 0, 0);
1386 SetViewportOrgEx(hMemDC, 0, 0, 0);
1387 BitBlt(hDc, part->rect.left, part->rect.top - scroll_pos,
1388 sz.cx, sz.cy, hMemDC, 0, 0, SRCCOPY);
1390 DeleteObject(hBitmap);
1397 EndPaint(hWnd, &ps);
1401 win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
1403 if (WINHELP_IsOverLink(win, wParam, lParam))
1404 SetCursor(win->hHandCur); /* set to hand pointer cursor to indicate a link */
1406 SetCursor(win->hArrowCur); /* set to hand pointer cursor to indicate a link */
1410 case WM_LBUTTONDOWN:
1411 win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
1413 if (Globals.active_popup)
1415 hPopupWnd = Globals.active_popup->hMainWnd;
1416 Globals.active_popup = NULL;
1418 else hPopupWnd = NULL;
1420 part = WINHELP_IsOverLink(win, wParam, lParam);
1424 HLPFILE_WINDOWINFO* wi;
1426 if (part->link) switch (part->link->cookie)
1429 hlpfile = WINHELP_LookupHelpFile(part->link->string);
1430 if (part->link->window == -1)
1432 else if (part->link->window < hlpfile->numWindows)
1433 wi = &hlpfile->windows[part->link->window];
1436 WINE_WARN("link to window %d/%d\n", part->link->window, hlpfile->numWindows);
1439 WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, part->link->hash,
1442 case hlp_link_popup:
1443 hlpfile = WINHELP_LookupHelpFile(part->link->string);
1444 if (hlpfile) WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, part->link->hash,
1445 WINHELP_GetPopupWindowInfo(hlpfile, win, lParam),
1448 case hlp_link_macro:
1449 MACRO_ExecuteMacro(part->link->string);
1452 WINE_FIXME("Unknown link cookie %d\n", part->link->cookie);
1457 DestroyWindow(hPopupWnd);
1462 return DefWindowProc(hWnd, msg, wParam, lParam);
1465 /******************************************************************
1466 * WINHELP_HistoryWndProc
1470 static LRESULT CALLBACK WINHELP_HistoryWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
1472 WINHELP_WINDOW* win;
1482 win = (WINHELP_WINDOW*)((LPCREATESTRUCT)lParam)->lpCreateParams;
1483 SetWindowLongPtr(hWnd, 0, (ULONG_PTR)win);
1484 win->hHistoryWnd = hWnd;
1487 win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
1489 GetTextMetrics(hDc, &tm);
1490 GetWindowRect(hWnd, &r);
1492 r.right = r.left + 30 * tm.tmAveCharWidth;
1493 r.bottom = r.top + (sizeof(Globals.history.set) / sizeof(Globals.history.set[0])) * tm.tmHeight;
1494 AdjustWindowRect(&r, GetWindowLong(hWnd, GWL_STYLE), FALSE);
1495 if (r.left < 0) {r.right -= r.left; r.left = 0;}
1496 if (r.top < 0) {r.bottom -= r.top; r.top = 0;}
1498 MoveWindow(hWnd, r.left, r.top, r.right, r.bottom, TRUE);
1499 ReleaseDC(hWnd, hDc);
1501 case WM_LBUTTONDOWN:
1502 win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
1504 GetTextMetrics(hDc, &tm);
1505 i = HIWORD(lParam) / tm.tmHeight;
1506 if (i < Globals.history.index)
1507 WINHELP_CreateHelpWindow(&Globals.history.set[i], SW_SHOW, TRUE);
1508 ReleaseDC(hWnd, hDc);
1511 hDc = BeginPaint(hWnd, &ps);
1512 win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
1513 GetTextMetrics(hDc, &tm);
1515 for (i = 0; i < Globals.history.index; i++)
1517 if (Globals.history.set[i].page->file == Globals.active_win->page->file)
1519 TextOut(hDc, 0, i * tm.tmHeight,
1520 Globals.history.set[i].page->lpszTitle,
1521 strlen(Globals.history.set[i].page->lpszTitle));
1530 ptr1 = strrchr(Globals.history.set[i].page->file->lpszPath, '\\');
1531 if (!ptr1) ptr1 = Globals.history.set[i].page->file->lpszPath;
1533 ptr2 = strrchr(ptr1, '.');
1534 len = ptr2 ? ptr2 - ptr1 : strlen(ptr1);
1535 if (len > sizeof(buffer)) len = sizeof(buffer);
1536 memcpy(buffer, ptr1, len);
1537 if (len < sizeof(buffer)) buffer[len++] = ':';
1538 strncpy(&buffer[len], Globals.history.set[i].page->lpszTitle, sizeof(buffer) - len);
1539 buffer[sizeof(buffer) - 1] = '\0';
1540 TextOut(hDc, 0, i * tm.tmHeight, buffer, strlen(buffer));
1543 EndPaint(hWnd, &ps);
1546 win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
1547 if (hWnd == win->hHistoryWnd)
1548 win->hHistoryWnd = 0;
1551 return DefWindowProc(hWnd, msg, wParam, lParam);
1554 /***********************************************************************
1556 * WINHELP_ShadowWndProc
1558 static LRESULT CALLBACK WINHELP_ShadowWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
1560 if (WINHELP_CheckPopup(hWnd, msg, wParam, lParam, NULL)) return 0;
1561 return WINHELP_CheckPopup(hWnd, msg, wParam, lParam, NULL) ? 0L : DefWindowProc(hWnd, msg, wParam, lParam);
1564 /***********************************************************************
1568 static void WINHELP_SetupText(HWND hWnd, WINHELP_WINDOW* win, ULONG relative)
1574 if (!win) win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
1575 if (use_richedit) return WINHELP_FillRichEdit(hWnd, win, relative);
1577 ShowScrollBar(hWnd, SB_VERT, FALSE);
1578 if (!WINHELP_SplitLines(hWnd, NULL))
1580 ShowScrollBar(hWnd, SB_VERT, TRUE);
1581 GetClientRect(hWnd, &rect);
1583 WINHELP_SplitLines(hWnd, &newsize);
1584 SetScrollRange(hWnd, SB_VERT, 0, rect.top + newsize.cy - rect.bottom, TRUE);
1588 SetScrollPos(hWnd, SB_VERT, 0, FALSE);
1589 SetScrollRange(hWnd, SB_VERT, 0, 0, FALSE);
1592 ReleaseDC(hWnd, hDc);
1595 /***********************************************************************
1597 * WINHELP_AppendText
1599 static BOOL WINHELP_AppendText(WINHELP_LINE ***linep, WINHELP_LINE_PART ***partp,
1600 LPSIZE space, LPSIZE textsize,
1601 INT *line_ascent, INT ascent,
1602 LPCSTR text, UINT textlen,
1603 HFONT font, COLORREF color, HLPFILE_LINK *link,
1607 WINHELP_LINE_PART *part;
1610 if (!*partp) /* New line */
1612 *line_ascent = ascent;
1614 line = HeapAlloc(GetProcessHeap(), 0,
1615 sizeof(WINHELP_LINE) + textlen);
1616 if (!line) return FALSE;
1619 part = &line->first_part;
1620 ptr = (char*)line + sizeof(WINHELP_LINE);
1622 line->rect.top = (**linep ? (**linep)->rect.bottom : 0) + space->cy;
1623 line->rect.bottom = line->rect.top;
1624 line->rect.left = space->cx;
1625 line->rect.right = space->cx;
1627 if (**linep) *linep = &(**linep)->next;
1631 else /* Same line */
1635 if (*line_ascent < ascent)
1637 WINHELP_LINE_PART *p;
1638 for (p = &line->first_part; p; p = p->next)
1640 p->rect.top += ascent - *line_ascent;
1641 p->rect.bottom += ascent - *line_ascent;
1643 line->rect.bottom += ascent - *line_ascent;
1644 *line_ascent = ascent;
1647 part = HeapAlloc(GetProcessHeap(), 0,
1648 sizeof(WINHELP_LINE_PART) + textlen);
1649 if (!part) return FALSE;
1651 ptr = (char*)part + sizeof(WINHELP_LINE_PART);
1654 memcpy(ptr, text, textlen);
1655 part->cookie = hlp_line_part_text;
1656 part->rect.left = line->rect.right + (*partp ? space->cx : 0);
1657 part->rect.right = part->rect.left + textsize->cx;
1658 line->rect.right = part->rect.right;
1660 ((*partp) ? line->rect.top : line->rect.bottom) + *line_ascent - ascent;
1661 part->rect.bottom = part->rect.top + textsize->cy;
1662 line->rect.bottom = max(line->rect.bottom, part->rect.bottom);
1663 part->u.text.lpsText = ptr;
1664 part->u.text.wTextLen = textlen;
1665 part->u.text.hFont = font;
1666 part->u.text.color = color;
1667 part->u.text.wUnderline = underline;
1669 WINE_TRACE("Appended text '%*.*s'[%d] @ (%d,%d-%d,%d)\n",
1670 part->u.text.wTextLen,
1671 part->u.text.wTextLen,
1672 part->u.text.lpsText,
1673 part->u.text.wTextLen,
1674 part->rect.left, part->rect.top, part->rect.right, part->rect.bottom);
1677 if (link) link->wRefCount++;
1680 *partp = &part->next;
1687 /***********************************************************************
1689 * WINHELP_AppendGfxObject
1691 static WINHELP_LINE_PART* WINHELP_AppendGfxObject(WINHELP_LINE ***linep, WINHELP_LINE_PART ***partp,
1692 LPSIZE space, LPSIZE gfxSize,
1693 HLPFILE_LINK *link, unsigned pos)
1696 WINHELP_LINE_PART *part;
1699 if (!*partp || pos == 1) /* New line */
1701 line = HeapAlloc(GetProcessHeap(), 0, sizeof(WINHELP_LINE));
1702 if (!line) return NULL;
1705 part = &line->first_part;
1707 line->rect.top = (**linep ? (**linep)->rect.bottom : 0) + space->cy;
1708 line->rect.bottom = line->rect.top;
1709 line->rect.left = space->cx;
1710 line->rect.right = space->cx;
1712 if (**linep) *linep = &(**linep)->next;
1715 ptr = (char*)line + sizeof(WINHELP_LINE);
1717 else /* Same line */
1719 if (pos == 2) WINE_FIXME("Left alignment not handled\n");
1722 part = HeapAlloc(GetProcessHeap(), 0, sizeof(WINHELP_LINE_PART));
1723 if (!part) return NULL;
1725 ptr = (char*)part + sizeof(WINHELP_LINE_PART);
1728 /* part->cookie should be set by caller (image or metafile) */
1729 part->rect.left = line->rect.right + (*partp ? space->cx : 0);
1730 part->rect.right = part->rect.left + gfxSize->cx;
1731 line->rect.right = part->rect.right;
1732 part->rect.top = (*partp) ? line->rect.top : line->rect.bottom;
1733 part->rect.bottom = part->rect.top + gfxSize->cy;
1734 line->rect.bottom = max(line->rect.bottom, part->rect.bottom);
1736 WINE_TRACE("Appended gfx @ (%d,%d-%d,%d)\n",
1737 part->rect.left, part->rect.top, part->rect.right, part->rect.bottom);
1740 if (link) link->wRefCount++;
1743 *partp = &part->next;
1751 /***********************************************************************
1753 * WINHELP_SplitLines
1755 static BOOL WINHELP_SplitLines(HWND hWnd, LPSIZE newsize)
1757 WINHELP_WINDOW *win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
1758 HLPFILE_PARAGRAPH *p;
1759 WINHELP_LINE **line = &win->first_line;
1760 WINHELP_LINE_PART **part = 0;
1761 INT line_ascent = 0;
1766 if (newsize) newsize->cx = newsize->cy = 0;
1768 if (!win->page) return TRUE;
1770 WINHELP_DeleteLines(win);
1772 GetClientRect(hWnd, &rect);
1774 rect.top += INTERNAL_BORDER_WIDTH;
1775 rect.left += INTERNAL_BORDER_WIDTH;
1776 rect.right -= INTERNAL_BORDER_WIDTH;
1777 rect.bottom -= INTERNAL_BORDER_WIDTH;
1779 space.cy = rect.top;
1780 space.cx = rect.left;
1784 for (p = win->page->first_paragraph; p; p = p->next)
1788 case para_normal_text:
1789 case para_debug_text:
1792 SIZE textsize = {0, 0};
1793 LPCSTR text = p->u.text.lpszText;
1795 UINT len = strlen(text);
1796 unsigned underline = 0;
1799 COLORREF color = RGB(0, 0, 0);
1801 if (p->u.text.wFont < win->page->file->numFonts)
1803 HLPFILE* hlpfile = win->page->file;
1805 if (!hlpfile->fonts[p->u.text.wFont].hFont)
1807 LOGFONT lf = hlpfile->fonts[p->u.text.wFont].LogFont;
1808 lf.lfHeight = -lf.lfHeight / 2 - 3;
1809 hlpfile->fonts[p->u.text.wFont].hFont = CreateFontIndirect(&lf);
1811 hFont = hlpfile->fonts[p->u.text.wFont].hFont;
1812 color = hlpfile->fonts[p->u.text.wFont].color;
1816 UINT wFont = (p->u.text.wFont < win->fonts_len) ? p->u.text.wFont : 0;
1818 hFont = win->fonts[wFont];
1821 if (p->link && p->link->bClrChange)
1823 underline = (p->link->cookie == hlp_link_popup) ? 3 : 1;
1824 color = RGB(0, 0x80, 0);
1826 if (p->cookie == para_debug_text) color = RGB(0xff, 0, 0);
1828 SelectObject(hDc, hFont);
1830 GetTextMetrics(hDc, &tm);
1832 if (p->u.text.wIndent)
1834 indent = p->u.text.wIndent * 5 * tm.tmAveCharWidth;
1836 space.cx = rect.left + indent - 2 * tm.tmAveCharWidth;
1839 if (p->u.text.wVSpace)
1842 space.cx = rect.left + indent;
1843 space.cy += (p->u.text.wVSpace - 1) * tm.tmHeight;
1846 if (p->u.text.wHSpace)
1848 space.cx += p->u.text.wHSpace * 2 * tm.tmAveCharWidth;
1851 WINE_TRACE("splitting text %s\n", text);
1855 INT free_width = rect.right - (part ? (*line)->rect.right : rect.left) - space.cx;
1856 UINT low = 0, curr = len, high = len, textlen = 0;
1862 GetTextExtentPoint(hDc, text, curr, &textsize);
1864 if (textsize.cx <= free_width) low = curr;
1867 if (high <= low + 1) break;
1869 if (textsize.cx) curr = (curr * free_width) / textsize.cx;
1870 if (curr <= low) curr = low + 1;
1871 else if (curr >= high) curr = high - 1;
1874 while (textlen && text[textlen] && text[textlen] != ' ') textlen--;
1876 if (!part && !textlen) textlen = max(low, 1);
1878 if (free_width <= 0 || !textlen)
1881 space.cx = rect.left + indent;
1882 space.cx = min(space.cx, rect.right - rect.left - 1);
1886 WINE_TRACE("\t => %d %*s\n", textlen, textlen, text);
1888 if (!WINHELP_AppendText(&line, &part, &space, &textsize,
1889 &line_ascent, tm.tmAscent,
1890 text, textlen, hFont, color, p->link, underline) ||
1891 (!newsize && (*line)->rect.bottom > rect.bottom))
1893 ReleaseDC(hWnd, hDc);
1898 newsize->cx = max(newsize->cx, (*line)->rect.right + INTERNAL_BORDER_WIDTH);
1902 if (text[0] == ' ') text++, len--;
1911 WINHELP_LINE_PART* ref_part;
1913 if (p->u.gfx.pos & 0x8000)
1915 space.cx = rect.left;
1917 space.cy += (*line)->rect.bottom - (*line)->rect.top;
1921 if (p->cookie == para_bitmap)
1925 GetObject(p->u.gfx.u.bmp.hBitmap, sizeof(dibs), &dibs);
1926 gfxSize.cx = dibs.dsBm.bmWidth;
1927 gfxSize.cy = dibs.dsBm.bmHeight;
1931 LPMETAFILEPICT lpmfp = &p->u.gfx.u.mfp;
1932 if (lpmfp->mm == MM_ANISOTROPIC || lpmfp->mm == MM_ISOTROPIC)
1934 gfxSize.cx = MulDiv(lpmfp->xExt, GetDeviceCaps(hDc, HORZRES),
1935 100*GetDeviceCaps(hDc, HORZSIZE));
1936 gfxSize.cy = MulDiv(lpmfp->yExt, GetDeviceCaps(hDc, VERTRES),
1937 100*GetDeviceCaps(hDc, VERTSIZE));
1941 gfxSize.cx = lpmfp->xExt;
1942 gfxSize.cy = lpmfp->yExt;
1946 free_width = rect.right - ((part && *line) ? (*line)->rect.right : rect.left) - space.cx;
1947 if (free_width <= 0)
1950 space.cx = rect.left;
1951 space.cx = min(space.cx, rect.right - rect.left - 1);
1953 ref_part = WINHELP_AppendGfxObject(&line, &part, &space, &gfxSize,
1954 p->link, p->u.gfx.pos);
1955 if (!ref_part || (!newsize && (*line)->rect.bottom > rect.bottom))
1959 if (p->cookie == para_bitmap)
1961 ref_part->cookie = hlp_line_part_bitmap;
1962 ref_part->u.bitmap.hBitmap = p->u.gfx.u.bmp.hBitmap;
1966 ref_part->cookie = hlp_line_part_metafile;
1967 ref_part->u.metafile.hMetaFile = p->u.gfx.u.mfp.hMF;
1968 ref_part->u.metafile.mm = p->u.gfx.u.mfp.mm;
1976 newsize->cy = (*line)->rect.bottom + INTERNAL_BORDER_WIDTH;
1978 ReleaseDC(hWnd, hDc);
1982 /***********************************************************************
1984 * WINHELP_CheckPopup
1986 static BOOL WINHELP_CheckPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, LRESULT* lret)
1990 if (!Globals.active_popup) return FALSE;
1996 MSGFILTER* msgf = (MSGFILTER*)lParam;
1997 if (msgf->nmhdr.code == EN_MSGFILTER)
1999 if (!WINHELP_CheckPopup(hWnd, msgf->msg, msgf->wParam, msgf->lParam, NULL))
2001 if (lret) *lret = 1;
2007 if (wParam != WA_INACTIVE || (HWND)lParam == Globals.active_win->hMainWnd ||
2008 (HWND)lParam == Globals.active_popup->hMainWnd ||
2009 GetWindow((HWND)lParam, GW_OWNER) == Globals.active_win->hMainWnd)
2012 if (use_richedit) break;
2015 case WM_LBUTTONDOWN:
2016 if (WINHELP_HandleTextMouse(Globals.active_popup, msg, lParam) && msg == WM_LBUTTONDOWN)
2019 case WM_MBUTTONDOWN:
2020 case WM_RBUTTONDOWN:
2021 case WM_NCLBUTTONDOWN:
2022 case WM_NCMBUTTONDOWN:
2023 case WM_NCRBUTTONDOWN:
2025 hPopup = Globals.active_popup->hMainWnd;
2026 Globals.active_popup = NULL;
2027 DestroyWindow(hPopup);
2033 /***********************************************************************
2035 * WINHELP_DeleteLines
2037 static void WINHELP_DeleteLines(WINHELP_WINDOW *win)
2039 WINHELP_LINE *line, *next_line;
2040 WINHELP_LINE_PART *part, *next_part;
2041 for (line = win->first_line; line; line = next_line)
2043 next_line = line->next;
2044 for (part = &line->first_part; part; part = next_part)
2046 next_part = part->next;
2047 HLPFILE_FreeLink(part->link);
2048 HeapFree(GetProcessHeap(), 0, part);
2051 win->first_line = 0;
2054 /******************************************************************
2055 * WINHELP_DeleteButtons
2058 static void WINHELP_DeleteButtons(WINHELP_WINDOW* win)
2063 for (b = win->first_button; b; b = bp)
2065 DestroyWindow(b->hWnd);
2067 HeapFree(GetProcessHeap(), 0, b);
2069 win->first_button = NULL;
2072 /******************************************************************
2073 * WINHELP_DeleteBackSet
2076 void WINHELP_DeleteBackSet(WINHELP_WINDOW* win)
2080 for (i = 0; i < win->back.index; i++)
2082 HLPFILE_FreeHlpFile(win->back.set[i].page->file);
2083 win->back.set[i].page = NULL;
2085 win->back.index = 0;
2088 /******************************************************************
2089 * WINHELP_DeletePageLinks
2092 static void WINHELP_DeletePageLinks(HLPFILE_PAGE* page)
2097 for (curr = page->first_link; curr; curr = next)
2100 HeapFree(GetProcessHeap(), 0, curr);
2104 /***********************************************************************
2106 * WINHELP_DeleteWindow
2108 static void WINHELP_DeleteWindow(WINHELP_WINDOW* win)
2112 for (w = &Globals.win_list; *w; w = &(*w)->next)
2121 if (Globals.active_win == win)
2123 Globals.active_win = Globals.win_list;
2124 if (Globals.win_list)
2125 SetActiveWindow(Globals.win_list->hMainWnd);
2128 if (win == Globals.active_popup)
2129 Globals.active_popup = NULL;
2131 WINHELP_DeleteButtons(win);
2133 if (win->page) WINHELP_DeletePageLinks(win->page);
2134 if (win->hShadowWnd) DestroyWindow(win->hShadowWnd);
2135 if (win->hHistoryWnd) DestroyWindow(win->hHistoryWnd);
2137 DeleteObject(win->hBrush);
2139 WINHELP_DeleteBackSet(win);
2141 if (win->page) HLPFILE_FreeHlpFile(win->page->file);
2142 WINHELP_DeleteLines(win);
2143 HeapFree(GetProcessHeap(), 0, win);
2146 /***********************************************************************
2150 static void WINHELP_InitFonts(HWND hWnd)
2152 WINHELP_WINDOW *win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
2153 LOGFONT logfontlist[] = {
2154 {-10, 0, 0, 0, 400, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 32, "Helv"},
2155 {-12, 0, 0, 0, 700, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 32, "Helv"},
2156 {-12, 0, 0, 0, 700, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 32, "Helv"},
2157 {-12, 0, 0, 0, 400, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 32, "Helv"},
2158 {-12, 0, 0, 0, 700, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 32, "Helv"},
2159 {-10, 0, 0, 0, 700, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 32, "Helv"},
2160 { -8, 0, 0, 0, 400, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 32, "Helv"}};
2161 #define FONTS_LEN (sizeof(logfontlist)/sizeof(*logfontlist))
2163 static HFONT fonts[FONTS_LEN];
2164 static BOOL init = 0;
2166 win->fonts_len = FONTS_LEN;
2173 for (i = 0; i < FONTS_LEN; i++)
2175 fonts[i] = CreateFontIndirect(&logfontlist[i]);
2182 /***********************************************************************
2184 * WINHELP_MessageBoxIDS_s
2186 INT WINHELP_MessageBoxIDS_s(UINT ids_text, LPCSTR str, UINT ids_title, WORD type)
2188 CHAR text[MAX_STRING_LEN];
2189 CHAR newtext[MAX_STRING_LEN + MAX_PATH];
2191 LoadString(Globals.hInstance, ids_text, text, sizeof(text));
2192 wsprintf(newtext, text, str);
2194 return MessageBox(0, newtext, MAKEINTRESOURCE(ids_title), type);
2197 /******************************************************************
2198 * WINHELP_IsOverLink
2202 WINHELP_LINE_PART* WINHELP_IsOverLink(WINHELP_WINDOW* win, WPARAM wParam, LPARAM lParam)
2206 WINHELP_LINE_PART *part;
2207 int scroll_pos = GetScrollPos(GetDlgItem(win->hMainWnd, CTL_ID_TEXT), SB_VERT);
2209 mouse.x = LOWORD(lParam);
2210 mouse.y = HIWORD(lParam);
2211 for (line = win->first_line; line; line = line->next)
2213 for (part = &line->first_part; part; part = part->next)
2216 part->link->string &&
2217 part->rect.left <= mouse.x &&
2218 part->rect.right >= mouse.x &&
2219 part->rect.top <= mouse.y + scroll_pos &&
2220 part->rect.bottom >= mouse.y + scroll_pos)
2230 /**************************************************************************
2233 * HLPFILE_BPTreeCallback enumeration function for '|KWBTREE' internal file.
2236 static void cb_KWBTree(void *p, void **next, void *cookie)
2238 HWND hListWnd = (HWND)cookie;
2241 WINE_TRACE("Adding '%s' to search list\n", (char *)p);
2242 SendMessage(hListWnd, LB_INSERTSTRING, -1, (LPARAM)p);
2243 count = SendMessage(hListWnd, LB_GETCOUNT, 0, 0);
2244 SendMessage(hListWnd, LB_SETITEMDATA, count-1, (LPARAM)p);
2245 *next = (char*)p + strlen((char*)p) + 7;
2248 /**************************************************************************
2249 * WINHELP_IndexDlgProc
2251 * Index dialog callback function.
2253 * nResult passed to EndDialog:
2255 * >1: valid offset value +2.
2256 * EndDialog itself can return 0 (error).
2258 INT_PTR CALLBACK WINHELP_SearchDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
2260 static HLPFILE *file;
2267 file = (HLPFILE *)lParam;
2268 HLPFILE_BPTreeEnum(file->kwbtree, cb_KWBTree,
2269 GetDlgItem(hWnd, IDC_INDEXLIST));
2272 switch (LOWORD(wParam))
2275 sel = SendDlgItemMessage(hWnd, IDC_INDEXLIST, LB_GETCURSEL, 0, 0);
2281 p = (BYTE*)SendDlgItemMessage(hWnd, IDC_INDEXLIST,
2282 LB_GETITEMDATA, sel, 0);
2283 count = *(short*)((char *)p + strlen((char *)p) + 1);
2286 MessageBox(hWnd, "count > 1 not supported yet", "Error", MB_OK | MB_ICONSTOP);
2289 offset = *(ULONG*)((char *)p + strlen((char *)p) + 3);
2290 offset = *(long*)(file->kwdata + offset + 9);
2291 if (offset == 0xFFFFFFFF)
2293 MessageBox(hWnd, "macro keywords not supported yet", "Error", MB_OK | MB_ICONSTOP);
2300 EndDialog(hWnd, offset);
2311 /**************************************************************************
2312 * WINHELP_CreateIndexWindow
2314 * Displays a dialog with keywords of current help file.
2317 BOOL WINHELP_CreateIndexWindow(void)
2322 if (Globals.active_win && Globals.active_win->page && Globals.active_win->page->file)
2323 hlpfile = Globals.active_win->page->file;
2327 if (hlpfile->kwbtree == NULL)
2329 WINE_TRACE("No index provided\n");
2333 ret = DialogBoxParam(Globals.hInstance, MAKEINTRESOURCE(IDD_INDEX),
2334 Globals.active_win->hMainWnd, WINHELP_SearchDlgProc,
2339 WINE_TRACE("got %d as an offset\n", ret);
2340 WINHELP_OpenHelpWindow(HLPFILE_PageByOffset, hlpfile, ret,
2341 Globals.active_win->info, SW_NORMAL);