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
33 #include "winhelp_res.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(winhelp
);
40 static BOOL
WINHELP_RegisterWinClasses(void);
41 static LRESULT CALLBACK
WINHELP_MainWndProc(HWND
, UINT
, WPARAM
, LPARAM
);
42 static LRESULT CALLBACK
WINHELP_TextWndProc(HWND
, UINT
, WPARAM
, LPARAM
);
43 static LRESULT CALLBACK
WINHELP_ButtonBoxWndProc(HWND
, UINT
, WPARAM
, LPARAM
);
44 static LRESULT CALLBACK
WINHELP_HistoryWndProc(HWND
, UINT
, WPARAM
, LPARAM
);
45 static void WINHELP_CheckPopup(UINT
);
46 static BOOL
WINHELP_SplitLines(HWND hWnd
, LPSIZE
);
47 static void WINHELP_InitFonts(HWND hWnd
);
48 static void WINHELP_DeleteLines(WINHELP_WINDOW
*);
49 static void WINHELP_DeleteWindow(WINHELP_WINDOW
*);
50 static void WINHELP_SetupText(HWND hWnd
);
51 static WINHELP_LINE_PART
* WINHELP_IsOverLink(WINHELP_WINDOW
*, WPARAM
, LPARAM
);
53 WINHELP_GLOBALS Globals
= {3, 0, 0, 0, 1, 0, 0};
55 /***********************************************************************
57 * WINHELP_LookupHelpFile
59 HLPFILE
* WINHELP_LookupHelpFile(LPCSTR lpszFile
)
63 hlpfile
= HLPFILE_ReadHlpFile(lpszFile
);
65 /* Add Suffix `.hlp' */
66 if (!hlpfile
&& lstrcmpi(lpszFile
+ strlen(lpszFile
) - 4, ".hlp") != 0)
68 char szFile_hlp
[MAX_PATHNAME_LEN
];
70 lstrcpyn(szFile_hlp
, lpszFile
, sizeof(szFile_hlp
) - 4);
71 szFile_hlp
[sizeof(szFile_hlp
) - 5] = '\0';
72 lstrcat(szFile_hlp
, ".hlp");
74 hlpfile
= HLPFILE_ReadHlpFile(szFile_hlp
);
78 WINHELP_MessageBoxIDS_s(STID_HLPFILE_ERROR_s
, lpszFile
, STID_WHERROR
, MB_OK
);
79 if (Globals
.win_list
) return NULL
;
84 /******************************************************************
85 * WINHELP_GetWindowInfo
89 HLPFILE_WINDOWINFO
* WINHELP_GetWindowInfo(HLPFILE
* hlpfile
, LPCSTR name
)
91 static HLPFILE_WINDOWINFO mwi
;
94 if (!name
|| !name
[0])
95 name
= Globals
.active_win
->lpszName
;
98 for (i
= 0; i
< hlpfile
->numWindows
; i
++)
99 if (!strcmp(hlpfile
->windows
[i
].name
, name
))
100 return &hlpfile
->windows
[i
];
102 if (strcmp(name
, "main") != 0)
104 WINE_FIXME("Couldn't find window info for %s\n", name
);
110 strcpy(mwi
.type
, "primary");
111 strcpy(mwi
.name
, "main");
112 if (!LoadString(Globals
.hInstance
, STID_WINE_HELP
,
113 mwi
.caption
, sizeof(mwi
.caption
)))
114 strcpy(mwi
.caption
, hlpfile
->lpszTitle
);
115 mwi
.origin
.x
= mwi
.origin
.y
= mwi
.size
.cx
= mwi
.size
.cy
= CW_USEDEFAULT
;
117 mwi
.sr_color
= mwi
.sr_color
= 0xFFFFFF;
122 /******************************************************************
123 * HLPFILE_GetPopupWindowInfo
127 HLPFILE_WINDOWINFO
* WINHELP_GetPopupWindowInfo(HLPFILE
* hlpfile
, HWND hParentWnd
, POINT
* mouse
)
129 static HLPFILE_WINDOWINFO wi
;
133 wi
.type
[0] = wi
.name
[0] = wi
.caption
[0] = '\0';
135 /* Calculate horizontal size and position of a popup window */
136 GetWindowRect(hParentWnd
, &parent_rect
);
137 wi
.size
.cx
= (parent_rect
.right
- parent_rect
.left
) / 2;
138 wi
.size
.cy
= 10; /* need a non null value, so that border are taken into account while computing */
141 ClientToScreen(hParentWnd
, &wi
.origin
);
142 wi
.origin
.x
-= wi
.size
.cx
/ 2;
143 wi
.origin
.x
= min(wi
.origin
.x
, GetSystemMetrics(SM_CXSCREEN
) - wi
.size
.cx
);
144 wi
.origin
.x
= max(wi
.origin
.x
, 0);
147 wi
.win_style
= WS_POPUPWINDOW
;
148 wi
.sr_color
= wi
.sr_color
= 0xFFFFFF;
153 /***********************************************************************
157 int PASCAL
WinMain(HINSTANCE hInstance
, HINSTANCE prev
, LPSTR cmdline
, int show
)
163 Globals
.hInstance
= hInstance
;
166 while (*cmdline
&& (*cmdline
== ' ' || *cmdline
== '-'))
170 if (*cmdline
++ == ' ') continue;
173 if (option
) cmdline
++;
174 while (*cmdline
&& *cmdline
== ' ') cmdline
++;
180 while (*cmdline
&& *cmdline
!= ' ') cmdline
++;
181 if (*cmdline
) *cmdline
++ = '\0';
182 lHash
= HLPFILE_Hash(topic_id
);
187 Globals
.wVersion
= option
- '0';
192 Globals
.isBook
= FALSE
;
196 WINE_FIXME("Unsupported cmd line: %s\n", cmdline
);
201 /* Create primary window */
202 WINHELP_RegisterWinClasses();
205 hlpfile
= WINHELP_LookupHelpFile(cmdline
);
206 if (!hlpfile
) return 0;
209 WINHELP_CreateHelpWindowByHash(hlpfile
, lHash
,
210 WINHELP_GetWindowInfo(hlpfile
, "main"), show
);
213 while (GetMessage(&msg
, 0, 0, 0))
215 TranslateMessage(&msg
);
216 DispatchMessage(&msg
);
221 /***********************************************************************
225 static BOOL
WINHELP_RegisterWinClasses(void)
227 WNDCLASS class_main
, class_button_box
, class_text
, class_shadow
, class_history
;
229 class_main
.style
= CS_HREDRAW
| CS_VREDRAW
;
230 class_main
.lpfnWndProc
= WINHELP_MainWndProc
;
231 class_main
.cbClsExtra
= 0;
232 class_main
.cbWndExtra
= sizeof(LONG
);
233 class_main
.hInstance
= Globals
.hInstance
;
234 class_main
.hIcon
= LoadIcon(0, IDI_APPLICATION
);
235 class_main
.hCursor
= LoadCursor(0, IDC_ARROW
);
236 class_main
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
237 class_main
.lpszMenuName
= 0;
238 class_main
.lpszClassName
= MAIN_WIN_CLASS_NAME
;
240 class_button_box
= class_main
;
241 class_button_box
.lpfnWndProc
= WINHELP_ButtonBoxWndProc
;
242 class_button_box
.hbrBackground
= GetStockObject(GRAY_BRUSH
);
243 class_button_box
.lpszClassName
= BUTTON_BOX_WIN_CLASS_NAME
;
245 class_text
= class_main
;
246 class_text
.lpfnWndProc
= WINHELP_TextWndProc
;
247 class_text
.lpszClassName
= TEXT_WIN_CLASS_NAME
;
249 class_shadow
= class_main
;
250 class_shadow
.lpfnWndProc
= DefWindowProc
;
251 class_shadow
.hbrBackground
= GetStockObject(GRAY_BRUSH
);
252 class_shadow
.lpszClassName
= SHADOW_WIN_CLASS_NAME
;
254 class_history
= class_main
;
255 class_history
.lpfnWndProc
= WINHELP_HistoryWndProc
;
256 class_history
.lpszClassName
= HISTORY_WIN_CLASS_NAME
;
258 return (RegisterClass(&class_main
) &&
259 RegisterClass(&class_button_box
) &&
260 RegisterClass(&class_text
) &&
261 RegisterClass(&class_shadow
) &&
262 RegisterClass(&class_history
));
273 } WINHELP
,*LPWINHELP
;
275 /******************************************************************
276 * WINHELP_HandleCommand
280 static LRESULT
WINHELP_HandleCommand(HWND hSrcWnd
, LPARAM lParam
)
282 COPYDATASTRUCT
* cds
= (COPYDATASTRUCT
*)lParam
;
285 if (cds
->dwData
!= 0xA1DE505)
287 WINE_FIXME("Wrong magic number (%08lx)\n", cds
->dwData
);
291 wh
= (WINHELP
*)cds
->lpData
;
295 char* ptr
= (wh
->ofsFilename
) ? (LPSTR
)wh
+ wh
->ofsFilename
: NULL
;
297 WINE_TRACE("Got[%u]: cmd=%u data=%08lx fn=%s\n",
298 wh
->size
, wh
->command
, wh
->data
, ptr
);
304 MACRO_JumpContext(ptr
, "main", wh
->data
);
313 MACRO_JumpContents(ptr
, "main");
316 case HELP_HELPONHELP
:
319 /* case HELP_SETINDEX: */
320 case HELP_SETCONTENTS
:
323 MACRO_SetContents(ptr
, wh
->data
);
326 case HELP_CONTEXTPOPUP
:
329 MACRO_PopupContext(ptr
, wh
->data
);
332 /* case HELP_FORCEFILE:*/
333 /* case HELP_CONTEXTMENU: */
335 /* in fact, should be the topic dialog box */
338 MACRO_JumpHash(ptr
, "main", 0);
341 /* case HELP_WM_HELP: */
342 /* case HELP_SETPOPUP_POS: */
344 /* case HELP_COMMAND: */
345 /* case HELP_PARTIALKEY: */
346 /* case HELP_MULTIKEY: */
347 /* case HELP_SETWINPOS: */
348 WINE_FIXME("Unknown command (%x) for remote winhelp control\n", wh
->command
);
355 /******************************************************************
356 * WINHELP_ReuseWindow
360 static BOOL
WINHELP_ReuseWindow(WINHELP_WINDOW
* win
, WINHELP_WINDOW
* oldwin
,
361 HLPFILE_PAGE
* page
, int nCmdShow
)
365 win
->hMainWnd
= oldwin
->hMainWnd
;
366 win
->hButtonBoxWnd
= oldwin
->hButtonBoxWnd
;
367 win
->hTextWnd
= oldwin
->hTextWnd
;
368 win
->hHistoryWnd
= oldwin
->hHistoryWnd
;
369 oldwin
->hMainWnd
= oldwin
->hButtonBoxWnd
= oldwin
->hTextWnd
= oldwin
->hHistoryWnd
= 0;
371 SetWindowLong(win
->hMainWnd
, 0, (LONG
)win
);
372 SetWindowLong(win
->hButtonBoxWnd
, 0, (LONG
)win
);
373 SetWindowLong(win
->hTextWnd
, 0, (LONG
)win
);
374 SetWindowLong(win
->hHistoryWnd
, 0, (LONG
)win
);
376 WINHELP_InitFonts(win
->hMainWnd
);
379 SetWindowText(win
->hMainWnd
, page
->file
->lpszTitle
);
381 WINHELP_SetupText(win
->hTextWnd
);
382 InvalidateRect(win
->hTextWnd
, NULL
, TRUE
);
383 SendMessage(win
->hMainWnd
, WM_USER
, 0, 0);
384 ShowWindow(win
->hMainWnd
, nCmdShow
);
385 UpdateWindow(win
->hTextWnd
);
387 if (!(win
->info
->win_style
& WS_POPUP
))
391 memcpy(win
->history
, oldwin
->history
, sizeof(win
->history
));
392 win
->histIndex
= oldwin
->histIndex
;
394 /* FIXME: when using back, we shouldn't update the history... */
398 for (i
= 0; i
< win
->histIndex
; i
++)
399 if (win
->history
[i
] == page
) break;
401 /* if the new page is already in the history, do nothing */
402 if (i
== win
->histIndex
)
404 num
= sizeof(win
->history
) / sizeof(win
->history
[0]);
405 if (win
->histIndex
== num
)
407 /* we're full, remove latest entry */
408 HLPFILE_FreeHlpFile(win
->history
[0]->file
);
409 memmove(&win
->history
[0], &win
->history
[1],
410 (num
- 1) * sizeof(win
->history
[0]));
413 win
->history
[win
->histIndex
++] = page
;
414 page
->file
->wRefCount
++;
415 if (win
->hHistoryWnd
) InvalidateRect(win
->hHistoryWnd
, NULL
, TRUE
);
419 memcpy(win
->back
, oldwin
->back
, sizeof(win
->back
));
420 win
->backIndex
= oldwin
->backIndex
;
424 num
= sizeof(win
->back
) / sizeof(win
->back
[0]);
425 if (win
->backIndex
== num
)
427 /* we're full, remove latest entry */
428 HLPFILE_FreeHlpFile(win
->back
[0]->file
);
429 memmove(&win
->back
[0], &win
->back
[1],
430 (num
- 1) * sizeof(win
->back
[0]));
433 win
->back
[win
->backIndex
++] = page
;
434 page
->file
->wRefCount
++;
438 win
->backIndex
= win
->histIndex
= 0;
440 oldwin
->histIndex
= oldwin
->backIndex
= 0;
441 WINHELP_DeleteWindow(oldwin
);
445 /***********************************************************************
447 * WINHELP_CreateHelpWindow
449 BOOL
WINHELP_CreateHelpWindow(HLPFILE_PAGE
* page
, HLPFILE_WINDOWINFO
* wi
,
452 WINHELP_WINDOW
*win
, *oldwin
;
457 bPrimary
= !lstrcmpi(wi
->name
, "main");
458 bPopup
= wi
->win_style
& WS_POPUP
;
460 /* Initialize WINHELP_WINDOW struct */
461 win
= HeapAlloc(GetProcessHeap(), 0,
462 sizeof(WINHELP_WINDOW
) + strlen(wi
->name
) + 1);
463 if (!win
) return FALSE
;
465 win
->next
= Globals
.win_list
;
466 Globals
.win_list
= win
;
468 win
->lpszName
= (char*)win
+ sizeof(WINHELP_WINDOW
);
469 lstrcpy((char*)win
->lpszName
, wi
->name
);
472 win
->first_button
= 0;
475 win
->hButtonBoxWnd
= 0;
478 win
->hHistoryWnd
= 0;
480 win
->hArrowCur
= LoadCursorA(0, IDC_ARROWA
);
481 win
->hHandCur
= LoadCursorA(0, IDC_HANDA
);
485 Globals
.active_win
= win
;
487 /* Initialize default pushbuttons */
488 if (bPrimary
&& page
)
490 CHAR buffer
[MAX_STRING_LEN
];
492 LoadString(Globals
.hInstance
, STID_CONTENTS
, buffer
, sizeof(buffer
));
493 MACRO_CreateButton("BTN_CONTENTS", buffer
, "Contents()");
494 LoadString(Globals
.hInstance
, STID_SEARCH
,buffer
, sizeof(buffer
));
495 MACRO_CreateButton("BTN_SEARCH", buffer
, "Search()");
496 LoadString(Globals
.hInstance
, STID_BACK
, buffer
, sizeof(buffer
));
497 MACRO_CreateButton("BTN_BACK", buffer
, "Back()");
498 LoadString(Globals
.hInstance
, STID_HISTORY
, buffer
, sizeof(buffer
));
499 MACRO_CreateButton("BTN_HISTORY", buffer
, "History()");
500 LoadString(Globals
.hInstance
, STID_TOPICS
, buffer
, sizeof(buffer
));
501 MACRO_CreateButton("BTN_TOPICS", buffer
, "Finder()");
504 /* Initialize file specific pushbuttons */
505 if (!(wi
->win_style
& WS_POPUP
) && page
)
507 HLPFILE_MACRO
*macro
;
508 for (macro
= page
->file
->first_macro
; macro
; macro
= macro
->next
)
509 MACRO_ExecuteMacro(macro
->lpszMacro
);
511 for (macro
= page
->first_macro
; macro
; macro
= macro
->next
)
512 MACRO_ExecuteMacro(macro
->lpszMacro
);
515 win
->histIndex
= win
->backIndex
= 0;
516 /* Reuse existing window */
519 for (oldwin
= win
->next
; oldwin
; oldwin
= oldwin
->next
)
521 if (!lstrcmpi(oldwin
->lpszName
, wi
->name
))
523 return WINHELP_ReuseWindow(win
, oldwin
, page
, nCmdShow
);
528 win
->histIndex
= win
->backIndex
= 1;
529 win
->history
[0] = win
->back
[0] = page
;
530 page
->file
->wRefCount
+= 2;
534 hWnd
= CreateWindow(bPopup
? TEXT_WIN_CLASS_NAME
: MAIN_WIN_CLASS_NAME
,
535 wi
->caption
, wi
->win_style
,
536 wi
->origin
.x
, wi
->origin
.y
, wi
->size
.cx
, wi
->size
.cy
,
537 0, bPrimary
? LoadMenu(Globals
.hInstance
, MAKEINTRESOURCE(MAIN_MENU
)) : 0,
538 Globals
.hInstance
, win
);
540 ShowWindow(hWnd
, nCmdShow
);
546 /***********************************************************************
548 * WINHELP_CreateHelpWindowByHash
550 BOOL
WINHELP_CreateHelpWindowByHash(HLPFILE
* hlpfile
, LONG lHash
,
551 HLPFILE_WINDOWINFO
* wi
, int nCmdShow
)
553 HLPFILE_PAGE
* page
= NULL
;
556 page
= lHash
? HLPFILE_PageByHash(hlpfile
, lHash
) :
557 HLPFILE_Contents(hlpfile
);
558 if (page
) page
->file
->wRefCount
++;
559 return WINHELP_CreateHelpWindow(page
, wi
, nCmdShow
);
562 /***********************************************************************
564 * WINHELP_MainWndProc
566 static LRESULT CALLBACK
WINHELP_MainWndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
569 WINHELP_BUTTON
*button
;
570 RECT rect
, button_box_rect
;
573 WINHELP_CheckPopup(msg
);
578 win
= (WINHELP_WINDOW
*) ((LPCREATESTRUCT
) lParam
)->lpCreateParams
;
579 SetWindowLong(hWnd
, 0, (LONG
) win
);
580 win
->hMainWnd
= hWnd
;
584 win
= (WINHELP_WINDOW
*) GetWindowLong(hWnd
, 0);
586 /* Create button box and text Window */
587 CreateWindow(BUTTON_BOX_WIN_CLASS_NAME
, "", WS_CHILD
| WS_VISIBLE
,
588 0, 0, 0, 0, hWnd
, 0, Globals
.hInstance
, win
);
590 CreateWindow(TEXT_WIN_CLASS_NAME
, "", WS_CHILD
| WS_VISIBLE
,
591 0, 0, 0, 0, hWnd
, 0, Globals
.hInstance
, win
);
595 case WM_WINDOWPOSCHANGED
:
596 win
= (WINHELP_WINDOW
*) GetWindowLong(hWnd
, 0);
597 GetClientRect(hWnd
, &rect
);
599 /* Update button box and text Window */
600 SetWindowPos(win
->hButtonBoxWnd
, HWND_TOP
,
602 rect
.right
- rect
.left
,
603 rect
.bottom
- rect
.top
, 0);
605 GetWindowRect(win
->hButtonBoxWnd
, &button_box_rect
);
606 text_top
= rect
.top
+ button_box_rect
.bottom
- button_box_rect
.top
;
608 SetWindowPos(win
->hTextWnd
, HWND_TOP
,
610 rect
.right
- rect
.left
,
611 rect
.bottom
- text_top
, 0);
616 Globals
.active_win
= win
= (WINHELP_WINDOW
*) GetWindowLong(hWnd
, 0);
620 case MNID_FILE_OPEN
: MACRO_FileOpen(); break;
621 case MNID_FILE_PRINT
: MACRO_Print(); break;
622 case MNID_FILE_SETUP
: MACRO_PrinterSetup(); break;
623 case MNID_FILE_EXIT
: MACRO_Exit(); break;
626 case MNID_EDIT_COPYDLG
: MACRO_CopyDialog(); break;
627 case MNID_EDIT_ANNOTATE
:MACRO_Annotate(); break;
630 case MNID_BKMK_DEFINE
: MACRO_BookmarkDefine(); break;
633 case MNID_HELP_HELPON
: MACRO_HelpOn(); break;
634 case MNID_HELP_HELPTOP
: MACRO_HelpOnTop(); break;
635 case MNID_HELP_ABOUT
: MACRO_About(); break;
636 case MNID_HELP_WINE
: ShellAbout(hWnd
, "WINE", "Help", 0); break;
640 for (button
= win
->first_button
; button
; button
= button
->next
)
641 if (wParam
== button
->wParam
) break;
643 MACRO_ExecuteMacro(button
->lpszMacro
);
645 WINHELP_MessageBoxIDS(STID_NOT_IMPLEMENTED
, 0x121, MB_OK
);
650 if (Globals
.hPopupWnd
) DestroyWindow(Globals
.hPopupWnd
);
653 return WINHELP_HandleCommand((HWND
)wParam
, lParam
);
655 return DefWindowProc(hWnd
, msg
, wParam
, lParam
);
658 /***********************************************************************
660 * WINHELP_ButtonBoxWndProc
662 static LRESULT CALLBACK
WINHELP_ButtonBoxWndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
666 WINHELP_BUTTON
*button
;
670 WINHELP_CheckPopup(msg
);
675 win
= (WINHELP_WINDOW
*) ((LPCREATESTRUCT
) lParam
)->lpCreateParams
;
676 SetWindowLong(hWnd
, 0, (LONG
) win
);
677 win
->hButtonBoxWnd
= hWnd
;
680 case WM_WINDOWPOSCHANGING
:
681 winpos
= (WINDOWPOS
*) lParam
;
682 win
= (WINHELP_WINDOW
*) GetWindowLong(hWnd
, 0);
687 for (button
= win
->first_button
; button
; button
= button
->next
)
692 button
->hWnd
= CreateWindow(STRING_BUTTON
, (LPSTR
) button
->lpszName
,
693 WS_CHILD
| WS_VISIBLE
| BS_PUSHBUTTON
,
695 hWnd
, (HMENU
) button
->wParam
,
696 Globals
.hInstance
, 0);
697 hDc
= GetDC(button
->hWnd
);
698 GetTextExtentPoint(hDc
, button
->lpszName
,
699 lstrlen(button
->lpszName
), &textsize
);
700 ReleaseDC(button
->hWnd
, hDc
);
702 button_size
.cx
= max(button_size
.cx
, textsize
.cx
+ BUTTON_CX
);
703 button_size
.cy
= max(button_size
.cy
, textsize
.cy
+ BUTTON_CY
);
708 for (button
= win
->first_button
; button
; button
= button
->next
)
710 SetWindowPos(button
->hWnd
, HWND_TOP
, x
, y
, button_size
.cx
, button_size
.cy
, 0);
712 if (x
+ 2 * button_size
.cx
<= winpos
->cx
)
715 x
= 0, y
+= button_size
.cy
;
717 winpos
->cy
= y
+ (x
? button_size
.cy
: 0);
721 SendMessage(GetParent(hWnd
), msg
, wParam
, lParam
);
725 return DefWindowProc(hWnd
, msg
, wParam
, lParam
);
728 /***********************************************************************
730 * WINHELP_TextWndProc
732 static LRESULT CALLBACK
WINHELP_TextWndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
736 WINHELP_LINE_PART
*part
;
745 if (msg
!= WM_LBUTTONDOWN
)
746 WINHELP_CheckPopup(msg
);
751 win
= (WINHELP_WINDOW
*) ((LPCREATESTRUCT
) lParam
)->lpCreateParams
;
752 SetWindowLong(hWnd
, 0, (LONG
) win
);
753 win
->hTextWnd
= hWnd
;
754 if (win
->info
->win_style
& WS_POPUP
) Globals
.hPopupWnd
= win
->hMainWnd
= hWnd
;
755 WINHELP_InitFonts(hWnd
);
759 win
= (WINHELP_WINDOW
*) GetWindowLong(hWnd
, 0);
761 /* Calculate vertical size and position of a popup window */
762 if (win
->info
->win_style
& WS_POPUP
)
765 RECT old_window_rect
;
766 RECT old_client_rect
;
767 SIZE old_window_size
;
768 SIZE old_client_size
;
769 SIZE new_client_size
;
770 SIZE new_window_size
;
772 GetWindowRect(hWnd
, &old_window_rect
);
773 origin
.x
= old_window_rect
.left
;
774 origin
.y
= old_window_rect
.top
;
775 old_window_size
.cx
= old_window_rect
.right
- old_window_rect
.left
;
776 old_window_size
.cy
= old_window_rect
.bottom
- old_window_rect
.top
;
778 GetClientRect(hWnd
, &old_client_rect
);
779 old_client_size
.cx
= old_client_rect
.right
- old_client_rect
.left
;
780 old_client_size
.cy
= old_client_rect
.bottom
- old_client_rect
.top
;
782 new_client_size
= old_client_size
;
783 WINHELP_SplitLines(hWnd
, &new_client_size
);
785 if (origin
.y
+ POPUP_YDISTANCE
+ new_client_size
.cy
<= GetSystemMetrics(SM_CYSCREEN
))
786 origin
.y
+= POPUP_YDISTANCE
;
788 origin
.y
-= POPUP_YDISTANCE
+ new_client_size
.cy
;
790 new_window_size
.cx
= old_window_size
.cx
- old_client_size
.cx
+ new_client_size
.cx
;
791 new_window_size
.cy
= old_window_size
.cy
- old_client_size
.cy
+ new_client_size
.cy
;
794 CreateWindow(SHADOW_WIN_CLASS_NAME
, "", WS_POPUP
,
795 origin
.x
+ SHADOW_DX
, origin
.y
+ SHADOW_DY
,
796 new_window_size
.cx
, new_window_size
.cy
,
797 0, 0, Globals
.hInstance
, 0);
799 SetWindowPos(hWnd
, HWND_TOP
, origin
.x
, origin
.y
,
800 new_window_size
.cx
, new_window_size
.cy
,
802 SetWindowPos(win
->hShadowWnd
, hWnd
, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOACTIVATE
);
803 ShowWindow(win
->hShadowWnd
, SW_NORMAL
);
804 SetActiveWindow(hWnd
);
808 case WM_WINDOWPOSCHANGED
:
809 winpos
= (WINDOWPOS
*) lParam
;
811 if (!(winpos
->flags
& SWP_NOSIZE
)) WINHELP_SetupText(hWnd
);
819 INT CurPos
= GetScrollPos(hWnd
, SB_VERT
);
822 GetScrollRange(hWnd
, SB_VERT
, &Min
, &Max
);
823 GetClientRect(hWnd
, &rect
);
825 switch (wParam
& 0xffff)
828 case SB_THUMBPOSITION
: CurPos
= wParam
>> 16; break;
829 case SB_TOP
: CurPos
= Min
; break;
830 case SB_BOTTOM
: CurPos
= Max
; break;
831 case SB_PAGEUP
: CurPos
-= (rect
.bottom
- rect
.top
) / 2; break;
832 case SB_PAGEDOWN
: CurPos
+= (rect
.bottom
- rect
.top
) / 2; break;
833 case SB_LINEUP
: CurPos
-= GetSystemMetrics(SM_CXVSCROLL
); break;
834 case SB_LINEDOWN
: CurPos
+= GetSystemMetrics(SM_CXVSCROLL
); break;
835 default: update
= FALSE
;
841 else if (CurPos
< Min
)
843 dy
= GetScrollPos(hWnd
, SB_VERT
) - CurPos
;
844 SetScrollPos(hWnd
, SB_VERT
, CurPos
, TRUE
);
845 ScrollWindow(hWnd
, 0, dy
, NULL
, NULL
);
852 hDc
= BeginPaint(hWnd
, &ps
);
853 win
= (WINHELP_WINDOW
*) GetWindowLong(hWnd
, 0);
854 scroll_pos
= GetScrollPos(hWnd
, SB_VERT
);
856 for (line
= win
->first_line
; line
; line
= line
->next
)
858 for (part
= &line
->first_part
; part
; part
= part
->next
)
860 switch (part
->cookie
)
862 case hlp_line_part_text
:
863 SelectObject(hDc
, part
->u
.text
.hFont
);
864 SetTextColor(hDc
, part
->u
.text
.color
);
865 TextOut(hDc
, part
->rect
.left
, part
->rect
.top
- scroll_pos
,
866 part
->u
.text
.lpsText
, part
->u
.text
.wTextLen
);
867 if (part
->u
.text
.wUnderline
)
871 switch (part
->u
.text
.wUnderline
)
875 hPen
= CreatePen(PS_SOLID
, 1, part
->u
.text
.color
);
878 hPen
= CreatePen(PS_DOT
, 1, part
->u
.text
.color
);
881 WINE_FIXME("Unknow underline type\n");
885 SelectObject(hDc
, hPen
);
886 MoveToEx(hDc
, part
->rect
.left
, part
->rect
.bottom
- scroll_pos
- 1, NULL
);
887 LineTo(hDc
, part
->rect
.right
, part
->rect
.bottom
- scroll_pos
- 1);
888 if (part
->u
.text
.wUnderline
== 2)
890 MoveToEx(hDc
, part
->rect
.left
, part
->rect
.bottom
- scroll_pos
+ 1, NULL
);
891 LineTo(hDc
, part
->rect
.right
, part
->rect
.bottom
- scroll_pos
+ 1);
896 case hlp_line_part_bitmap
:
900 hMemDC
= CreateCompatibleDC(hDc
);
901 SelectObject(hMemDC
, part
->u
.bitmap
.hBitmap
);
902 BitBlt(hDc
, part
->rect
.left
, part
->rect
.top
- scroll_pos
,
903 part
->rect
.right
- part
->rect
.left
, part
->rect
.bottom
- part
->rect
.top
,
904 hMemDC
, 0, 0, SRCCOPY
);
908 case hlp_line_part_metafile
:
912 SetViewportOrgEx(hDc
, part
->rect
.left
, part
->rect
.top
- scroll_pos
, &pt
);
913 PlayMetaFile(hDc
, part
->u
.metafile
.hMetaFile
);
914 SetViewportOrgEx(hDc
, pt
.x
, pt
.y
, NULL
);
925 win
= (WINHELP_WINDOW
*) GetWindowLong(hWnd
, 0);
927 if (WINHELP_IsOverLink(win
, wParam
, lParam
))
928 SetCursor(win
->hHandCur
); /* set to hand pointer cursor to indicate a link */
930 SetCursor(win
->hArrowCur
); /* set to hand pointer cursor to indicate a link */
935 win
= (WINHELP_WINDOW
*) GetWindowLong(hWnd
, 0);
937 hPopupWnd
= Globals
.hPopupWnd
;
938 Globals
.hPopupWnd
= 0;
940 part
= WINHELP_IsOverLink(win
, wParam
, lParam
);
944 HLPFILE_WINDOWINFO
* wi
;
946 mouse
.x
= LOWORD(lParam
);
947 mouse
.y
= HIWORD(lParam
);
949 if (part
->link
) switch (part
->link
->cookie
)
952 hlpfile
= WINHELP_LookupHelpFile(part
->link
->lpszString
);
953 if (part
->link
->window
== -1)
955 else if (part
->link
->window
< hlpfile
->numWindows
)
956 wi
= &hlpfile
->windows
[part
->link
->window
];
959 WINE_WARN("link to window %d/%d\n", part
->link
->window
, hlpfile
->numWindows
);
962 WINHELP_CreateHelpWindowByHash(hlpfile
, part
->link
->lHash
, wi
,
966 hlpfile
= WINHELP_LookupHelpFile(part
->link
->lpszString
);
967 WINHELP_CreateHelpWindowByHash(hlpfile
, part
->link
->lHash
,
968 WINHELP_GetPopupWindowInfo(hlpfile
, hWnd
, &mouse
),
972 MACRO_ExecuteMacro(part
->link
->lpszString
);
975 WINE_FIXME("Unknown link cookie %d\n", part
->link
->cookie
);
980 DestroyWindow(hPopupWnd
);
984 win
= (WINHELP_WINDOW
*) GetWindowLong(hWnd
, 0);
986 if (hWnd
== Globals
.hPopupWnd
) Globals
.hPopupWnd
= 0;
988 bExit
= (Globals
.wVersion
>= 4 && !lstrcmpi(win
->lpszName
, "main"));
990 WINHELP_DeleteWindow(win
);
992 if (bExit
) MACRO_Exit();
994 if (!Globals
.win_list
)
999 return DefWindowProc(hWnd
, msg
, wParam
, lParam
);
1002 /******************************************************************
1003 * WINHELP_HistoryWndProc
1007 static LRESULT CALLBACK
WINHELP_HistoryWndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
1009 WINHELP_WINDOW
* win
;
1019 win
= (WINHELP_WINDOW
*)((LPCREATESTRUCT
)lParam
)->lpCreateParams
;
1020 SetWindowLong(hWnd
, 0, (LONG
)win
);
1021 win
->hHistoryWnd
= hWnd
;
1024 win
= (WINHELP_WINDOW
*) GetWindowLong(hWnd
, 0);
1026 GetTextMetrics(hDc
, &tm
);
1027 GetWindowRect(hWnd
, &r
);
1029 r
.right
= r
.left
+ 30 * tm
.tmAveCharWidth
;
1030 r
.bottom
= r
.top
+ (sizeof(win
->history
) / sizeof(win
->history
[0])) * tm
.tmHeight
;
1031 AdjustWindowRect(&r
, GetWindowLong(hWnd
, GWL_STYLE
), FALSE
);
1032 if (r
.left
< 0) {r
.right
-= r
.left
; r
.left
= 0;}
1033 if (r
.top
< 0) {r
.bottom
-= r
.top
; r
.top
= 0;}
1035 MoveWindow(hWnd
, r
.left
, r
.top
, r
.right
, r
.bottom
, TRUE
);
1036 ReleaseDC(hWnd
, hDc
);
1038 case WM_LBUTTONDOWN
:
1039 win
= (WINHELP_WINDOW
*) GetWindowLong(hWnd
, 0);
1041 GetTextMetrics(hDc
, &tm
);
1042 i
= HIWORD(lParam
) / tm
.tmHeight
;
1043 if (i
< win
->histIndex
)
1044 WINHELP_CreateHelpWindow(win
->history
[i
], win
->info
, SW_SHOW
);
1045 ReleaseDC(hWnd
, hDc
);
1048 hDc
= BeginPaint(hWnd
, &ps
);
1049 win
= (WINHELP_WINDOW
*) GetWindowLong(hWnd
, 0);
1050 GetTextMetrics(hDc
, &tm
);
1052 for (i
= 0; i
< win
->histIndex
; i
++)
1054 TextOut(hDc
, 0, i
* tm
.tmHeight
, win
->history
[i
]->lpszTitle
,
1055 strlen(win
->history
[i
]->lpszTitle
));
1057 EndPaint(hWnd
, &ps
);
1060 win
= (WINHELP_WINDOW
*) GetWindowLong(hWnd
, 0);
1061 if (hWnd
== win
->hHistoryWnd
)
1062 win
->hHistoryWnd
= 0;
1065 return DefWindowProc(hWnd
, msg
, wParam
, lParam
);
1068 /***********************************************************************
1072 static void WINHELP_SetupText(HWND hWnd
)
1074 HDC hDc
= GetDC(hWnd
);
1078 ShowScrollBar(hWnd
, SB_VERT
, FALSE
);
1079 if (!WINHELP_SplitLines(hWnd
, NULL
))
1081 ShowScrollBar(hWnd
, SB_VERT
, TRUE
);
1082 GetClientRect(hWnd
, &rect
);
1084 WINHELP_SplitLines(hWnd
, &newsize
);
1085 SetScrollRange(hWnd
, SB_VERT
, 0, rect
.top
+ newsize
.cy
- rect
.bottom
, TRUE
);
1087 else SetScrollPos(hWnd
, SB_VERT
, 0, FALSE
);
1089 ReleaseDC(hWnd
, hDc
);
1092 /***********************************************************************
1094 * WINHELP_AppendText
1096 static BOOL
WINHELP_AppendText(WINHELP_LINE
***linep
, WINHELP_LINE_PART
***partp
,
1097 LPSIZE space
, LPSIZE textsize
,
1098 INT
*line_ascent
, INT ascent
,
1099 LPCSTR text
, UINT textlen
,
1100 HFONT font
, COLORREF color
, HLPFILE_LINK
*link
,
1104 WINHELP_LINE_PART
*part
;
1107 if (!*partp
) /* New line */
1109 *line_ascent
= ascent
;
1111 line
= HeapAlloc(GetProcessHeap(), 0,
1112 sizeof(WINHELP_LINE
) + textlen
);
1113 if (!line
) return FALSE
;
1116 part
= &line
->first_part
;
1117 ptr
= (char*)line
+ sizeof(WINHELP_LINE
);
1119 line
->rect
.top
= (**linep
? (**linep
)->rect
.bottom
: 0) + space
->cy
;
1120 line
->rect
.bottom
= line
->rect
.top
;
1121 line
->rect
.left
= space
->cx
;
1122 line
->rect
.right
= space
->cx
;
1124 if (**linep
) *linep
= &(**linep
)->next
;
1128 else /* Same line */
1132 if (*line_ascent
< ascent
)
1134 WINHELP_LINE_PART
*p
;
1135 for (p
= &line
->first_part
; p
; p
= p
->next
)
1137 p
->rect
.top
+= ascent
- *line_ascent
;
1138 p
->rect
.bottom
+= ascent
- *line_ascent
;
1140 line
->rect
.bottom
+= ascent
- *line_ascent
;
1141 *line_ascent
= ascent
;
1144 part
= HeapAlloc(GetProcessHeap(), 0,
1145 sizeof(WINHELP_LINE_PART
) + textlen
);
1146 if (!part
) return FALSE
;
1148 ptr
= (char*)part
+ sizeof(WINHELP_LINE_PART
);
1151 memcpy(ptr
, text
, textlen
);
1152 part
->cookie
= hlp_line_part_text
;
1153 part
->rect
.left
= line
->rect
.right
+ (*partp
? space
->cx
: 0);
1154 part
->rect
.right
= part
->rect
.left
+ textsize
->cx
;
1155 line
->rect
.right
= part
->rect
.right
;
1157 ((*partp
) ? line
->rect
.top
: line
->rect
.bottom
) + *line_ascent
- ascent
;
1158 part
->rect
.bottom
= part
->rect
.top
+ textsize
->cy
;
1159 line
->rect
.bottom
= max(line
->rect
.bottom
, part
->rect
.bottom
);
1160 part
->u
.text
.lpsText
= ptr
;
1161 part
->u
.text
.wTextLen
= textlen
;
1162 part
->u
.text
.hFont
= font
;
1163 part
->u
.text
.color
= color
;
1164 part
->u
.text
.wUnderline
= underline
;
1166 WINE_TRACE("Appended text '%*.*s'[%d] @ (%ld,%ld-%ld,%ld)\n",
1167 part
->u
.text
.wTextLen
,
1168 part
->u
.text
.wTextLen
,
1169 part
->u
.text
.lpsText
,
1170 part
->u
.text
.wTextLen
,
1171 part
->rect
.left
, part
->rect
.top
, part
->rect
.right
, part
->rect
.bottom
);
1174 if (link
) link
->wRefCount
++;
1177 *partp
= &part
->next
;
1184 /***********************************************************************
1186 * WINHELP_AppendGfxObject
1188 static WINHELP_LINE_PART
* WINHELP_AppendGfxObject(WINHELP_LINE
***linep
, WINHELP_LINE_PART
***partp
,
1189 LPSIZE space
, LPSIZE gfxSize
,
1190 HLPFILE_LINK
*link
, unsigned pos
)
1193 WINHELP_LINE_PART
*part
;
1196 if (!*partp
|| pos
== 1) /* New line */
1198 line
= HeapAlloc(GetProcessHeap(), 0, sizeof(WINHELP_LINE
));
1199 if (!line
) return NULL
;
1202 part
= &line
->first_part
;
1204 line
->rect
.top
= (**linep
? (**linep
)->rect
.bottom
: 0) + space
->cy
;
1205 line
->rect
.bottom
= line
->rect
.top
;
1206 line
->rect
.left
= space
->cx
;
1207 line
->rect
.right
= space
->cx
;
1209 if (**linep
) *linep
= &(**linep
)->next
;
1212 ptr
= (char*)line
+ sizeof(WINHELP_LINE
);
1214 else /* Same line */
1216 if (pos
== 2) WINE_FIXME("Left alignment not handled\n");
1219 part
= HeapAlloc(GetProcessHeap(), 0, sizeof(WINHELP_LINE_PART
));
1220 if (!part
) return NULL
;
1222 ptr
= (char*)part
+ sizeof(WINHELP_LINE_PART
);
1225 /* part->cookie should be set by caller (image or metafile) */
1226 part
->rect
.left
= line
->rect
.right
+ (*partp
? space
->cx
: 0);
1227 part
->rect
.right
= part
->rect
.left
+ gfxSize
->cx
;
1228 line
->rect
.right
= part
->rect
.right
;
1229 part
->rect
.top
= (*partp
) ? line
->rect
.top
: line
->rect
.bottom
;
1230 part
->rect
.bottom
= part
->rect
.top
+ gfxSize
->cy
;
1231 line
->rect
.bottom
= max(line
->rect
.bottom
, part
->rect
.bottom
);
1233 WINE_TRACE("Appended gfx @ (%ld,%ld-%ld,%ld)\n",
1234 part
->rect
.left
, part
->rect
.top
, part
->rect
.right
, part
->rect
.bottom
);
1237 if (link
) link
->wRefCount
++;
1240 *partp
= &part
->next
;
1248 /***********************************************************************
1250 * WINHELP_SplitLines
1252 static BOOL
WINHELP_SplitLines(HWND hWnd
, LPSIZE newsize
)
1254 WINHELP_WINDOW
*win
= (WINHELP_WINDOW
*) GetWindowLong(hWnd
, 0);
1255 HLPFILE_PARAGRAPH
*p
;
1256 WINHELP_LINE
**line
= &win
->first_line
;
1257 WINHELP_LINE_PART
**part
= 0;
1258 INT line_ascent
= 0;
1263 if (newsize
) newsize
->cx
= newsize
->cy
= 0;
1265 if (!win
->page
) return TRUE
;
1267 WINHELP_DeleteLines(win
);
1269 GetClientRect(hWnd
, &rect
);
1271 rect
.top
+= INTERNAL_BORDER_WIDTH
;
1272 rect
.left
+= INTERNAL_BORDER_WIDTH
;
1273 rect
.right
-= INTERNAL_BORDER_WIDTH
;
1274 rect
.bottom
-= INTERNAL_BORDER_WIDTH
;
1276 space
.cy
= rect
.top
;
1277 space
.cx
= rect
.left
;
1281 for (p
= win
->page
->first_paragraph
; p
; p
= p
->next
)
1285 case para_normal_text
:
1286 case para_debug_text
:
1289 SIZE textsize
= {0, 0};
1290 LPCSTR text
= p
->u
.text
.lpszText
;
1292 UINT len
= strlen(text
);
1293 unsigned underline
= 0;
1296 COLORREF color
= RGB(0, 0, 0);
1298 if (p
->u
.text
.wFont
< win
->page
->file
->numFonts
)
1300 HLPFILE
* hlpfile
= win
->page
->file
;
1302 if (!hlpfile
->fonts
[p
->u
.text
.wFont
].hFont
)
1303 hlpfile
->fonts
[p
->u
.text
.wFont
].hFont
= CreateFontIndirect(&hlpfile
->fonts
[p
->u
.text
.wFont
].LogFont
);
1304 hFont
= hlpfile
->fonts
[p
->u
.text
.wFont
].hFont
;
1305 color
= hlpfile
->fonts
[p
->u
.text
.wFont
].color
;
1309 UINT wFont
= (p
->u
.text
.wFont
< win
->fonts_len
) ? p
->u
.text
.wFont
: 0;
1311 hFont
= win
->fonts
[wFont
];
1314 if (p
->link
&& p
->link
->bClrChange
)
1316 underline
= (p
->link
->cookie
== hlp_link_popup
) ? 3 : 1;
1317 color
= RGB(0, 0x80, 0);
1319 if (p
->cookie
== para_debug_text
) color
= RGB(0xff, 0, 0);
1321 SelectObject(hDc
, hFont
);
1323 GetTextMetrics(hDc
, &tm
);
1325 if (p
->u
.text
.wIndent
)
1327 indent
= p
->u
.text
.wIndent
* 5 * tm
.tmAveCharWidth
;
1329 space
.cx
= rect
.left
+ indent
- 2 * tm
.tmAveCharWidth
;
1332 if (p
->u
.text
.wVSpace
)
1335 space
.cx
= rect
.left
+ indent
;
1336 space
.cy
+= (p
->u
.text
.wVSpace
- 1) * tm
.tmHeight
;
1339 if (p
->u
.text
.wHSpace
)
1341 space
.cx
+= p
->u
.text
.wHSpace
* 2 * tm
.tmAveCharWidth
;
1344 WINE_TRACE("splitting text %s\n", text
);
1348 INT free_width
= rect
.right
- (part
? (*line
)->rect
.right
: rect
.left
) - space
.cx
;
1349 UINT low
= 0, curr
= len
, high
= len
, textlen
= 0;
1355 GetTextExtentPoint(hDc
, text
, curr
, &textsize
);
1357 if (textsize
.cx
<= free_width
) low
= curr
;
1360 if (high
<= low
+ 1) break;
1362 if (textsize
.cx
) curr
= (curr
* free_width
) / textsize
.cx
;
1363 if (curr
<= low
) curr
= low
+ 1;
1364 else if (curr
>= high
) curr
= high
- 1;
1367 while (textlen
&& text
[textlen
] && text
[textlen
] != ' ') textlen
--;
1369 if (!part
&& !textlen
) textlen
= max(low
, 1);
1371 if (free_width
<= 0 || !textlen
)
1374 space
.cx
= rect
.left
+ indent
;
1375 space
.cx
= min(space
.cx
, rect
.right
- rect
.left
- 1);
1379 WINE_TRACE("\t => %d %*s\n", textlen
, textlen
, text
);
1381 if (!WINHELP_AppendText(&line
, &part
, &space
, &textsize
,
1382 &line_ascent
, tm
.tmAscent
,
1383 text
, textlen
, hFont
, color
, p
->link
, underline
) ||
1384 (!newsize
&& (*line
)->rect
.bottom
> rect
.bottom
))
1386 ReleaseDC(hWnd
, hDc
);
1391 newsize
->cx
= max(newsize
->cx
, (*line
)->rect
.right
+ INTERNAL_BORDER_WIDTH
);
1395 if (text
[0] == ' ') text
++, len
--;
1404 WINHELP_LINE_PART
* ref_part
;
1406 if (p
->u
.gfx
.pos
& 0x8000)
1408 space
.cx
= rect
.left
;
1410 space
.cy
+= (*line
)->rect
.bottom
- (*line
)->rect
.top
;
1414 if (p
->cookie
== para_bitmap
)
1418 GetObject(p
->u
.gfx
.u
.bmp
.hBitmap
, sizeof(dibs
), &dibs
);
1419 gfxSize
.cx
= dibs
.dsBm
.bmWidth
;
1420 gfxSize
.cy
= dibs
.dsBm
.bmHeight
;
1422 else gfxSize
= p
->u
.gfx
.u
.mf
.mfSize
;
1424 free_width
= rect
.right
- ((part
&& *line
) ? (*line
)->rect
.right
: rect
.left
) - space
.cx
;
1425 if (free_width
<= 0)
1428 space
.cx
= rect
.left
;
1429 space
.cx
= min(space
.cx
, rect
.right
- rect
.left
- 1);
1431 ref_part
= WINHELP_AppendGfxObject(&line
, &part
, &space
, &gfxSize
,
1432 p
->link
, p
->u
.gfx
.pos
);
1433 if (!ref_part
|| (!newsize
&& (*line
)->rect
.bottom
> rect
.bottom
))
1437 if (p
->cookie
== para_bitmap
)
1439 ref_part
->cookie
= hlp_line_part_bitmap
;
1440 ref_part
->u
.bitmap
.hBitmap
= p
->u
.gfx
.u
.bmp
.hBitmap
;
1444 ref_part
->cookie
= hlp_line_part_metafile
;
1445 ref_part
->u
.metafile
.hMetaFile
= p
->u
.gfx
.u
.mf
.hMetaFile
;
1453 newsize
->cy
= (*line
)->rect
.bottom
+ INTERNAL_BORDER_WIDTH
;
1455 ReleaseDC(hWnd
, hDc
);
1459 /***********************************************************************
1461 * WINHELP_CheckPopup
1463 static void WINHELP_CheckPopup(UINT msg
)
1465 if (!Globals
.hPopupWnd
) return;
1470 case WM_LBUTTONDOWN
:
1471 case WM_MBUTTONDOWN
:
1472 case WM_RBUTTONDOWN
:
1473 case WM_NCLBUTTONDOWN
:
1474 case WM_NCMBUTTONDOWN
:
1475 case WM_NCRBUTTONDOWN
:
1476 DestroyWindow(Globals
.hPopupWnd
);
1477 Globals
.hPopupWnd
= 0;
1481 /***********************************************************************
1483 * WINHELP_DeleteLines
1485 static void WINHELP_DeleteLines(WINHELP_WINDOW
*win
)
1487 WINHELP_LINE
*line
, *next_line
;
1488 WINHELP_LINE_PART
*part
, *next_part
;
1489 for (line
= win
->first_line
; line
; line
= next_line
)
1491 next_line
= line
->next
;
1492 for (part
= &line
->first_part
; part
; part
= next_part
)
1494 next_part
= part
->next
;
1495 HLPFILE_FreeLink(part
->link
);
1496 HeapFree(GetProcessHeap(), 0, part
);
1499 win
->first_line
= 0;
1502 /***********************************************************************
1504 * WINHELP_DeleteWindow
1506 static void WINHELP_DeleteWindow(WINHELP_WINDOW
* win
)
1513 for (w
= &Globals
.win_list
; *w
; w
= &(*w
)->next
)
1522 for (b
= win
->first_button
; b
; b
= bp
)
1524 DestroyWindow(b
->hWnd
);
1526 HeapFree(GetProcessHeap(), 0, b
);
1529 if (win
->hShadowWnd
) DestroyWindow(win
->hShadowWnd
);
1530 if (win
->hHistoryWnd
) DestroyWindow(win
->hHistoryWnd
);
1532 for (i
= 0; i
< win
->histIndex
; i
++)
1534 HLPFILE_FreeHlpFile(win
->history
[i
]->file
);
1537 for (i
= 0; i
< win
->backIndex
; i
++)
1538 HLPFILE_FreeHlpFile(win
->back
[i
]->file
);
1540 if (win
->page
) HLPFILE_FreeHlpFile(win
->page
->file
);
1541 WINHELP_DeleteLines(win
);
1542 HeapFree(GetProcessHeap(), 0, win
);
1545 /***********************************************************************
1549 static void WINHELP_InitFonts(HWND hWnd
)
1551 WINHELP_WINDOW
*win
= (WINHELP_WINDOW
*) GetWindowLong(hWnd
, 0);
1552 LOGFONT logfontlist
[] = {
1553 {-10, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"},
1554 {-12, 0, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"},
1555 {-12, 0, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"},
1556 {-12, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"},
1557 {-12, 0, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"},
1558 {-10, 0, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"},
1559 { -8, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"}};
1560 #define FONTS_LEN (sizeof(logfontlist)/sizeof(*logfontlist))
1562 static HFONT fonts
[FONTS_LEN
];
1563 static BOOL init
= 0;
1565 win
->fonts_len
= FONTS_LEN
;
1572 for (i
= 0; i
< FONTS_LEN
; i
++)
1574 fonts
[i
] = CreateFontIndirect(&logfontlist
[i
]);
1581 /***********************************************************************
1583 * WINHELP_MessageBoxIDS
1585 INT
WINHELP_MessageBoxIDS(UINT ids_text
, UINT ids_title
, WORD type
)
1587 CHAR text
[MAX_STRING_LEN
];
1588 CHAR title
[MAX_STRING_LEN
];
1590 LoadString(Globals
.hInstance
, ids_text
, text
, sizeof(text
));
1591 LoadString(Globals
.hInstance
, ids_title
, title
, sizeof(title
));
1593 return MessageBox(0, text
, title
, type
);
1596 /***********************************************************************
1598 * MAIN_MessageBoxIDS_s
1600 INT
WINHELP_MessageBoxIDS_s(UINT ids_text
, LPCSTR str
, UINT ids_title
, WORD type
)
1602 CHAR text
[MAX_STRING_LEN
];
1603 CHAR title
[MAX_STRING_LEN
];
1604 CHAR newtext
[MAX_STRING_LEN
+ MAX_PATHNAME_LEN
];
1606 LoadString(Globals
.hInstance
, ids_text
, text
, sizeof(text
));
1607 LoadString(Globals
.hInstance
, ids_title
, title
, sizeof(title
));
1608 wsprintf(newtext
, text
, str
);
1610 return MessageBox(0, newtext
, title
, type
);
1613 /******************************************************************
1614 * WINHELP_IsOverLink
1618 WINHELP_LINE_PART
* WINHELP_IsOverLink(WINHELP_WINDOW
* win
, WPARAM wParam
, LPARAM lParam
)
1622 WINHELP_LINE_PART
*part
;
1623 int scroll_pos
= GetScrollPos(win
->hMainWnd
, SB_VERT
);
1625 mouse
.x
= LOWORD(lParam
);
1626 mouse
.y
= HIWORD(lParam
);
1627 for (line
= win
->first_line
; line
; line
= line
->next
)
1629 for (part
= &line
->first_part
; part
; part
= part
->next
)
1632 part
->link
->lpszString
&&
1633 part
->rect
.left
<= mouse
.x
&&
1634 part
->rect
.right
>= mouse
.x
&&
1635 part
->rect
.top
<= mouse
.y
+ scroll_pos
&&
1636 part
->rect
.bottom
>= mouse
.y
+ scroll_pos
)