4 * Copyright 1996 Ulrich Schmid <uschmid@mail.hh.provi.de>
5 * 2002 Sylvain Petreolle <spetreolle@yahoo.fr>
6 * 2002 Eric Pouech <eric.pouech@wanadoo.fr>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 #include "winhelp_res.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(winhelp);
41 static BOOL WINHELP_RegisterWinClasses(void);
42 static LRESULT CALLBACK WINHELP_MainWndProc(HWND, UINT, WPARAM, LPARAM);
43 static LRESULT CALLBACK WINHELP_TextWndProc(HWND, UINT, WPARAM, LPARAM);
44 static LRESULT CALLBACK WINHELP_ButtonBoxWndProc(HWND, UINT, WPARAM, LPARAM);
45 static LRESULT CALLBACK WINHELP_HistoryWndProc(HWND, UINT, WPARAM, LPARAM);
46 static void WINHELP_CheckPopup(UINT);
47 static BOOL WINHELP_SplitLines(HWND hWnd, LPSIZE);
48 static void WINHELP_InitFonts(HWND hWnd);
49 static void WINHELP_DeleteLines(WINHELP_WINDOW*);
50 static void WINHELP_DeleteWindow(WINHELP_WINDOW*);
51 static void WINHELP_SetupText(HWND hWnd);
52 static WINHELP_LINE_PART* WINHELP_IsOverLink(WINHELP_WINDOW*, WPARAM, LPARAM);
54 WINHELP_GLOBALS Globals = {3, 0, 0, 0, 1, 0, 0};
56 /***********************************************************************
58 * WINHELP_LookupHelpFile
60 HLPFILE* WINHELP_LookupHelpFile(LPCSTR lpszFile)
64 hlpfile = HLPFILE_ReadHlpFile(lpszFile);
66 /* Add Suffix `.hlp' */
67 if (!hlpfile && lstrcmpi(lpszFile + strlen(lpszFile) - 4, ".hlp") != 0)
69 char szFile_hlp[MAX_PATHNAME_LEN];
71 lstrcpyn(szFile_hlp, lpszFile, sizeof(szFile_hlp) - 4);
72 szFile_hlp[sizeof(szFile_hlp) - 5] = '\0';
73 lstrcat(szFile_hlp, ".hlp");
75 hlpfile = HLPFILE_ReadHlpFile(szFile_hlp);
79 WINHELP_MessageBoxIDS_s(STID_HLPFILE_ERROR_s, lpszFile, STID_WHERROR, MB_OK);
80 if (Globals.win_list) return NULL;
85 /******************************************************************
86 * WINHELP_GetWindowInfo
90 HLPFILE_WINDOWINFO* WINHELP_GetWindowInfo(HLPFILE* hlpfile, LPCSTR name)
92 static HLPFILE_WINDOWINFO mwi;
95 if (!name || !name[0])
96 name = Globals.active_win->lpszName;
99 for (i = 0; i < hlpfile->numWindows; i++)
100 if (!strcmp(hlpfile->windows[i].name, name))
101 return &hlpfile->windows[i];
103 if (strcmp(name, "main") != 0)
105 WINE_FIXME("Couldn't find window info for %s\n", name);
111 strcpy(mwi.type, "primary");
112 strcpy(mwi.name, "main");
113 if (!LoadString(Globals.hInstance, STID_WINE_HELP,
114 mwi.caption, sizeof(mwi.caption)))
115 strcpy(mwi.caption, hlpfile->lpszTitle);
116 mwi.origin.x = mwi.origin.y = mwi.size.cx = mwi.size.cy = CW_USEDEFAULT;
118 mwi.sr_color = mwi.sr_color = 0xFFFFFF;
123 /******************************************************************
124 * HLPFILE_GetPopupWindowInfo
128 HLPFILE_WINDOWINFO* WINHELP_GetPopupWindowInfo(HLPFILE* hlpfile, HWND hParentWnd, POINT* mouse)
130 static HLPFILE_WINDOWINFO wi;
134 wi.type[0] = wi.name[0] = wi.caption[0] = '\0';
136 /* Calculate horizontal size and position of a popup window */
137 GetWindowRect(hParentWnd, &parent_rect);
138 wi.size.cx = (parent_rect.right - parent_rect.left) / 2;
139 wi.size.cy = 10; /* need a non null value, so that border are taken into account while computing */
142 ClientToScreen(hParentWnd, &wi.origin);
143 wi.origin.x -= wi.size.cx / 2;
144 wi.origin.x = min(wi.origin.x, GetSystemMetrics(SM_CXSCREEN) - wi.size.cx);
145 wi.origin.x = max(wi.origin.x, 0);
148 wi.win_style = WS_POPUPWINDOW;
149 wi.sr_color = wi.sr_color = 0xFFFFFF;
154 /***********************************************************************
158 int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show)
164 Globals.hInstance = hInstance;
167 while (*cmdline && (*cmdline == ' ' || *cmdline == '-'))
171 if (*cmdline++ == ' ') continue;
174 if (option) cmdline++;
175 while (*cmdline && *cmdline == ' ') cmdline++;
181 while (*cmdline && *cmdline != ' ') cmdline++;
182 if (*cmdline) *cmdline++ = '\0';
183 lHash = HLPFILE_Hash(topic_id);
188 Globals.wVersion = option - '0';
193 Globals.isBook = FALSE;
197 WINE_FIXME("Unsupported cmd line: %s\n", cmdline);
202 /* Create primary window */
203 WINHELP_RegisterWinClasses();
206 hlpfile = WINHELP_LookupHelpFile(cmdline);
207 if (!hlpfile) return 0;
210 WINHELP_CreateHelpWindowByHash(hlpfile, lHash,
211 WINHELP_GetWindowInfo(hlpfile, "main"), show);
214 while (GetMessage(&msg, 0, 0, 0))
216 TranslateMessage(&msg);
217 DispatchMessage(&msg);
222 /***********************************************************************
226 static BOOL WINHELP_RegisterWinClasses(void)
228 WNDCLASS class_main, class_button_box, class_text, class_shadow, class_history;
230 class_main.style = CS_HREDRAW | CS_VREDRAW;
231 class_main.lpfnWndProc = WINHELP_MainWndProc;
232 class_main.cbClsExtra = 0;
233 class_main.cbWndExtra = sizeof(LONG);
234 class_main.hInstance = Globals.hInstance;
235 class_main.hIcon = LoadIcon(0, IDI_APPLICATION);
236 class_main.hCursor = LoadCursor(0, IDC_ARROW);
237 class_main.hbrBackground = GetStockObject(WHITE_BRUSH);
238 class_main.lpszMenuName = 0;
239 class_main.lpszClassName = MAIN_WIN_CLASS_NAME;
241 class_button_box = class_main;
242 class_button_box.lpfnWndProc = WINHELP_ButtonBoxWndProc;
243 class_button_box.hbrBackground = GetStockObject(GRAY_BRUSH);
244 class_button_box.lpszClassName = BUTTON_BOX_WIN_CLASS_NAME;
246 class_text = class_main;
247 class_text.lpfnWndProc = WINHELP_TextWndProc;
248 class_text.lpszClassName = TEXT_WIN_CLASS_NAME;
250 class_shadow = class_main;
251 class_shadow.lpfnWndProc = DefWindowProc;
252 class_shadow.hbrBackground = GetStockObject(GRAY_BRUSH);
253 class_shadow.lpszClassName = SHADOW_WIN_CLASS_NAME;
255 class_history = class_main;
256 class_history.lpfnWndProc = WINHELP_HistoryWndProc;
257 class_history.lpszClassName = HISTORY_WIN_CLASS_NAME;
259 return (RegisterClass(&class_main) &&
260 RegisterClass(&class_button_box) &&
261 RegisterClass(&class_text) &&
262 RegisterClass(&class_shadow) &&
263 RegisterClass(&class_history));
274 } WINHELP,*LPWINHELP;
276 /******************************************************************
277 * WINHELP_HandleCommand
281 static LRESULT WINHELP_HandleCommand(HWND hSrcWnd, LPARAM lParam)
283 COPYDATASTRUCT* cds = (COPYDATASTRUCT*)lParam;
286 if (cds->dwData != 0xA1DE505)
288 WINE_FIXME("Wrong magic number (%08lx)\n", cds->dwData);
292 wh = (WINHELP*)cds->lpData;
296 char* ptr = (wh->ofsFilename) ? (LPSTR)wh + wh->ofsFilename : NULL;
298 WINE_TRACE("Got[%u]: cmd=%u data=%08lx fn=%s\n",
299 wh->size, wh->command, wh->data, ptr);
305 MACRO_JumpContext(ptr, "main", wh->data);
314 MACRO_JumpContents(ptr, "main");
317 case HELP_HELPONHELP:
320 /* case HELP_SETINDEX: */
321 case HELP_SETCONTENTS:
324 MACRO_SetContents(ptr, wh->data);
327 case HELP_CONTEXTPOPUP:
330 MACRO_PopupContext(ptr, wh->data);
333 /* case HELP_FORCEFILE:*/
334 /* case HELP_CONTEXTMENU: */
336 /* in fact, should be the topic dialog box */
339 MACRO_JumpHash(ptr, "main", 0);
342 /* case HELP_WM_HELP: */
343 /* case HELP_SETPOPUP_POS: */
345 /* case HELP_COMMAND: */
346 /* case HELP_PARTIALKEY: */
347 /* case HELP_MULTIKEY: */
348 /* case HELP_SETWINPOS: */
349 WINE_FIXME("Unknown command (%x) for remote winhelp control\n", wh->command);
356 /******************************************************************
357 * WINHELP_ReuseWindow
361 static BOOL WINHELP_ReuseWindow(WINHELP_WINDOW* win, WINHELP_WINDOW* oldwin,
362 HLPFILE_PAGE* page, int nCmdShow)
366 win->hMainWnd = oldwin->hMainWnd;
367 win->hButtonBoxWnd = oldwin->hButtonBoxWnd;
368 win->hTextWnd = oldwin->hTextWnd;
369 win->hHistoryWnd = oldwin->hHistoryWnd;
370 oldwin->hMainWnd = oldwin->hButtonBoxWnd = oldwin->hTextWnd = oldwin->hHistoryWnd = 0;
372 SetWindowLong(win->hMainWnd, 0, (LONG)win);
373 SetWindowLong(win->hButtonBoxWnd, 0, (LONG)win);
374 SetWindowLong(win->hTextWnd, 0, (LONG)win);
375 SetWindowLong(win->hHistoryWnd, 0, (LONG)win);
377 WINHELP_InitFonts(win->hMainWnd);
380 SetWindowText(win->hMainWnd, page->file->lpszTitle);
382 WINHELP_SetupText(win->hTextWnd);
383 InvalidateRect(win->hTextWnd, NULL, TRUE);
384 SendMessage(win->hMainWnd, WM_USER, 0, 0);
385 ShowWindow(win->hMainWnd, nCmdShow);
386 UpdateWindow(win->hTextWnd);
388 if (!(win->info->win_style & WS_POPUP))
392 memcpy(win->history, oldwin->history, sizeof(win->history));
393 win->histIndex = oldwin->histIndex;
395 /* FIXME: when using back, we shouldn't update the history... */
399 for (i = 0; i < win->histIndex; i++)
400 if (win->history[i] == page) break;
402 /* if the new page is already in the history, do nothing */
403 if (i == win->histIndex)
405 num = sizeof(win->history) / sizeof(win->history[0]);
406 if (win->histIndex == num)
408 /* we're full, remove latest entry */
409 HLPFILE_FreeHlpFile(win->history[0]->file);
410 memmove(&win->history[0], &win->history[1],
411 (num - 1) * sizeof(win->history[0]));
414 win->history[win->histIndex++] = page;
415 page->file->wRefCount++;
416 if (win->hHistoryWnd) InvalidateRect(win->hHistoryWnd, NULL, TRUE);
420 memcpy(win->back, oldwin->back, sizeof(win->back));
421 win->backIndex = oldwin->backIndex;
425 num = sizeof(win->back) / sizeof(win->back[0]);
426 if (win->backIndex == num)
428 /* we're full, remove latest entry */
429 HLPFILE_FreeHlpFile(win->back[0]->file);
430 memmove(&win->back[0], &win->back[1],
431 (num - 1) * sizeof(win->back[0]));
434 win->back[win->backIndex++] = page;
435 page->file->wRefCount++;
439 win->backIndex = win->histIndex = 0;
441 oldwin->histIndex = oldwin->backIndex = 0;
442 WINHELP_DeleteWindow(oldwin);
446 /***********************************************************************
448 * WINHELP_CreateHelpWindow
450 BOOL WINHELP_CreateHelpWindow(HLPFILE_PAGE* page, HLPFILE_WINDOWINFO* wi,
453 WINHELP_WINDOW *win, *oldwin;
458 bPrimary = !lstrcmpi(wi->name, "main");
459 bPopup = wi->win_style & WS_POPUP;
461 /* Initialize WINHELP_WINDOW struct */
462 win = HeapAlloc(GetProcessHeap(), 0,
463 sizeof(WINHELP_WINDOW) + strlen(wi->name) + 1);
464 if (!win) return FALSE;
466 win->next = Globals.win_list;
467 Globals.win_list = win;
469 win->lpszName = (char*)win + sizeof(WINHELP_WINDOW);
470 lstrcpy((char*)win->lpszName, wi->name);
473 win->first_button = 0;
476 win->hButtonBoxWnd = 0;
479 win->hHistoryWnd = 0;
481 win->hArrowCur = LoadCursorA(0, (LPSTR)IDC_ARROW);
482 win->hHandCur = LoadCursorA(0, (LPSTR)IDC_HAND);
486 Globals.active_win = win;
488 /* Initialize default pushbuttons */
489 if (bPrimary && page)
491 CHAR buffer[MAX_STRING_LEN];
493 LoadString(Globals.hInstance, STID_CONTENTS, buffer, sizeof(buffer));
494 MACRO_CreateButton("BTN_CONTENTS", buffer, "Contents()");
495 LoadString(Globals.hInstance, STID_SEARCH,buffer, sizeof(buffer));
496 MACRO_CreateButton("BTN_SEARCH", buffer, "Search()");
497 LoadString(Globals.hInstance, STID_BACK, buffer, sizeof(buffer));
498 MACRO_CreateButton("BTN_BACK", buffer, "Back()");
499 LoadString(Globals.hInstance, STID_HISTORY, buffer, sizeof(buffer));
500 MACRO_CreateButton("BTN_HISTORY", buffer, "History()");
501 LoadString(Globals.hInstance, STID_TOPICS, buffer, sizeof(buffer));
502 MACRO_CreateButton("BTN_TOPICS", buffer, "Finder()");
505 /* Initialize file specific pushbuttons */
506 if (!(wi->win_style & WS_POPUP) && page)
508 HLPFILE_MACRO *macro;
509 for (macro = page->file->first_macro; macro; macro = macro->next)
510 MACRO_ExecuteMacro(macro->lpszMacro);
512 for (macro = page->first_macro; macro; macro = macro->next)
513 MACRO_ExecuteMacro(macro->lpszMacro);
516 win->histIndex = win->backIndex = 0;
517 /* Reuse existing window */
520 for (oldwin = win->next; oldwin; oldwin = oldwin->next)
522 if (!lstrcmpi(oldwin->lpszName, wi->name))
524 return WINHELP_ReuseWindow(win, oldwin, page, nCmdShow);
529 win->histIndex = win->backIndex = 1;
530 win->history[0] = win->back[0] = page;
531 page->file->wRefCount += 2;
535 hWnd = CreateWindow(bPopup ? TEXT_WIN_CLASS_NAME : MAIN_WIN_CLASS_NAME,
536 wi->caption, wi->win_style,
537 wi->origin.x, wi->origin.y, wi->size.cx, wi->size.cy,
538 0, bPrimary ? LoadMenu(Globals.hInstance, MAKEINTRESOURCE(MAIN_MENU)) : 0,
539 Globals.hInstance, win);
541 ShowWindow(hWnd, nCmdShow);
547 /***********************************************************************
549 * WINHELP_CreateHelpWindowByHash
551 BOOL WINHELP_CreateHelpWindowByHash(HLPFILE* hlpfile, LONG lHash,
552 HLPFILE_WINDOWINFO* wi, int nCmdShow)
554 HLPFILE_PAGE* page = NULL;
557 page = lHash ? HLPFILE_PageByHash(hlpfile, lHash) :
558 HLPFILE_Contents(hlpfile);
559 if (page) page->file->wRefCount++;
560 return WINHELP_CreateHelpWindow(page, wi, nCmdShow);
563 /***********************************************************************
565 * WINHELP_MainWndProc
567 static LRESULT CALLBACK WINHELP_MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
570 WINHELP_BUTTON *button;
571 RECT rect, button_box_rect;
574 WINHELP_CheckPopup(msg);
579 win = (WINHELP_WINDOW*) ((LPCREATESTRUCT) lParam)->lpCreateParams;
580 SetWindowLong(hWnd, 0, (LONG) win);
581 win->hMainWnd = hWnd;
585 win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
587 /* Create button box and text Window */
588 CreateWindow(BUTTON_BOX_WIN_CLASS_NAME, "", WS_CHILD | WS_VISIBLE,
589 0, 0, 0, 0, hWnd, 0, Globals.hInstance, win);
591 CreateWindow(TEXT_WIN_CLASS_NAME, "", WS_CHILD | WS_VISIBLE,
592 0, 0, 0, 0, hWnd, 0, Globals.hInstance, win);
596 case WM_WINDOWPOSCHANGED:
597 win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
598 GetClientRect(hWnd, &rect);
600 /* Update button box and text Window */
601 SetWindowPos(win->hButtonBoxWnd, HWND_TOP,
603 rect.right - rect.left,
604 rect.bottom - rect.top, 0);
606 GetWindowRect(win->hButtonBoxWnd, &button_box_rect);
607 text_top = rect.top + button_box_rect.bottom - button_box_rect.top;
609 SetWindowPos(win->hTextWnd, HWND_TOP,
611 rect.right - rect.left,
612 rect.bottom - text_top, 0);
617 Globals.active_win = win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
621 case MNID_FILE_OPEN: MACRO_FileOpen(); break;
622 case MNID_FILE_PRINT: MACRO_Print(); break;
623 case MNID_FILE_SETUP: MACRO_PrinterSetup(); break;
624 case MNID_FILE_EXIT: MACRO_Exit(); break;
627 case MNID_EDIT_COPYDLG: MACRO_CopyDialog(); break;
628 case MNID_EDIT_ANNOTATE:MACRO_Annotate(); break;
631 case MNID_BKMK_DEFINE: MACRO_BookmarkDefine(); break;
634 case MNID_HELP_HELPON: MACRO_HelpOn(); break;
635 case MNID_HELP_HELPTOP: MACRO_HelpOnTop(); break;
636 case MNID_HELP_ABOUT: MACRO_About(); break;
637 case MNID_HELP_WINE: ShellAbout(hWnd, "WINE", "Help", 0); break;
641 for (button = win->first_button; button; button = button->next)
642 if (wParam == button->wParam) break;
644 MACRO_ExecuteMacro(button->lpszMacro);
646 WINHELP_MessageBoxIDS(STID_NOT_IMPLEMENTED, 0x121, MB_OK);
651 if (Globals.hPopupWnd) DestroyWindow(Globals.hPopupWnd);
654 return WINHELP_HandleCommand((HWND)wParam, lParam);
656 return DefWindowProc(hWnd, msg, wParam, lParam);
659 /***********************************************************************
661 * WINHELP_ButtonBoxWndProc
663 static LRESULT CALLBACK WINHELP_ButtonBoxWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
667 WINHELP_BUTTON *button;
671 WINHELP_CheckPopup(msg);
676 win = (WINHELP_WINDOW*) ((LPCREATESTRUCT) lParam)->lpCreateParams;
677 SetWindowLong(hWnd, 0, (LONG) win);
678 win->hButtonBoxWnd = hWnd;
681 case WM_WINDOWPOSCHANGING:
682 winpos = (WINDOWPOS*) lParam;
683 win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
688 for (button = win->first_button; button; button = button->next)
693 button->hWnd = CreateWindow(STRING_BUTTON, (LPSTR) button->lpszName,
694 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
696 hWnd, (HMENU) button->wParam,
697 Globals.hInstance, 0);
698 hDc = GetDC(button->hWnd);
699 GetTextExtentPoint(hDc, button->lpszName,
700 lstrlen(button->lpszName), &textsize);
701 ReleaseDC(button->hWnd, hDc);
703 button_size.cx = max(button_size.cx, textsize.cx + BUTTON_CX);
704 button_size.cy = max(button_size.cy, textsize.cy + BUTTON_CY);
709 for (button = win->first_button; button; button = button->next)
711 SetWindowPos(button->hWnd, HWND_TOP, x, y, button_size.cx, button_size.cy, 0);
713 if (x + 2 * button_size.cx <= winpos->cx)
716 x = 0, y += button_size.cy;
718 winpos->cy = y + (x ? button_size.cy : 0);
722 SendMessage(GetParent(hWnd), msg, wParam, lParam);
726 return DefWindowProc(hWnd, msg, wParam, lParam);
729 /***********************************************************************
731 * WINHELP_TextWndProc
733 static LRESULT CALLBACK WINHELP_TextWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
737 WINHELP_LINE_PART *part;
746 if (msg != WM_LBUTTONDOWN)
747 WINHELP_CheckPopup(msg);
752 win = (WINHELP_WINDOW*) ((LPCREATESTRUCT) lParam)->lpCreateParams;
753 SetWindowLong(hWnd, 0, (LONG) win);
754 win->hTextWnd = hWnd;
755 if (win->info->win_style & WS_POPUP) Globals.hPopupWnd = win->hMainWnd = hWnd;
756 WINHELP_InitFonts(hWnd);
760 win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
762 /* Calculate vertical size and position of a popup window */
763 if (win->info->win_style & WS_POPUP)
766 RECT old_window_rect;
767 RECT old_client_rect;
768 SIZE old_window_size;
769 SIZE old_client_size;
770 SIZE new_client_size;
771 SIZE new_window_size;
773 GetWindowRect(hWnd, &old_window_rect);
774 origin.x = old_window_rect.left;
775 origin.y = old_window_rect.top;
776 old_window_size.cx = old_window_rect.right - old_window_rect.left;
777 old_window_size.cy = old_window_rect.bottom - old_window_rect.top;
779 GetClientRect(hWnd, &old_client_rect);
780 old_client_size.cx = old_client_rect.right - old_client_rect.left;
781 old_client_size.cy = old_client_rect.bottom - old_client_rect.top;
783 new_client_size = old_client_size;
784 WINHELP_SplitLines(hWnd, &new_client_size);
786 if (origin.y + POPUP_YDISTANCE + new_client_size.cy <= GetSystemMetrics(SM_CYSCREEN))
787 origin.y += POPUP_YDISTANCE;
789 origin.y -= POPUP_YDISTANCE + new_client_size.cy;
791 new_window_size.cx = old_window_size.cx - old_client_size.cx + new_client_size.cx;
792 new_window_size.cy = old_window_size.cy - old_client_size.cy + new_client_size.cy;
795 CreateWindow(SHADOW_WIN_CLASS_NAME, "", WS_POPUP,
796 origin.x + SHADOW_DX, origin.y + SHADOW_DY,
797 new_window_size.cx, new_window_size.cy,
798 0, 0, Globals.hInstance, 0);
800 SetWindowPos(hWnd, HWND_TOP, origin.x, origin.y,
801 new_window_size.cx, new_window_size.cy,
803 SetWindowPos(win->hShadowWnd, hWnd, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
804 ShowWindow(win->hShadowWnd, SW_NORMAL);
805 SetActiveWindow(hWnd);
809 case WM_WINDOWPOSCHANGED:
810 winpos = (WINDOWPOS*) lParam;
812 if (!(winpos->flags & SWP_NOSIZE)) WINHELP_SetupText(hWnd);
818 UINT scrollLines = 3;
819 int curPos = GetScrollPos(hWnd, SB_VERT);
822 GetScrollRange(hWnd, SB_VERT, &min, &max);
824 SystemParametersInfo(SPI_GETWHEELSCROLLLINES,0, &scrollLines, 0);
825 if (wParam & (MK_SHIFT | MK_CONTROL))
826 return DefWindowProc(hWnd, msg, wParam, lParam);
827 wheelDelta -= GET_WHEEL_DELTA_WPARAM(wParam);
828 if (abs(wheelDelta) >= WHEEL_DELTA && scrollLines) {
831 curPos += wheelDelta;
834 else if (curPos < min)
837 dy = GetScrollPos(hWnd, SB_VERT) - curPos;
838 SetScrollPos(hWnd, SB_VERT, curPos, TRUE);
839 ScrollWindow(hWnd, 0, dy, NULL, NULL);
850 INT CurPos = GetScrollPos(hWnd, SB_VERT);
853 GetScrollRange(hWnd, SB_VERT, &Min, &Max);
854 GetClientRect(hWnd, &rect);
856 switch (wParam & 0xffff)
859 case SB_THUMBPOSITION: CurPos = wParam >> 16; break;
860 case SB_TOP: CurPos = Min; break;
861 case SB_BOTTOM: CurPos = Max; break;
862 case SB_PAGEUP: CurPos -= (rect.bottom - rect.top) / 2; break;
863 case SB_PAGEDOWN: CurPos += (rect.bottom - rect.top) / 2; break;
864 case SB_LINEUP: CurPos -= GetSystemMetrics(SM_CXVSCROLL); break;
865 case SB_LINEDOWN: CurPos += GetSystemMetrics(SM_CXVSCROLL); break;
866 default: update = FALSE;
872 else if (CurPos < Min)
874 dy = GetScrollPos(hWnd, SB_VERT) - CurPos;
875 SetScrollPos(hWnd, SB_VERT, CurPos, TRUE);
876 ScrollWindow(hWnd, 0, dy, NULL, NULL);
883 hDc = BeginPaint(hWnd, &ps);
884 win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
885 scroll_pos = GetScrollPos(hWnd, SB_VERT);
887 for (line = win->first_line; line; line = line->next)
889 for (part = &line->first_part; part; part = part->next)
891 switch (part->cookie)
893 case hlp_line_part_text:
894 SelectObject(hDc, part->u.text.hFont);
895 SetTextColor(hDc, part->u.text.color);
896 TextOut(hDc, part->rect.left, part->rect.top - scroll_pos,
897 part->u.text.lpsText, part->u.text.wTextLen);
898 if (part->u.text.wUnderline)
902 switch (part->u.text.wUnderline)
906 hPen = CreatePen(PS_SOLID, 1, part->u.text.color);
909 hPen = CreatePen(PS_DOT, 1, part->u.text.color);
912 WINE_FIXME("Unknow underline type\n");
916 SelectObject(hDc, hPen);
917 MoveToEx(hDc, part->rect.left, part->rect.bottom - scroll_pos - 1, NULL);
918 LineTo(hDc, part->rect.right, part->rect.bottom - scroll_pos - 1);
919 if (part->u.text.wUnderline == 2)
921 MoveToEx(hDc, part->rect.left, part->rect.bottom - scroll_pos + 1, NULL);
922 LineTo(hDc, part->rect.right, part->rect.bottom - scroll_pos + 1);
927 case hlp_line_part_bitmap:
931 hMemDC = CreateCompatibleDC(hDc);
932 SelectObject(hMemDC, part->u.bitmap.hBitmap);
933 BitBlt(hDc, part->rect.left, part->rect.top - scroll_pos,
934 part->rect.right - part->rect.left, part->rect.bottom - part->rect.top,
935 hMemDC, 0, 0, SRCCOPY);
939 case hlp_line_part_metafile:
943 SetViewportOrgEx(hDc, part->rect.left, part->rect.top - scroll_pos, &pt);
944 PlayMetaFile(hDc, part->u.metafile.hMetaFile);
945 SetViewportOrgEx(hDc, pt.x, pt.y, NULL);
956 win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
958 if (WINHELP_IsOverLink(win, wParam, lParam))
959 SetCursor(win->hHandCur); /* set to hand pointer cursor to indicate a link */
961 SetCursor(win->hArrowCur); /* set to hand pointer cursor to indicate a link */
966 win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
968 hPopupWnd = Globals.hPopupWnd;
969 Globals.hPopupWnd = 0;
971 part = WINHELP_IsOverLink(win, wParam, lParam);
975 HLPFILE_WINDOWINFO* wi;
977 mouse.x = LOWORD(lParam);
978 mouse.y = HIWORD(lParam);
980 if (part->link) switch (part->link->cookie)
983 hlpfile = WINHELP_LookupHelpFile(part->link->lpszString);
984 if (part->link->window == -1)
986 else if (part->link->window < hlpfile->numWindows)
987 wi = &hlpfile->windows[part->link->window];
990 WINE_WARN("link to window %d/%d\n", part->link->window, hlpfile->numWindows);
993 WINHELP_CreateHelpWindowByHash(hlpfile, part->link->lHash, wi,
997 hlpfile = WINHELP_LookupHelpFile(part->link->lpszString);
998 WINHELP_CreateHelpWindowByHash(hlpfile, part->link->lHash,
999 WINHELP_GetPopupWindowInfo(hlpfile, hWnd, &mouse),
1002 case hlp_link_macro:
1003 MACRO_ExecuteMacro(part->link->lpszString);
1006 WINE_FIXME("Unknown link cookie %d\n", part->link->cookie);
1011 DestroyWindow(hPopupWnd);
1015 win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
1017 if (hWnd == Globals.hPopupWnd) Globals.hPopupWnd = 0;
1019 bExit = (Globals.wVersion >= 4 && !lstrcmpi(win->lpszName, "main"));
1021 WINHELP_DeleteWindow(win);
1023 if (bExit) MACRO_Exit();
1025 if (!Globals.win_list)
1030 return DefWindowProc(hWnd, msg, wParam, lParam);
1033 /******************************************************************
1034 * WINHELP_HistoryWndProc
1038 static LRESULT CALLBACK WINHELP_HistoryWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
1040 WINHELP_WINDOW* win;
1050 win = (WINHELP_WINDOW*)((LPCREATESTRUCT)lParam)->lpCreateParams;
1051 SetWindowLong(hWnd, 0, (LONG)win);
1052 win->hHistoryWnd = hWnd;
1055 win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
1057 GetTextMetrics(hDc, &tm);
1058 GetWindowRect(hWnd, &r);
1060 r.right = r.left + 30 * tm.tmAveCharWidth;
1061 r.bottom = r.top + (sizeof(win->history) / sizeof(win->history[0])) * tm.tmHeight;
1062 AdjustWindowRect(&r, GetWindowLong(hWnd, GWL_STYLE), FALSE);
1063 if (r.left < 0) {r.right -= r.left; r.left = 0;}
1064 if (r.top < 0) {r.bottom -= r.top; r.top = 0;}
1066 MoveWindow(hWnd, r.left, r.top, r.right, r.bottom, TRUE);
1067 ReleaseDC(hWnd, hDc);
1069 case WM_LBUTTONDOWN:
1070 win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
1072 GetTextMetrics(hDc, &tm);
1073 i = HIWORD(lParam) / tm.tmHeight;
1074 if (i < win->histIndex)
1075 WINHELP_CreateHelpWindow(win->history[i], win->info, SW_SHOW);
1076 ReleaseDC(hWnd, hDc);
1079 hDc = BeginPaint(hWnd, &ps);
1080 win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
1081 GetTextMetrics(hDc, &tm);
1083 for (i = 0; i < win->histIndex; i++)
1085 TextOut(hDc, 0, i * tm.tmHeight, win->history[i]->lpszTitle,
1086 strlen(win->history[i]->lpszTitle));
1088 EndPaint(hWnd, &ps);
1091 win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
1092 if (hWnd == win->hHistoryWnd)
1093 win->hHistoryWnd = 0;
1096 return DefWindowProc(hWnd, msg, wParam, lParam);
1099 /***********************************************************************
1103 static void WINHELP_SetupText(HWND hWnd)
1105 HDC hDc = GetDC(hWnd);
1109 ShowScrollBar(hWnd, SB_VERT, FALSE);
1110 if (!WINHELP_SplitLines(hWnd, NULL))
1112 ShowScrollBar(hWnd, SB_VERT, TRUE);
1113 GetClientRect(hWnd, &rect);
1115 WINHELP_SplitLines(hWnd, &newsize);
1116 SetScrollRange(hWnd, SB_VERT, 0, rect.top + newsize.cy - rect.bottom, TRUE);
1118 else SetScrollPos(hWnd, SB_VERT, 0, FALSE);
1120 ReleaseDC(hWnd, hDc);
1123 /***********************************************************************
1125 * WINHELP_AppendText
1127 static BOOL WINHELP_AppendText(WINHELP_LINE ***linep, WINHELP_LINE_PART ***partp,
1128 LPSIZE space, LPSIZE textsize,
1129 INT *line_ascent, INT ascent,
1130 LPCSTR text, UINT textlen,
1131 HFONT font, COLORREF color, HLPFILE_LINK *link,
1135 WINHELP_LINE_PART *part;
1138 if (!*partp) /* New line */
1140 *line_ascent = ascent;
1142 line = HeapAlloc(GetProcessHeap(), 0,
1143 sizeof(WINHELP_LINE) + textlen);
1144 if (!line) return FALSE;
1147 part = &line->first_part;
1148 ptr = (char*)line + sizeof(WINHELP_LINE);
1150 line->rect.top = (**linep ? (**linep)->rect.bottom : 0) + space->cy;
1151 line->rect.bottom = line->rect.top;
1152 line->rect.left = space->cx;
1153 line->rect.right = space->cx;
1155 if (**linep) *linep = &(**linep)->next;
1159 else /* Same line */
1163 if (*line_ascent < ascent)
1165 WINHELP_LINE_PART *p;
1166 for (p = &line->first_part; p; p = p->next)
1168 p->rect.top += ascent - *line_ascent;
1169 p->rect.bottom += ascent - *line_ascent;
1171 line->rect.bottom += ascent - *line_ascent;
1172 *line_ascent = ascent;
1175 part = HeapAlloc(GetProcessHeap(), 0,
1176 sizeof(WINHELP_LINE_PART) + textlen);
1177 if (!part) return FALSE;
1179 ptr = (char*)part + sizeof(WINHELP_LINE_PART);
1182 memcpy(ptr, text, textlen);
1183 part->cookie = hlp_line_part_text;
1184 part->rect.left = line->rect.right + (*partp ? space->cx : 0);
1185 part->rect.right = part->rect.left + textsize->cx;
1186 line->rect.right = part->rect.right;
1188 ((*partp) ? line->rect.top : line->rect.bottom) + *line_ascent - ascent;
1189 part->rect.bottom = part->rect.top + textsize->cy;
1190 line->rect.bottom = max(line->rect.bottom, part->rect.bottom);
1191 part->u.text.lpsText = ptr;
1192 part->u.text.wTextLen = textlen;
1193 part->u.text.hFont = font;
1194 part->u.text.color = color;
1195 part->u.text.wUnderline = underline;
1197 WINE_TRACE("Appended text '%*.*s'[%d] @ (%ld,%ld-%ld,%ld)\n",
1198 part->u.text.wTextLen,
1199 part->u.text.wTextLen,
1200 part->u.text.lpsText,
1201 part->u.text.wTextLen,
1202 part->rect.left, part->rect.top, part->rect.right, part->rect.bottom);
1205 if (link) link->wRefCount++;
1208 *partp = &part->next;
1215 /***********************************************************************
1217 * WINHELP_AppendGfxObject
1219 static WINHELP_LINE_PART* WINHELP_AppendGfxObject(WINHELP_LINE ***linep, WINHELP_LINE_PART ***partp,
1220 LPSIZE space, LPSIZE gfxSize,
1221 HLPFILE_LINK *link, unsigned pos)
1224 WINHELP_LINE_PART *part;
1227 if (!*partp || pos == 1) /* New line */
1229 line = HeapAlloc(GetProcessHeap(), 0, sizeof(WINHELP_LINE));
1230 if (!line) return NULL;
1233 part = &line->first_part;
1235 line->rect.top = (**linep ? (**linep)->rect.bottom : 0) + space->cy;
1236 line->rect.bottom = line->rect.top;
1237 line->rect.left = space->cx;
1238 line->rect.right = space->cx;
1240 if (**linep) *linep = &(**linep)->next;
1243 ptr = (char*)line + sizeof(WINHELP_LINE);
1245 else /* Same line */
1247 if (pos == 2) WINE_FIXME("Left alignment not handled\n");
1250 part = HeapAlloc(GetProcessHeap(), 0, sizeof(WINHELP_LINE_PART));
1251 if (!part) return NULL;
1253 ptr = (char*)part + sizeof(WINHELP_LINE_PART);
1256 /* part->cookie should be set by caller (image or metafile) */
1257 part->rect.left = line->rect.right + (*partp ? space->cx : 0);
1258 part->rect.right = part->rect.left + gfxSize->cx;
1259 line->rect.right = part->rect.right;
1260 part->rect.top = (*partp) ? line->rect.top : line->rect.bottom;
1261 part->rect.bottom = part->rect.top + gfxSize->cy;
1262 line->rect.bottom = max(line->rect.bottom, part->rect.bottom);
1264 WINE_TRACE("Appended gfx @ (%ld,%ld-%ld,%ld)\n",
1265 part->rect.left, part->rect.top, part->rect.right, part->rect.bottom);
1268 if (link) link->wRefCount++;
1271 *partp = &part->next;
1279 /***********************************************************************
1281 * WINHELP_SplitLines
1283 static BOOL WINHELP_SplitLines(HWND hWnd, LPSIZE newsize)
1285 WINHELP_WINDOW *win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
1286 HLPFILE_PARAGRAPH *p;
1287 WINHELP_LINE **line = &win->first_line;
1288 WINHELP_LINE_PART **part = 0;
1289 INT line_ascent = 0;
1294 if (newsize) newsize->cx = newsize->cy = 0;
1296 if (!win->page) return TRUE;
1298 WINHELP_DeleteLines(win);
1300 GetClientRect(hWnd, &rect);
1302 rect.top += INTERNAL_BORDER_WIDTH;
1303 rect.left += INTERNAL_BORDER_WIDTH;
1304 rect.right -= INTERNAL_BORDER_WIDTH;
1305 rect.bottom -= INTERNAL_BORDER_WIDTH;
1307 space.cy = rect.top;
1308 space.cx = rect.left;
1312 for (p = win->page->first_paragraph; p; p = p->next)
1316 case para_normal_text:
1317 case para_debug_text:
1320 SIZE textsize = {0, 0};
1321 LPCSTR text = p->u.text.lpszText;
1323 UINT len = strlen(text);
1324 unsigned underline = 0;
1327 COLORREF color = RGB(0, 0, 0);
1329 if (p->u.text.wFont < win->page->file->numFonts)
1331 HLPFILE* hlpfile = win->page->file;
1333 if (!hlpfile->fonts[p->u.text.wFont].hFont)
1334 hlpfile->fonts[p->u.text.wFont].hFont = CreateFontIndirect(&hlpfile->fonts[p->u.text.wFont].LogFont);
1335 hFont = hlpfile->fonts[p->u.text.wFont].hFont;
1336 color = hlpfile->fonts[p->u.text.wFont].color;
1340 UINT wFont = (p->u.text.wFont < win->fonts_len) ? p->u.text.wFont : 0;
1342 hFont = win->fonts[wFont];
1345 if (p->link && p->link->bClrChange)
1347 underline = (p->link->cookie == hlp_link_popup) ? 3 : 1;
1348 color = RGB(0, 0x80, 0);
1350 if (p->cookie == para_debug_text) color = RGB(0xff, 0, 0);
1352 SelectObject(hDc, hFont);
1354 GetTextMetrics(hDc, &tm);
1356 if (p->u.text.wIndent)
1358 indent = p->u.text.wIndent * 5 * tm.tmAveCharWidth;
1360 space.cx = rect.left + indent - 2 * tm.tmAveCharWidth;
1363 if (p->u.text.wVSpace)
1366 space.cx = rect.left + indent;
1367 space.cy += (p->u.text.wVSpace - 1) * tm.tmHeight;
1370 if (p->u.text.wHSpace)
1372 space.cx += p->u.text.wHSpace * 2 * tm.tmAveCharWidth;
1375 WINE_TRACE("splitting text %s\n", text);
1379 INT free_width = rect.right - (part ? (*line)->rect.right : rect.left) - space.cx;
1380 UINT low = 0, curr = len, high = len, textlen = 0;
1386 GetTextExtentPoint(hDc, text, curr, &textsize);
1388 if (textsize.cx <= free_width) low = curr;
1391 if (high <= low + 1) break;
1393 if (textsize.cx) curr = (curr * free_width) / textsize.cx;
1394 if (curr <= low) curr = low + 1;
1395 else if (curr >= high) curr = high - 1;
1398 while (textlen && text[textlen] && text[textlen] != ' ') textlen--;
1400 if (!part && !textlen) textlen = max(low, 1);
1402 if (free_width <= 0 || !textlen)
1405 space.cx = rect.left + indent;
1406 space.cx = min(space.cx, rect.right - rect.left - 1);
1410 WINE_TRACE("\t => %d %*s\n", textlen, textlen, text);
1412 if (!WINHELP_AppendText(&line, &part, &space, &textsize,
1413 &line_ascent, tm.tmAscent,
1414 text, textlen, hFont, color, p->link, underline) ||
1415 (!newsize && (*line)->rect.bottom > rect.bottom))
1417 ReleaseDC(hWnd, hDc);
1422 newsize->cx = max(newsize->cx, (*line)->rect.right + INTERNAL_BORDER_WIDTH);
1426 if (text[0] == ' ') text++, len--;
1435 WINHELP_LINE_PART* ref_part;
1437 if (p->u.gfx.pos & 0x8000)
1439 space.cx = rect.left;
1441 space.cy += (*line)->rect.bottom - (*line)->rect.top;
1445 if (p->cookie == para_bitmap)
1449 GetObject(p->u.gfx.u.bmp.hBitmap, sizeof(dibs), &dibs);
1450 gfxSize.cx = dibs.dsBm.bmWidth;
1451 gfxSize.cy = dibs.dsBm.bmHeight;
1453 else gfxSize = p->u.gfx.u.mf.mfSize;
1455 free_width = rect.right - ((part && *line) ? (*line)->rect.right : rect.left) - space.cx;
1456 if (free_width <= 0)
1459 space.cx = rect.left;
1460 space.cx = min(space.cx, rect.right - rect.left - 1);
1462 ref_part = WINHELP_AppendGfxObject(&line, &part, &space, &gfxSize,
1463 p->link, p->u.gfx.pos);
1464 if (!ref_part || (!newsize && (*line)->rect.bottom > rect.bottom))
1468 if (p->cookie == para_bitmap)
1470 ref_part->cookie = hlp_line_part_bitmap;
1471 ref_part->u.bitmap.hBitmap = p->u.gfx.u.bmp.hBitmap;
1475 ref_part->cookie = hlp_line_part_metafile;
1476 ref_part->u.metafile.hMetaFile = p->u.gfx.u.mf.hMetaFile;
1484 newsize->cy = (*line)->rect.bottom + INTERNAL_BORDER_WIDTH;
1486 ReleaseDC(hWnd, hDc);
1490 /***********************************************************************
1492 * WINHELP_CheckPopup
1494 static void WINHELP_CheckPopup(UINT msg)
1496 if (!Globals.hPopupWnd) return;
1501 case WM_LBUTTONDOWN:
1502 case WM_MBUTTONDOWN:
1503 case WM_RBUTTONDOWN:
1504 case WM_NCLBUTTONDOWN:
1505 case WM_NCMBUTTONDOWN:
1506 case WM_NCRBUTTONDOWN:
1507 DestroyWindow(Globals.hPopupWnd);
1508 Globals.hPopupWnd = 0;
1512 /***********************************************************************
1514 * WINHELP_DeleteLines
1516 static void WINHELP_DeleteLines(WINHELP_WINDOW *win)
1518 WINHELP_LINE *line, *next_line;
1519 WINHELP_LINE_PART *part, *next_part;
1520 for (line = win->first_line; line; line = next_line)
1522 next_line = line->next;
1523 for (part = &line->first_part; part; part = next_part)
1525 next_part = part->next;
1526 HLPFILE_FreeLink(part->link);
1527 HeapFree(GetProcessHeap(), 0, part);
1530 win->first_line = 0;
1533 /***********************************************************************
1535 * WINHELP_DeleteWindow
1537 static void WINHELP_DeleteWindow(WINHELP_WINDOW* win)
1544 for (w = &Globals.win_list; *w; w = &(*w)->next)
1553 for (b = win->first_button; b; b = bp)
1555 DestroyWindow(b->hWnd);
1557 HeapFree(GetProcessHeap(), 0, b);
1560 if (win->hShadowWnd) DestroyWindow(win->hShadowWnd);
1561 if (win->hHistoryWnd) DestroyWindow(win->hHistoryWnd);
1563 for (i = 0; i < win->histIndex; i++)
1565 HLPFILE_FreeHlpFile(win->history[i]->file);
1568 for (i = 0; i < win->backIndex; i++)
1569 HLPFILE_FreeHlpFile(win->back[i]->file);
1571 if (win->page) HLPFILE_FreeHlpFile(win->page->file);
1572 WINHELP_DeleteLines(win);
1573 HeapFree(GetProcessHeap(), 0, win);
1576 /***********************************************************************
1580 static void WINHELP_InitFonts(HWND hWnd)
1582 WINHELP_WINDOW *win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
1583 LOGFONT logfontlist[] = {
1584 {-10, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"},
1585 {-12, 0, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"},
1586 {-12, 0, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"},
1587 {-12, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"},
1588 {-12, 0, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"},
1589 {-10, 0, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"},
1590 { -8, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"}};
1591 #define FONTS_LEN (sizeof(logfontlist)/sizeof(*logfontlist))
1593 static HFONT fonts[FONTS_LEN];
1594 static BOOL init = 0;
1596 win->fonts_len = FONTS_LEN;
1603 for (i = 0; i < FONTS_LEN; i++)
1605 fonts[i] = CreateFontIndirect(&logfontlist[i]);
1612 /***********************************************************************
1614 * WINHELP_MessageBoxIDS
1616 INT WINHELP_MessageBoxIDS(UINT ids_text, UINT ids_title, WORD type)
1618 CHAR text[MAX_STRING_LEN];
1619 CHAR title[MAX_STRING_LEN];
1621 LoadString(Globals.hInstance, ids_text, text, sizeof(text));
1622 LoadString(Globals.hInstance, ids_title, title, sizeof(title));
1624 return MessageBox(0, text, title, type);
1627 /***********************************************************************
1629 * MAIN_MessageBoxIDS_s
1631 INT WINHELP_MessageBoxIDS_s(UINT ids_text, LPCSTR str, UINT ids_title, WORD type)
1633 CHAR text[MAX_STRING_LEN];
1634 CHAR title[MAX_STRING_LEN];
1635 CHAR newtext[MAX_STRING_LEN + MAX_PATHNAME_LEN];
1637 LoadString(Globals.hInstance, ids_text, text, sizeof(text));
1638 LoadString(Globals.hInstance, ids_title, title, sizeof(title));
1639 wsprintf(newtext, text, str);
1641 return MessageBox(0, newtext, title, type);
1644 /******************************************************************
1645 * WINHELP_IsOverLink
1649 WINHELP_LINE_PART* WINHELP_IsOverLink(WINHELP_WINDOW* win, WPARAM wParam, LPARAM lParam)
1653 WINHELP_LINE_PART *part;
1654 int scroll_pos = GetScrollPos(win->hMainWnd, SB_VERT);
1656 mouse.x = LOWORD(lParam);
1657 mouse.y = HIWORD(lParam);
1658 for (line = win->first_line; line; line = line->next)
1660 for (part = &line->first_part; part; part = part->next)
1663 part->link->lpszString &&
1664 part->rect.left <= mouse.x &&
1665 part->rect.right >= mouse.x &&
1666 part->rect.top <= mouse.y + scroll_pos &&
1667 part->rect.bottom >= mouse.y + scroll_pos)