1996-05-06 18:06:24 +02:00
|
|
|
/*
|
|
|
|
* Help Viewer
|
|
|
|
*
|
2002-07-16 03:46:29 +02:00
|
|
|
* Copyright 1996 Ulrich Schmid <uschmid@mail.hh.provi.de>
|
|
|
|
* 2002 Sylvain Petreolle <spetreolle@yahoo.fr>
|
2008-04-18 21:34:17 +02:00
|
|
|
* 2002, 2008 Eric Pouech <eric.pouech@wanadoo.fr>
|
2004-09-07 22:42:05 +02:00
|
|
|
* 2004 Ken Belleau <jamez@ivic.qc.ca>
|
2008-08-04 01:50:39 +02:00
|
|
|
* 2008 Kirill K. Smirnov <lich@math.spbu.ru>
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1996-05-06 18:06:24 +02:00
|
|
|
*/
|
|
|
|
|
2002-11-18 20:48:11 +01:00
|
|
|
#include <assert.h>
|
1996-05-06 18:06:24 +02:00
|
|
|
#include <stdio.h>
|
2000-03-19 22:49:49 +01:00
|
|
|
#include <string.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2003-09-18 00:38:12 +02:00
|
|
|
#include <stdlib.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
|
2008-06-27 21:28:44 +02:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2000-10-14 01:07:43 +02:00
|
|
|
#include "winbase.h"
|
2002-07-16 03:46:29 +02:00
|
|
|
#include "wingdi.h"
|
2002-11-13 05:09:34 +01:00
|
|
|
#include "winuser.h"
|
2006-11-06 13:07:01 +01:00
|
|
|
#include "commdlg.h"
|
2000-01-29 23:07:03 +01:00
|
|
|
#include "winhelp.h"
|
2002-05-14 05:48:10 +02:00
|
|
|
#include "winhelp_res.h"
|
2002-11-13 05:09:34 +01:00
|
|
|
#include "shellapi.h"
|
2008-04-23 21:37:44 +02:00
|
|
|
#include "richedit.h"
|
2008-06-27 21:28:44 +02:00
|
|
|
#include "commctrl.h"
|
2000-01-29 23:07:03 +01:00
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(winhelp);
|
|
|
|
|
2008-07-12 10:36:49 +02:00
|
|
|
WINHELP_GLOBALS Globals = {3, NULL, TRUE, NULL, NULL, NULL, NULL, NULL, {{{NULL,NULL}},0}, NULL};
|
1996-05-06 18:06:24 +02:00
|
|
|
|
2008-04-18 21:34:17 +02:00
|
|
|
#define CTL_ID_BUTTON 0x700
|
|
|
|
#define CTL_ID_TEXT 0x701
|
2006-11-06 13:07:01 +01:00
|
|
|
|
2009-01-08 14:13:17 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* WINHELP_InitFonts
|
|
|
|
*/
|
|
|
|
static void WINHELP_InitFonts(HWND hWnd)
|
|
|
|
{
|
2012-01-20 12:50:15 +01:00
|
|
|
WINHELP_WINDOW *win = (WINHELP_WINDOW*) GetWindowLongPtrW(hWnd, 0);
|
|
|
|
LOGFONTW logfontlist[] = {
|
|
|
|
{-10, 0, 0, 0, 400, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 32, {'H','e','l','v',0}},
|
|
|
|
{-12, 0, 0, 0, 700, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 32, {'H','e','l','v',0}},
|
|
|
|
{-12, 0, 0, 0, 700, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 32, {'H','e','l','v',0}},
|
|
|
|
{-12, 0, 0, 0, 400, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 32, {'H','e','l','v',0}},
|
|
|
|
{-12, 0, 0, 0, 700, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 32, {'H','e','l','v',0}},
|
|
|
|
{-10, 0, 0, 0, 700, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 32, {'H','e','l','v',0}},
|
|
|
|
{ -8, 0, 0, 0, 400, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 32, {'H','e','l','v',0}}};
|
2009-01-08 14:13:17 +01:00
|
|
|
|
2018-08-10 12:27:56 +02:00
|
|
|
static HFONT fonts[ARRAY_SIZE(logfontlist)];
|
2013-10-22 00:16:10 +02:00
|
|
|
static BOOL init = FALSE;
|
2009-01-08 14:13:17 +01:00
|
|
|
|
2018-08-10 12:27:56 +02:00
|
|
|
win->fonts_len = ARRAY_SIZE(logfontlist);
|
2009-01-08 14:13:17 +01:00
|
|
|
win->fonts = fonts;
|
|
|
|
|
|
|
|
if (!init)
|
|
|
|
{
|
|
|
|
UINT i;
|
|
|
|
|
2018-08-10 12:27:56 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(logfontlist); i++)
|
2009-01-08 14:13:17 +01:00
|
|
|
{
|
2012-01-20 12:50:15 +01:00
|
|
|
fonts[i] = CreateFontIndirectW(&logfontlist[i]);
|
2009-01-08 14:13:17 +01:00
|
|
|
}
|
|
|
|
|
2013-10-22 00:16:10 +02:00
|
|
|
init = TRUE;
|
2009-01-08 14:13:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD CALLBACK WINHELP_RtfStreamIn(DWORD_PTR cookie, BYTE* buff,
|
|
|
|
LONG cb, LONG* pcb)
|
|
|
|
{
|
|
|
|
struct RtfData* rd = (struct RtfData*)cookie;
|
|
|
|
|
|
|
|
if (rd->where >= rd->ptr) return 1;
|
|
|
|
if (rd->where + cb > rd->ptr)
|
|
|
|
cb = rd->ptr - rd->where;
|
|
|
|
memcpy(buff, rd->where, cb);
|
|
|
|
rd->where += cb;
|
|
|
|
*pcb = cb;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINHELP_SetupText(HWND hTextWnd, WINHELP_WINDOW* win, ULONG relative)
|
|
|
|
{
|
2012-01-20 12:50:15 +01:00
|
|
|
static const WCHAR emptyW[1];
|
2009-01-08 14:13:17 +01:00
|
|
|
/* At first clear area - needed by EM_POSFROMCHAR/EM_SETSCROLLPOS */
|
2012-01-20 12:50:15 +01:00
|
|
|
SendMessageW(hTextWnd, WM_SETTEXT, 0, (LPARAM)emptyW);
|
|
|
|
SendMessageW(hTextWnd, WM_SETREDRAW, FALSE, 0);
|
|
|
|
SendMessageW(hTextWnd, EM_SETBKGNDCOLOR, 0, (LPARAM)win->info->sr_color);
|
2009-01-08 14:13:17 +01:00
|
|
|
/* set word-wrap to window size (undocumented) */
|
2012-01-20 12:50:15 +01:00
|
|
|
SendMessageW(hTextWnd, EM_SETTARGETDEVICE, 0, 0);
|
2009-01-08 14:13:17 +01:00
|
|
|
if (win->page)
|
|
|
|
{
|
|
|
|
struct RtfData rd;
|
|
|
|
EDITSTREAM es;
|
|
|
|
unsigned cp = 0;
|
|
|
|
POINTL ptl;
|
|
|
|
POINT pt;
|
|
|
|
|
|
|
|
|
|
|
|
if (HLPFILE_BrowsePage(win->page, &rd, win->font_scale, relative))
|
|
|
|
{
|
|
|
|
rd.where = rd.data;
|
|
|
|
es.dwCookie = (DWORD_PTR)&rd;
|
|
|
|
es.dwError = 0;
|
|
|
|
es.pfnCallback = WINHELP_RtfStreamIn;
|
|
|
|
|
|
|
|
SendMessageW(hTextWnd, EM_STREAMIN, SF_RTF, (LPARAM)&es);
|
|
|
|
cp = rd.char_pos_rel;
|
|
|
|
}
|
|
|
|
/* FIXME: else leaking potentially the rd.first_link chain */
|
|
|
|
HeapFree(GetProcessHeap(), 0, rd.data);
|
2012-01-20 12:50:15 +01:00
|
|
|
SendMessageW(hTextWnd, EM_POSFROMCHAR, (WPARAM)&ptl, cp ? cp - 1 : 0);
|
2009-01-08 14:13:17 +01:00
|
|
|
pt.x = 0; pt.y = ptl.y;
|
2012-01-20 12:50:15 +01:00
|
|
|
SendMessageW(hTextWnd, EM_SETSCROLLPOS, 0, (LPARAM)&pt);
|
2009-01-08 14:13:17 +01:00
|
|
|
}
|
2012-01-20 12:50:15 +01:00
|
|
|
SendMessageW(hTextWnd, WM_SETREDRAW, TRUE, 0);
|
2009-03-23 15:34:55 +01:00
|
|
|
RedrawWindow(hTextWnd, NULL, NULL, RDW_FRAME|RDW_INVALIDATE);
|
2009-01-08 14:13:17 +01:00
|
|
|
}
|
|
|
|
|
2006-11-06 13:07:01 +01:00
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* WINHELP_GetOpenFileName
|
|
|
|
*/
|
|
|
|
BOOL WINHELP_GetOpenFileName(LPSTR lpszFile, int len)
|
|
|
|
{
|
2012-01-20 12:50:15 +01:00
|
|
|
OPENFILENAMEA openfilename;
|
2006-11-06 13:07:01 +01:00
|
|
|
CHAR szDir[MAX_PATH];
|
|
|
|
CHAR szzFilter[2 * MAX_STRING_LEN + 100];
|
|
|
|
LPSTR p = szzFilter;
|
|
|
|
|
|
|
|
WINE_TRACE("()\n");
|
|
|
|
|
2012-01-20 12:50:15 +01:00
|
|
|
LoadStringA(Globals.hInstance, STID_HELP_FILES_HLP, p, MAX_STRING_LEN);
|
2006-11-06 13:07:01 +01:00
|
|
|
p += strlen(p) + 1;
|
2012-01-20 12:50:15 +01:00
|
|
|
strcpy(p, "*.hlp");
|
2006-11-06 13:07:01 +01:00
|
|
|
p += strlen(p) + 1;
|
2012-01-20 12:50:15 +01:00
|
|
|
LoadStringA(Globals.hInstance, STID_ALL_FILES, p, MAX_STRING_LEN);
|
2006-11-06 13:07:01 +01:00
|
|
|
p += strlen(p) + 1;
|
2012-01-20 12:50:15 +01:00
|
|
|
strcpy(p, "*.*");
|
2006-11-06 13:07:01 +01:00
|
|
|
p += strlen(p) + 1;
|
|
|
|
*p = '\0';
|
|
|
|
|
2012-01-20 12:50:15 +01:00
|
|
|
GetCurrentDirectoryA(sizeof(szDir), szDir);
|
2006-11-06 13:07:01 +01:00
|
|
|
|
|
|
|
lpszFile[0]='\0';
|
|
|
|
|
2012-01-20 12:50:15 +01:00
|
|
|
openfilename.lStructSize = sizeof(openfilename);
|
2009-07-23 22:18:57 +02:00
|
|
|
openfilename.hwndOwner = (Globals.active_win ? Globals.active_win->hMainWnd : 0);
|
2006-11-06 13:07:01 +01:00
|
|
|
openfilename.hInstance = Globals.hInstance;
|
|
|
|
openfilename.lpstrFilter = szzFilter;
|
|
|
|
openfilename.lpstrCustomFilter = 0;
|
|
|
|
openfilename.nMaxCustFilter = 0;
|
|
|
|
openfilename.nFilterIndex = 1;
|
|
|
|
openfilename.lpstrFile = lpszFile;
|
|
|
|
openfilename.nMaxFile = len;
|
|
|
|
openfilename.lpstrFileTitle = 0;
|
|
|
|
openfilename.nMaxFileTitle = 0;
|
|
|
|
openfilename.lpstrInitialDir = szDir;
|
|
|
|
openfilename.lpstrTitle = 0;
|
2013-04-07 14:39:18 +02:00
|
|
|
openfilename.Flags = OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_READONLY;
|
2006-11-06 13:07:01 +01:00
|
|
|
openfilename.nFileOffset = 0;
|
|
|
|
openfilename.nFileExtension = 0;
|
|
|
|
openfilename.lpstrDefExt = 0;
|
|
|
|
openfilename.lCustData = 0;
|
|
|
|
openfilename.lpfnHook = 0;
|
|
|
|
openfilename.lpTemplateName = 0;
|
|
|
|
|
2012-01-20 12:50:15 +01:00
|
|
|
return GetOpenFileNameA(&openfilename);
|
2006-11-06 13:07:01 +01:00
|
|
|
}
|
|
|
|
|
2009-01-08 14:13:17 +01:00
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* WINHELP_MessageBoxIDS_s
|
|
|
|
*/
|
2009-01-08 14:13:30 +01:00
|
|
|
static INT WINHELP_MessageBoxIDS_s(UINT ids_text, LPCSTR str, UINT ids_title, WORD type)
|
2008-04-22 22:00:14 +02:00
|
|
|
{
|
2009-01-08 14:13:17 +01:00
|
|
|
CHAR text[MAX_STRING_LEN];
|
|
|
|
CHAR newtext[MAX_STRING_LEN + MAX_PATH];
|
|
|
|
|
2012-01-20 12:50:15 +01:00
|
|
|
LoadStringA(Globals.hInstance, ids_text, text, sizeof(text));
|
|
|
|
wsprintfA(newtext, text, str);
|
2009-01-08 14:13:17 +01:00
|
|
|
|
2012-01-20 12:50:15 +01:00
|
|
|
return MessageBoxA(0, newtext, MAKEINTRESOURCEA(ids_title), type);
|
2008-04-22 22:00:14 +02:00
|
|
|
}
|
|
|
|
|
2002-11-18 20:48:11 +01:00
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* WINHELP_LookupHelpFile
|
|
|
|
*/
|
|
|
|
HLPFILE* WINHELP_LookupHelpFile(LPCSTR lpszFile)
|
|
|
|
{
|
|
|
|
HLPFILE* hlpfile;
|
2006-11-06 13:07:01 +01:00
|
|
|
char szFullName[MAX_PATH];
|
2006-11-10 17:37:26 +01:00
|
|
|
char szAddPath[MAX_PATH];
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: This is needed by popup windows only.
|
|
|
|
* In other cases it's not needed but does not hurt though.
|
|
|
|
*/
|
|
|
|
if (Globals.active_win && Globals.active_win->page && Globals.active_win->page->file)
|
|
|
|
{
|
|
|
|
strcpy(szAddPath, Globals.active_win->page->file->lpszPath);
|
|
|
|
p = strrchr(szAddPath, '\\');
|
|
|
|
if (p) *p = 0;
|
|
|
|
}
|
2002-11-18 20:48:11 +01:00
|
|
|
|
2006-11-10 17:37:26 +01:00
|
|
|
/*
|
|
|
|
* FIXME: Should we swap conditions?
|
|
|
|
*/
|
2012-01-20 12:50:15 +01:00
|
|
|
if (!SearchPathA(NULL, lpszFile, ".hlp", MAX_PATH, szFullName, NULL) &&
|
|
|
|
!SearchPathA(szAddPath, lpszFile, ".hlp", MAX_PATH, szFullName, NULL))
|
2002-11-18 20:48:11 +01:00
|
|
|
{
|
2006-11-06 13:07:01 +01:00
|
|
|
if (WINHELP_MessageBoxIDS_s(STID_FILE_NOT_FOUND_s, lpszFile, STID_WHERROR,
|
|
|
|
MB_YESNO|MB_ICONQUESTION) != IDYES)
|
|
|
|
return NULL;
|
|
|
|
if (!WINHELP_GetOpenFileName(szFullName, MAX_PATH))
|
|
|
|
return NULL;
|
2002-11-18 20:48:11 +01:00
|
|
|
}
|
2006-11-06 13:07:01 +01:00
|
|
|
hlpfile = HLPFILE_ReadHlpFile(szFullName);
|
2002-11-18 20:48:11 +01:00
|
|
|
if (!hlpfile)
|
2006-11-06 13:07:01 +01:00
|
|
|
WINHELP_MessageBoxIDS_s(STID_HLPFILE_ERROR_s, lpszFile,
|
|
|
|
STID_WHERROR, MB_OK|MB_ICONSTOP);
|
2002-11-18 20:48:11 +01:00
|
|
|
return hlpfile;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* WINHELP_GetWindowInfo
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HLPFILE_WINDOWINFO* WINHELP_GetWindowInfo(HLPFILE* hlpfile, LPCSTR name)
|
|
|
|
{
|
|
|
|
static HLPFILE_WINDOWINFO mwi;
|
2004-09-22 04:46:38 +02:00
|
|
|
unsigned int i;
|
2002-11-18 20:48:11 +01:00
|
|
|
|
|
|
|
if (!name || !name[0])
|
2009-05-30 14:26:58 +02:00
|
|
|
name = Globals.active_win->info->name;
|
2002-11-18 20:48:11 +01:00
|
|
|
|
2003-06-04 22:13:54 +02:00
|
|
|
if (hlpfile)
|
|
|
|
for (i = 0; i < hlpfile->numWindows; i++)
|
2012-01-20 12:50:15 +01:00
|
|
|
if (!lstrcmpiA(hlpfile->windows[i].name, name))
|
2003-06-04 22:13:54 +02:00
|
|
|
return &hlpfile->windows[i];
|
2002-11-18 20:48:11 +01:00
|
|
|
|
|
|
|
if (strcmp(name, "main") != 0)
|
|
|
|
{
|
2016-04-21 22:03:57 +02:00
|
|
|
WINE_FIXME("Couldn't find window info for %s\n", debugstr_a(name));
|
2002-11-18 20:48:11 +01:00
|
|
|
assert(0);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (!mwi.name[0])
|
|
|
|
{
|
|
|
|
strcpy(mwi.type, "primary");
|
|
|
|
strcpy(mwi.name, "main");
|
2009-06-02 23:47:20 +02:00
|
|
|
if (hlpfile && hlpfile->lpszTitle[0])
|
2009-05-31 21:13:59 +02:00
|
|
|
{
|
|
|
|
char tmp[128];
|
2012-01-20 12:50:15 +01:00
|
|
|
LoadStringA(Globals.hInstance, STID_WINE_HELP, tmp, sizeof(tmp));
|
2009-05-31 21:13:59 +02:00
|
|
|
snprintf(mwi.caption, sizeof(mwi.caption), "%s %s - %s",
|
|
|
|
hlpfile->lpszTitle, tmp, hlpfile->lpszPath);
|
|
|
|
}
|
|
|
|
else
|
2012-01-20 12:50:15 +01:00
|
|
|
LoadStringA(Globals.hInstance, STID_WINE_HELP, mwi.caption, sizeof(mwi.caption));
|
2002-11-18 20:48:11 +01:00
|
|
|
mwi.origin.x = mwi.origin.y = mwi.size.cx = mwi.size.cy = CW_USEDEFAULT;
|
|
|
|
mwi.style = SW_SHOW;
|
2003-10-04 05:06:39 +02:00
|
|
|
mwi.win_style = WS_OVERLAPPEDWINDOW;
|
2009-05-31 21:14:17 +02:00
|
|
|
mwi.sr_color = mwi.nsr_color = 0xFFFFFF;
|
2002-11-18 20:48:11 +01:00
|
|
|
}
|
|
|
|
return &mwi;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* HLPFILE_GetPopupWindowInfo
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2008-04-22 22:01:21 +02:00
|
|
|
static HLPFILE_WINDOWINFO* WINHELP_GetPopupWindowInfo(HLPFILE* hlpfile,
|
2008-04-23 21:38:14 +02:00
|
|
|
WINHELP_WINDOW* parent, LPARAM mouse)
|
2002-11-18 20:48:11 +01:00
|
|
|
{
|
|
|
|
static HLPFILE_WINDOWINFO wi;
|
|
|
|
|
|
|
|
RECT parent_rect;
|
|
|
|
|
|
|
|
wi.type[0] = wi.name[0] = wi.caption[0] = '\0';
|
|
|
|
|
|
|
|
/* Calculate horizontal size and position of a popup window */
|
2008-04-22 22:01:21 +02:00
|
|
|
GetWindowRect(parent->hMainWnd, &parent_rect);
|
2002-11-18 20:48:11 +01:00
|
|
|
wi.size.cx = (parent_rect.right - parent_rect.left) / 2;
|
2014-10-02 10:30:06 +02:00
|
|
|
wi.size.cy = 10; /* need a non null value, so that borders are taken into account while computing */
|
2002-11-18 20:48:11 +01:00
|
|
|
|
2008-04-23 21:38:14 +02:00
|
|
|
wi.origin.x = (short)LOWORD(mouse);
|
|
|
|
wi.origin.y = (short)HIWORD(mouse);
|
2008-04-22 22:01:21 +02:00
|
|
|
ClientToScreen(parent->hMainWnd, &wi.origin);
|
2002-11-18 20:48:11 +01:00
|
|
|
wi.origin.x -= wi.size.cx / 2;
|
|
|
|
wi.origin.x = min(wi.origin.x, GetSystemMetrics(SM_CXSCREEN) - wi.size.cx);
|
|
|
|
wi.origin.x = max(wi.origin.x, 0);
|
|
|
|
|
|
|
|
wi.style = SW_SHOW;
|
2007-06-18 12:29:48 +02:00
|
|
|
wi.win_style = WS_POPUP | WS_BORDER;
|
2008-07-12 10:37:08 +02:00
|
|
|
if (parent->page->file->has_popup_color)
|
|
|
|
wi.sr_color = parent->page->file->popup_color;
|
|
|
|
else
|
|
|
|
wi.sr_color = parent->info->sr_color;
|
2008-04-22 22:01:21 +02:00
|
|
|
wi.nsr_color = 0xFFFFFF;
|
2002-11-18 20:48:11 +01:00
|
|
|
|
|
|
|
return &wi;
|
|
|
|
}
|
1996-05-06 18:06:24 +02:00
|
|
|
|
2002-11-11 23:20:47 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
WORD size;
|
|
|
|
WORD command;
|
|
|
|
LONG data;
|
|
|
|
LONG reserved;
|
|
|
|
WORD ofsFilename;
|
|
|
|
WORD ofsData;
|
|
|
|
} WINHELP,*LPWINHELP;
|
|
|
|
|
2008-06-21 10:50:26 +02:00
|
|
|
static BOOL WINHELP_HasWorkingWindow(void)
|
|
|
|
{
|
|
|
|
if (!Globals.active_win) return FALSE;
|
|
|
|
if (Globals.active_win->next || Globals.win_list != Globals.active_win) return TRUE;
|
|
|
|
return Globals.active_win->page != NULL && Globals.active_win->page->file != NULL;
|
|
|
|
}
|
|
|
|
|
2002-11-11 23:20:47 +01:00
|
|
|
/******************************************************************
|
|
|
|
* WINHELP_HandleCommand
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static LRESULT WINHELP_HandleCommand(HWND hSrcWnd, LPARAM lParam)
|
|
|
|
{
|
|
|
|
COPYDATASTRUCT* cds = (COPYDATASTRUCT*)lParam;
|
|
|
|
WINHELP* wh;
|
|
|
|
|
|
|
|
if (cds->dwData != 0xA1DE505)
|
|
|
|
{
|
|
|
|
WINE_FIXME("Wrong magic number (%08lx)\n", cds->dwData);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-04-06 11:51:26 +02:00
|
|
|
wh = cds->lpData;
|
2002-11-11 23:20:47 +01:00
|
|
|
|
|
|
|
if (wh)
|
|
|
|
{
|
2003-06-04 22:13:54 +02:00
|
|
|
char* ptr = (wh->ofsFilename) ? (LPSTR)wh + wh->ofsFilename : NULL;
|
|
|
|
|
2006-10-02 23:20:26 +02:00
|
|
|
WINE_TRACE("Got[%u]: cmd=%u data=%08x fn=%s\n",
|
2016-04-21 22:03:57 +02:00
|
|
|
wh->size, wh->command, wh->data, debugstr_a(ptr));
|
2002-11-11 23:20:47 +01:00
|
|
|
switch (wh->command)
|
|
|
|
{
|
2003-06-04 22:13:54 +02:00
|
|
|
case HELP_CONTEXT:
|
|
|
|
if (ptr)
|
|
|
|
{
|
|
|
|
MACRO_JumpContext(ptr, "main", wh->data);
|
|
|
|
}
|
2008-06-21 10:50:26 +02:00
|
|
|
if (!WINHELP_HasWorkingWindow()) MACRO_Exit();
|
2003-06-04 22:13:54 +02:00
|
|
|
break;
|
2002-11-11 23:20:47 +01:00
|
|
|
case HELP_QUIT:
|
|
|
|
MACRO_Exit();
|
|
|
|
break;
|
2003-06-04 22:13:54 +02:00
|
|
|
case HELP_CONTENTS:
|
|
|
|
if (ptr)
|
2002-11-11 23:20:47 +01:00
|
|
|
{
|
2003-06-04 22:13:54 +02:00
|
|
|
MACRO_JumpContents(ptr, "main");
|
2002-11-11 23:20:47 +01:00
|
|
|
}
|
2008-06-21 10:50:26 +02:00
|
|
|
if (!WINHELP_HasWorkingWindow()) MACRO_Exit();
|
2002-11-11 23:20:47 +01:00
|
|
|
break;
|
2003-06-04 22:13:54 +02:00
|
|
|
case HELP_HELPONHELP:
|
|
|
|
MACRO_HelpOn();
|
2008-06-21 10:50:26 +02:00
|
|
|
if (!WINHELP_HasWorkingWindow()) MACRO_Exit();
|
2003-06-04 22:13:54 +02:00
|
|
|
break;
|
|
|
|
/* case HELP_SETINDEX: */
|
2002-11-11 23:20:47 +01:00
|
|
|
case HELP_SETCONTENTS:
|
2003-06-04 22:13:54 +02:00
|
|
|
if (ptr)
|
|
|
|
{
|
|
|
|
MACRO_SetContents(ptr, wh->data);
|
|
|
|
}
|
|
|
|
break;
|
2002-11-11 23:20:47 +01:00
|
|
|
case HELP_CONTEXTPOPUP:
|
2003-06-04 22:13:54 +02:00
|
|
|
if (ptr)
|
|
|
|
{
|
|
|
|
MACRO_PopupContext(ptr, wh->data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
/* case HELP_FORCEFILE:*/
|
|
|
|
/* case HELP_CONTEXTMENU: */
|
|
|
|
case HELP_FINDER:
|
|
|
|
/* in fact, should be the topic dialog box */
|
2006-10-26 11:21:44 +02:00
|
|
|
WINE_FIXME("HELP_FINDER: stub\n");
|
2003-06-04 22:13:54 +02:00
|
|
|
if (ptr)
|
|
|
|
{
|
|
|
|
MACRO_JumpHash(ptr, "main", 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
/* case HELP_WM_HELP: */
|
|
|
|
/* case HELP_SETPOPUP_POS: */
|
|
|
|
/* case HELP_KEY: */
|
|
|
|
/* case HELP_COMMAND: */
|
|
|
|
/* case HELP_PARTIALKEY: */
|
|
|
|
/* case HELP_MULTIKEY: */
|
|
|
|
/* case HELP_SETWINPOS: */
|
2007-07-18 22:22:07 +02:00
|
|
|
default:
|
|
|
|
WINE_FIXME("Unhandled command (%x) for remote winhelp control\n", wh->command);
|
2002-11-11 23:20:47 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-12-04 22:39:04 +01:00
|
|
|
/* Always return success for now */
|
|
|
|
return 1;
|
2002-11-11 23:20:47 +01:00
|
|
|
}
|
|
|
|
|
2008-04-18 21:33:51 +02:00
|
|
|
void WINHELP_LayoutMainWindow(WINHELP_WINDOW* win)
|
|
|
|
{
|
|
|
|
RECT rect, button_box_rect;
|
2008-04-18 21:34:17 +02:00
|
|
|
INT text_top = 0;
|
2008-04-18 21:34:29 +02:00
|
|
|
HWND hButtonBoxWnd = GetDlgItem(win->hMainWnd, CTL_ID_BUTTON);
|
|
|
|
HWND hTextWnd = GetDlgItem(win->hMainWnd, CTL_ID_TEXT);
|
2008-04-18 21:33:51 +02:00
|
|
|
|
|
|
|
GetClientRect(win->hMainWnd, &rect);
|
|
|
|
|
|
|
|
/* Update button box and text Window */
|
2008-04-18 21:34:29 +02:00
|
|
|
SetWindowPos(hButtonBoxWnd, HWND_TOP,
|
2008-04-18 21:33:51 +02:00
|
|
|
rect.left, rect.top,
|
|
|
|
rect.right - rect.left,
|
|
|
|
rect.bottom - rect.top, 0);
|
|
|
|
|
2008-04-18 21:34:29 +02:00
|
|
|
if (GetWindowRect(hButtonBoxWnd, &button_box_rect))
|
2008-04-18 21:34:17 +02:00
|
|
|
text_top = rect.top + button_box_rect.bottom - button_box_rect.top;
|
2008-04-18 21:33:51 +02:00
|
|
|
|
2008-04-18 21:34:29 +02:00
|
|
|
SetWindowPos(hTextWnd, HWND_TOP,
|
2008-04-18 21:33:51 +02:00
|
|
|
rect.left, text_top,
|
|
|
|
rect.right - rect.left,
|
|
|
|
rect.bottom - text_top, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-01-08 14:13:17 +01:00
|
|
|
/******************************************************************
|
|
|
|
* WINHELP_DeleteButtons
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void WINHELP_DeleteButtons(WINHELP_WINDOW* win)
|
2002-11-20 20:46:18 +01:00
|
|
|
{
|
2009-01-08 14:13:17 +01:00
|
|
|
WINHELP_BUTTON* b;
|
|
|
|
WINHELP_BUTTON* bp;
|
2002-11-20 20:46:18 +01:00
|
|
|
|
2009-01-08 14:13:17 +01:00
|
|
|
for (b = win->first_button; b; b = bp)
|
2002-11-20 20:46:18 +01:00
|
|
|
{
|
2009-01-08 14:13:17 +01:00
|
|
|
DestroyWindow(b->hWnd);
|
|
|
|
bp = b->next;
|
|
|
|
HeapFree(GetProcessHeap(), 0, b);
|
|
|
|
}
|
|
|
|
win->first_button = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* WINHELP_DeleteBackSet
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void WINHELP_DeleteBackSet(WINHELP_WINDOW* win)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < win->back.index; i++)
|
|
|
|
{
|
|
|
|
HLPFILE_FreeHlpFile(win->back.set[i].page->file);
|
|
|
|
win->back.set[i].page = NULL;
|
|
|
|
}
|
|
|
|
win->back.index = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* WINHELP_DeletePageLinks
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void WINHELP_DeletePageLinks(HLPFILE_PAGE* page)
|
|
|
|
{
|
|
|
|
HLPFILE_LINK* curr;
|
|
|
|
HLPFILE_LINK* next;
|
|
|
|
|
|
|
|
for (curr = page->first_link; curr; curr = next)
|
|
|
|
{
|
|
|
|
next = curr->next;
|
|
|
|
HeapFree(GetProcessHeap(), 0, curr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:27:04 +02:00
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* WINHELP_GrabWindow
|
|
|
|
*/
|
|
|
|
WINHELP_WINDOW* WINHELP_GrabWindow(WINHELP_WINDOW* win)
|
|
|
|
{
|
|
|
|
WINE_TRACE("Grab %p#%d++\n", win, win->ref_count);
|
|
|
|
win->ref_count++;
|
|
|
|
return win;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
*
|
2016-05-26 17:18:15 +02:00
|
|
|
* WINHELP_ReleaseWindow
|
2009-05-30 14:27:04 +02:00
|
|
|
*/
|
|
|
|
BOOL WINHELP_ReleaseWindow(WINHELP_WINDOW* win)
|
|
|
|
{
|
|
|
|
WINE_TRACE("Release %p#%d--\n", win, win->ref_count);
|
|
|
|
|
|
|
|
if (!--win->ref_count)
|
|
|
|
{
|
|
|
|
DestroyWindow(win->hMainWnd);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-01-08 14:13:17 +01:00
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* WINHELP_DeleteWindow
|
|
|
|
*/
|
|
|
|
static void WINHELP_DeleteWindow(WINHELP_WINDOW* win)
|
|
|
|
{
|
|
|
|
WINHELP_WINDOW** w;
|
2009-05-30 14:27:04 +02:00
|
|
|
BOOL bExit;
|
2009-11-08 14:07:50 +01:00
|
|
|
HWND hTextWnd;
|
2009-01-08 14:13:17 +01:00
|
|
|
|
|
|
|
for (w = &Globals.win_list; *w; w = &(*w)->next)
|
|
|
|
{
|
|
|
|
if (*w == win)
|
|
|
|
{
|
|
|
|
*w = win->next;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-01-20 12:50:15 +01:00
|
|
|
bExit = (Globals.wVersion >= 4 && !lstrcmpiA(win->info->name, "main"));
|
2009-01-08 14:13:17 +01:00
|
|
|
|
|
|
|
if (Globals.active_win == win)
|
|
|
|
{
|
|
|
|
Globals.active_win = Globals.win_list;
|
|
|
|
if (Globals.win_list)
|
|
|
|
SetActiveWindow(Globals.win_list->hMainWnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (win == Globals.active_popup)
|
|
|
|
Globals.active_popup = NULL;
|
|
|
|
|
2009-11-08 14:07:50 +01:00
|
|
|
hTextWnd = GetDlgItem(win->hMainWnd, CTL_ID_TEXT);
|
2012-01-20 12:50:15 +01:00
|
|
|
SetWindowLongPtrA(hTextWnd, GWLP_WNDPROC, (LONG_PTR)win->origRicheditWndProc);
|
2009-11-08 14:07:50 +01:00
|
|
|
|
2009-01-08 14:13:17 +01:00
|
|
|
WINHELP_DeleteButtons(win);
|
|
|
|
|
|
|
|
if (win->page) WINHELP_DeletePageLinks(win->page);
|
|
|
|
if (win->hHistoryWnd) DestroyWindow(win->hHistoryWnd);
|
|
|
|
|
|
|
|
DeleteObject(win->hBrush);
|
|
|
|
|
|
|
|
WINHELP_DeleteBackSet(win);
|
|
|
|
|
|
|
|
if (win->page) HLPFILE_FreeHlpFile(win->page->file);
|
|
|
|
HeapFree(GetProcessHeap(), 0, win);
|
2009-05-30 14:27:04 +02:00
|
|
|
|
|
|
|
if (bExit) MACRO_Exit();
|
|
|
|
if (!Globals.win_list)
|
|
|
|
PostQuitMessage(0);
|
2009-01-08 14:13:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static char* WINHELP_GetCaption(WINHELP_WNDPAGE* wpage)
|
|
|
|
{
|
|
|
|
if (wpage->wininfo->caption[0]) return wpage->wininfo->caption;
|
|
|
|
return wpage->page->file->lpszTitle;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINHELP_RememberPage(WINHELP_WINDOW* win, WINHELP_WNDPAGE* wpage)
|
|
|
|
{
|
|
|
|
unsigned num;
|
|
|
|
|
|
|
|
if (!Globals.history.index || Globals.history.set[0].page != wpage->page)
|
|
|
|
{
|
2018-08-10 12:27:55 +02:00
|
|
|
num = ARRAY_SIZE(Globals.history.set);
|
2009-01-08 14:13:17 +01:00
|
|
|
/* we're full, remove latest entry */
|
|
|
|
if (Globals.history.index == num)
|
|
|
|
{
|
|
|
|
HLPFILE_FreeHlpFile(Globals.history.set[num - 1].page->file);
|
|
|
|
Globals.history.index--;
|
|
|
|
}
|
2008-04-22 21:59:45 +02:00
|
|
|
memmove(&Globals.history.set[1], &Globals.history.set[0],
|
|
|
|
Globals.history.index * sizeof(Globals.history.set[0]));
|
2008-04-22 22:01:02 +02:00
|
|
|
Globals.history.set[0] = *wpage;
|
2008-04-22 21:59:45 +02:00
|
|
|
Globals.history.index++;
|
2008-04-22 22:01:02 +02:00
|
|
|
wpage->page->file->wRefCount++;
|
2002-11-20 20:46:18 +01:00
|
|
|
}
|
2008-04-22 21:59:51 +02:00
|
|
|
if (win->hHistoryWnd) InvalidateRect(win->hHistoryWnd, NULL, TRUE);
|
2002-11-20 20:46:18 +01:00
|
|
|
|
2018-08-10 12:27:55 +02:00
|
|
|
num = ARRAY_SIZE(win->back.set);
|
2008-04-22 21:59:38 +02:00
|
|
|
if (win->back.index == num)
|
2008-04-22 21:59:31 +02:00
|
|
|
{
|
|
|
|
/* we're full, remove latest entry */
|
2008-04-22 21:59:38 +02:00
|
|
|
HLPFILE_FreeHlpFile(win->back.set[0].page->file);
|
|
|
|
memmove(&win->back.set[0], &win->back.set[1],
|
|
|
|
(num - 1) * sizeof(win->back.set[0]));
|
|
|
|
win->back.index--;
|
2008-04-22 21:59:31 +02:00
|
|
|
}
|
2008-04-22 22:01:02 +02:00
|
|
|
win->back.set[win->back.index++] = *wpage;
|
|
|
|
wpage->page->file->wRefCount++;
|
2002-11-20 20:46:18 +01:00
|
|
|
}
|
|
|
|
|
2009-03-10 20:19:59 +01:00
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* WINHELP_FindLink
|
|
|
|
*/
|
|
|
|
static HLPFILE_LINK* WINHELP_FindLink(WINHELP_WINDOW* win, LPARAM pos)
|
|
|
|
{
|
|
|
|
HLPFILE_LINK* link;
|
|
|
|
POINTL mouse_ptl, char_ptl, char_next_ptl;
|
|
|
|
DWORD cp;
|
|
|
|
|
|
|
|
if (!win->page) return NULL;
|
|
|
|
|
|
|
|
mouse_ptl.x = (short)LOWORD(pos);
|
|
|
|
mouse_ptl.y = (short)HIWORD(pos);
|
|
|
|
cp = SendMessageW(GetDlgItem(win->hMainWnd, CTL_ID_TEXT), EM_CHARFROMPOS,
|
|
|
|
0, (LPARAM)&mouse_ptl);
|
|
|
|
|
|
|
|
for (link = win->page->first_link; link; link = link->next)
|
|
|
|
{
|
|
|
|
if (link->cpMin <= cp && cp <= link->cpMax)
|
|
|
|
{
|
|
|
|
/* check whether we're at end of line */
|
|
|
|
SendMessageW(GetDlgItem(win->hMainWnd, CTL_ID_TEXT), EM_POSFROMCHAR,
|
|
|
|
(LPARAM)&char_ptl, cp);
|
|
|
|
SendMessageW(GetDlgItem(win->hMainWnd, CTL_ID_TEXT), EM_POSFROMCHAR,
|
|
|
|
(LPARAM)&char_next_ptl, cp + 1);
|
2009-09-19 12:53:01 +02:00
|
|
|
if (link->bHotSpot)
|
|
|
|
{
|
|
|
|
HLPFILE_HOTSPOTLINK* hslink = (HLPFILE_HOTSPOTLINK*)link;
|
|
|
|
if ((mouse_ptl.x < char_ptl.x + hslink->x) ||
|
|
|
|
(mouse_ptl.x >= char_ptl.x + hslink->x + hslink->width) ||
|
|
|
|
(mouse_ptl.y < char_ptl.y + hslink->y) ||
|
|
|
|
(mouse_ptl.y >= char_ptl.y + hslink->y + hslink->height))
|
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
}
|
2009-03-10 20:19:59 +01:00
|
|
|
if (char_next_ptl.y != char_ptl.y || mouse_ptl.x >= char_next_ptl.x)
|
|
|
|
link = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return link;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT CALLBACK WINHELP_RicheditWndProc(HWND hWnd, UINT msg,
|
|
|
|
WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2012-01-20 12:50:15 +01:00
|
|
|
WINHELP_WINDOW *win = (WINHELP_WINDOW*) GetWindowLongPtrW(GetParent(hWnd), 0);
|
2009-03-10 20:19:59 +01:00
|
|
|
DWORD messagePos;
|
|
|
|
POINT pt;
|
|
|
|
switch(msg)
|
|
|
|
{
|
|
|
|
case WM_SETCURSOR:
|
|
|
|
messagePos = GetMessagePos();
|
|
|
|
pt.x = (short)LOWORD(messagePos);
|
|
|
|
pt.y = (short)HIWORD(messagePos);
|
|
|
|
ScreenToClient(hWnd, &pt);
|
|
|
|
if (win->page && WINHELP_FindLink(win, MAKELPARAM(pt.x, pt.y)))
|
|
|
|
{
|
|
|
|
SetCursor(win->hHandCur);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* fall through */
|
|
|
|
default:
|
|
|
|
return CallWindowProcA(win->origRicheditWndProc, hWnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-05-06 18:06:24 +02:00
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* WINHELP_CreateHelpWindow
|
|
|
|
*/
|
2008-04-22 22:00:20 +02:00
|
|
|
BOOL WINHELP_CreateHelpWindow(WINHELP_WNDPAGE* wpage, int nCmdShow, BOOL remember)
|
1996-05-06 18:06:24 +02:00
|
|
|
{
|
2008-04-22 21:59:31 +02:00
|
|
|
WINHELP_WINDOW* win = NULL;
|
|
|
|
BOOL bPrimary, bPopup, bReUsed = FALSE;
|
2008-04-22 22:00:50 +02:00
|
|
|
HICON hIcon;
|
2008-04-23 21:37:51 +02:00
|
|
|
HWND hTextWnd = NULL;
|
2002-07-16 03:46:29 +02:00
|
|
|
|
2012-01-20 12:50:15 +01:00
|
|
|
bPrimary = !lstrcmpiA(wpage->wininfo->name, "main");
|
2008-04-22 21:59:38 +02:00
|
|
|
bPopup = !bPrimary && (wpage->wininfo->win_style & WS_POPUP);
|
1996-05-06 18:06:24 +02:00
|
|
|
|
2008-04-22 21:59:31 +02:00
|
|
|
if (!bPopup)
|
|
|
|
{
|
|
|
|
for (win = Globals.win_list; win; win = win->next)
|
|
|
|
{
|
2012-01-20 12:50:15 +01:00
|
|
|
if (!lstrcmpiA(win->info->name, wpage->wininfo->name))
|
2008-04-22 21:59:31 +02:00
|
|
|
{
|
2010-06-02 22:22:53 +02:00
|
|
|
if (win->page == wpage->page && win->info == wpage->wininfo)
|
|
|
|
{
|
|
|
|
/* see #22979, some hlp files have a macro (run at page opening), which
|
|
|
|
* jumps to the very same page
|
|
|
|
* Exit gracefully in that case
|
|
|
|
*/
|
|
|
|
return TRUE;
|
|
|
|
}
|
2008-04-22 21:59:31 +02:00
|
|
|
WINHELP_DeleteButtons(win);
|
|
|
|
bReUsed = TRUE;
|
2012-01-20 12:50:15 +01:00
|
|
|
SetWindowTextA(win->hMainWnd, WINHELP_GetCaption(wpage));
|
2010-06-04 21:27:23 +02:00
|
|
|
if (win->info != wpage->wininfo)
|
2008-04-22 22:01:33 +02:00
|
|
|
{
|
2010-06-04 21:27:23 +02:00
|
|
|
POINT pt = {0, 0};
|
|
|
|
SIZE sz = {0, 0};
|
|
|
|
DWORD flags = SWP_NOSIZE | SWP_NOMOVE;
|
|
|
|
|
|
|
|
if (wpage->wininfo->origin.x != CW_USEDEFAULT &&
|
|
|
|
wpage->wininfo->origin.y != CW_USEDEFAULT)
|
|
|
|
{
|
|
|
|
pt = wpage->wininfo->origin;
|
|
|
|
flags &= ~SWP_NOSIZE;
|
|
|
|
}
|
|
|
|
if (wpage->wininfo->size.cx != CW_USEDEFAULT &&
|
|
|
|
wpage->wininfo->size.cy != CW_USEDEFAULT)
|
|
|
|
{
|
|
|
|
sz = wpage->wininfo->size;
|
|
|
|
flags &= ~SWP_NOMOVE;
|
|
|
|
}
|
|
|
|
SetWindowPos(win->hMainWnd, HWND_TOP, pt.x, pt.y, sz.cx, sz.cy, flags);
|
2008-04-22 22:01:33 +02:00
|
|
|
}
|
|
|
|
|
2008-04-29 17:19:33 +02:00
|
|
|
if (wpage->page && win->page && wpage->page->file != win->page->file)
|
2008-04-22 21:59:57 +02:00
|
|
|
WINHELP_DeleteBackSet(win);
|
2008-04-22 21:59:31 +02:00
|
|
|
WINHELP_InitFonts(win->hMainWnd);
|
|
|
|
|
2008-04-22 21:59:38 +02:00
|
|
|
win->page = wpage->page;
|
|
|
|
win->info = wpage->wininfo;
|
2008-04-23 21:37:51 +02:00
|
|
|
hTextWnd = GetDlgItem(win->hMainWnd, CTL_ID_TEXT);
|
|
|
|
WINHELP_SetupText(hTextWnd, win, wpage->relative);
|
2008-04-22 22:00:56 +02:00
|
|
|
|
2008-04-22 21:59:31 +02:00
|
|
|
InvalidateRect(win->hMainWnd, NULL, TRUE);
|
|
|
|
if (win->hHistoryWnd) InvalidateRect(win->hHistoryWnd, NULL, TRUE);
|
2008-05-01 21:16:53 +02:00
|
|
|
|
2008-04-22 21:59:31 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-10-14 01:07:43 +02:00
|
|
|
|
2008-04-22 21:59:31 +02:00
|
|
|
if (!win)
|
|
|
|
{
|
|
|
|
/* Initialize WINHELP_WINDOW struct */
|
2009-05-30 14:26:58 +02:00
|
|
|
win = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINHELP_WINDOW));
|
2008-04-22 21:59:31 +02:00
|
|
|
if (!win) return FALSE;
|
|
|
|
win->next = Globals.win_list;
|
|
|
|
Globals.win_list = win;
|
|
|
|
|
|
|
|
win->hHandCur = LoadCursorW(0, (LPWSTR)IDC_HAND);
|
2008-04-22 21:59:38 +02:00
|
|
|
win->back.index = 0;
|
2008-05-01 21:17:29 +02:00
|
|
|
win->font_scale = 1;
|
2009-05-30 14:27:04 +02:00
|
|
|
WINHELP_GrabWindow(win);
|
2008-04-22 21:59:31 +02:00
|
|
|
}
|
2008-04-22 21:59:38 +02:00
|
|
|
win->page = wpage->page;
|
|
|
|
win->info = wpage->wininfo;
|
2009-05-30 14:27:04 +02:00
|
|
|
WINHELP_GrabWindow(win);
|
1996-05-06 18:06:24 +02:00
|
|
|
|
2008-04-22 22:00:20 +02:00
|
|
|
if (!bPopup && wpage->page && remember)
|
2008-04-22 21:59:31 +02:00
|
|
|
{
|
2008-04-22 22:01:02 +02:00
|
|
|
WINHELP_RememberPage(win, wpage);
|
2008-04-22 21:59:31 +02:00
|
|
|
}
|
2002-11-18 20:48:11 +01:00
|
|
|
|
2008-04-22 22:01:14 +02:00
|
|
|
if (bPopup)
|
|
|
|
Globals.active_popup = win;
|
|
|
|
else
|
2008-04-22 21:59:31 +02:00
|
|
|
Globals.active_win = win;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
/* Initialize default pushbuttons */
|
2008-04-22 21:59:38 +02:00
|
|
|
if (bPrimary && wpage->page)
|
1996-05-06 18:06:24 +02:00
|
|
|
{
|
2002-10-21 21:18:42 +02:00
|
|
|
CHAR buffer[MAX_STRING_LEN];
|
|
|
|
|
2012-01-20 12:50:15 +01:00
|
|
|
LoadStringA(Globals.hInstance, STID_CONTENTS, buffer, sizeof(buffer));
|
2002-10-21 21:18:42 +02:00
|
|
|
MACRO_CreateButton("BTN_CONTENTS", buffer, "Contents()");
|
2012-01-20 12:50:15 +01:00
|
|
|
LoadStringA(Globals.hInstance, STID_INDEX, buffer, sizeof(buffer));
|
2008-07-05 21:33:37 +02:00
|
|
|
MACRO_CreateButton("BTN_INDEX", buffer, "Finder()");
|
2012-01-20 12:50:15 +01:00
|
|
|
LoadStringA(Globals.hInstance, STID_BACK, buffer, sizeof(buffer));
|
2002-10-21 21:18:42 +02:00
|
|
|
MACRO_CreateButton("BTN_BACK", buffer, "Back()");
|
2008-04-22 22:00:20 +02:00
|
|
|
if (win->back.index <= 1) MACRO_DisableButton("BTN_BACK");
|
1996-05-06 18:06:24 +02:00
|
|
|
}
|
|
|
|
|
2008-04-22 21:59:31 +02:00
|
|
|
if (!bReUsed)
|
2002-11-18 20:48:11 +01:00
|
|
|
{
|
2012-01-20 12:50:15 +01:00
|
|
|
win->hMainWnd = CreateWindowExA((bPopup) ? WS_EX_TOOLWINDOW : 0, MAIN_WIN_CLASS_NAME,
|
2008-04-22 22:00:14 +02:00
|
|
|
WINHELP_GetCaption(wpage),
|
2008-04-22 21:59:38 +02:00
|
|
|
bPrimary ? WS_OVERLAPPEDWINDOW : wpage->wininfo->win_style,
|
|
|
|
wpage->wininfo->origin.x, wpage->wininfo->origin.y,
|
|
|
|
wpage->wininfo->size.cx, wpage->wininfo->size.cy,
|
2008-04-22 21:59:31 +02:00
|
|
|
bPopup ? Globals.active_win->hMainWnd : NULL,
|
2012-01-20 12:50:15 +01:00
|
|
|
bPrimary ? LoadMenuW(Globals.hInstance, MAKEINTRESOURCEW(MAIN_MENU)) : 0,
|
2008-04-22 21:59:31 +02:00
|
|
|
Globals.hInstance, win);
|
|
|
|
if (!bPopup)
|
|
|
|
/* Create button box and text Window */
|
2012-01-20 12:50:15 +01:00
|
|
|
CreateWindowA(BUTTON_BOX_WIN_CLASS_NAME, "", WS_CHILD | WS_VISIBLE,
|
2008-04-22 21:59:31 +02:00
|
|
|
0, 0, 0, 0, win->hMainWnd, (HMENU)CTL_ID_BUTTON, Globals.hInstance, NULL);
|
|
|
|
|
2012-01-20 12:50:15 +01:00
|
|
|
hTextWnd = CreateWindowA(RICHEDIT_CLASS20A, NULL,
|
2008-05-01 21:16:53 +02:00
|
|
|
ES_MULTILINE | ES_READONLY | WS_CHILD | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE,
|
|
|
|
0, 0, 0, 0, win->hMainWnd, (HMENU)CTL_ID_TEXT, Globals.hInstance, NULL);
|
2012-01-20 12:50:15 +01:00
|
|
|
SendMessageW(hTextWnd, EM_SETEVENTMASK, 0,
|
|
|
|
SendMessageW(hTextWnd, EM_GETEVENTMASK, 0, 0) | ENM_MOUSEEVENTS);
|
|
|
|
win->origRicheditWndProc = (WNDPROC)SetWindowLongPtrA(hTextWnd, GWLP_WNDPROC,
|
2009-03-10 20:19:59 +01:00
|
|
|
(LONG_PTR)WINHELP_RicheditWndProc);
|
2002-11-18 20:48:11 +01:00
|
|
|
}
|
2002-07-16 03:46:29 +02:00
|
|
|
|
2008-04-22 22:00:50 +02:00
|
|
|
hIcon = (wpage->page) ? wpage->page->file->hIcon : NULL;
|
2012-01-20 12:50:15 +01:00
|
|
|
if (!hIcon) hIcon = LoadImageW(Globals.hInstance, MAKEINTRESOURCEW(IDI_WINHELP), IMAGE_ICON,
|
2010-04-19 20:13:11 +02:00
|
|
|
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED);
|
2012-01-20 12:50:15 +01:00
|
|
|
SendMessageW(win->hMainWnd, WM_SETICON, ICON_SMALL, (DWORD_PTR)hIcon);
|
2008-04-22 22:00:50 +02:00
|
|
|
|
2008-04-22 22:00:38 +02:00
|
|
|
/* Initialize file specific pushbuttons */
|
|
|
|
if (!(wpage->wininfo->win_style & WS_POPUP) && wpage->page)
|
|
|
|
{
|
|
|
|
HLPFILE_MACRO *macro;
|
|
|
|
for (macro = wpage->page->file->first_macro; macro; macro = macro->next)
|
2009-05-30 14:26:33 +02:00
|
|
|
MACRO_ExecuteMacro(win, macro->lpszMacro);
|
2008-04-22 22:00:38 +02:00
|
|
|
|
|
|
|
for (macro = wpage->page->first_macro; macro; macro = macro->next)
|
2009-05-30 14:26:33 +02:00
|
|
|
MACRO_ExecuteMacro(win, macro->lpszMacro);
|
2008-04-22 22:00:38 +02:00
|
|
|
}
|
2009-05-30 14:27:04 +02:00
|
|
|
/* See #17681, in some cases, the newly created window is closed by the macros it contains
|
|
|
|
* (braindead), so deal with this case
|
|
|
|
*/
|
|
|
|
for (win = Globals.win_list; win; win = win->next)
|
|
|
|
{
|
2012-01-20 12:50:15 +01:00
|
|
|
if (!lstrcmpiA(win->info->name, wpage->wininfo->name)) break;
|
2009-05-30 14:27:04 +02:00
|
|
|
}
|
|
|
|
if (!win || !WINHELP_ReleaseWindow(win)) return TRUE;
|
2008-04-22 22:00:38 +02:00
|
|
|
|
2008-05-01 21:16:53 +02:00
|
|
|
if (bPopup)
|
2008-04-23 21:38:27 +02:00
|
|
|
{
|
2012-01-20 12:50:15 +01:00
|
|
|
DWORD mask = SendMessageW(hTextWnd, EM_GETEVENTMASK, 0, 0);
|
2008-04-23 21:38:27 +02:00
|
|
|
|
2008-05-01 21:17:29 +02:00
|
|
|
win->font_scale = Globals.active_win->font_scale;
|
2008-04-23 21:38:27 +02:00
|
|
|
WINHELP_SetupText(hTextWnd, win, wpage->relative);
|
2002-07-16 03:46:29 +02:00
|
|
|
|
2008-04-23 21:38:27 +02:00
|
|
|
/* we need the window to be shown for richedit to compute the size */
|
|
|
|
ShowWindow(win->hMainWnd, nCmdShow);
|
2012-01-20 12:50:15 +01:00
|
|
|
SendMessageW(hTextWnd, EM_SETEVENTMASK, 0, mask | ENM_REQUESTRESIZE);
|
|
|
|
SendMessageW(hTextWnd, EM_REQUESTRESIZE, 0, 0);
|
|
|
|
SendMessageW(hTextWnd, EM_SETEVENTMASK, 0, mask);
|
2008-04-23 21:38:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WINHELP_SetupText(hTextWnd, win, wpage->relative);
|
|
|
|
WINHELP_LayoutMainWindow(win);
|
|
|
|
ShowWindow(win->hMainWnd, nCmdShow);
|
|
|
|
}
|
1996-05-06 18:06:24 +02:00
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
return TRUE;
|
1996-05-06 18:06:24 +02:00
|
|
|
}
|
|
|
|
|
2008-04-22 22:01:08 +02:00
|
|
|
/******************************************************************
|
|
|
|
* WINHELP_OpenHelpWindow
|
|
|
|
* Main function to search for a page and display it in a window
|
2007-12-12 22:56:18 +01:00
|
|
|
*/
|
2008-04-22 22:01:08 +02:00
|
|
|
BOOL WINHELP_OpenHelpWindow(HLPFILE_PAGE* (*lookup)(HLPFILE*, LONG, ULONG*),
|
|
|
|
HLPFILE* hlpfile, LONG val, HLPFILE_WINDOWINFO* wi,
|
|
|
|
int nCmdShow)
|
2007-12-12 22:56:18 +01:00
|
|
|
{
|
2008-04-22 21:59:38 +02:00
|
|
|
WINHELP_WNDPAGE wpage;
|
2007-12-12 22:56:18 +01:00
|
|
|
|
2008-04-22 22:01:08 +02:00
|
|
|
wpage.page = lookup(hlpfile, val, &wpage.relative);
|
2008-04-22 21:59:38 +02:00
|
|
|
if (wpage.page) wpage.page->file->wRefCount++;
|
|
|
|
wpage.wininfo = wi;
|
2008-04-22 22:00:20 +02:00
|
|
|
return WINHELP_CreateHelpWindow(&wpage, nCmdShow, TRUE);
|
2007-12-12 22:56:18 +01:00
|
|
|
}
|
|
|
|
|
2008-04-23 21:38:14 +02:00
|
|
|
/******************************************************************
|
|
|
|
* WINHELP_HandleTextMouse
|
|
|
|
*
|
|
|
|
*/
|
2008-04-23 21:38:42 +02:00
|
|
|
static BOOL WINHELP_HandleTextMouse(WINHELP_WINDOW* win, UINT msg, LPARAM lParam)
|
2008-04-23 21:38:14 +02:00
|
|
|
{
|
|
|
|
HLPFILE* hlpfile;
|
|
|
|
HLPFILE_LINK* link;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
2008-04-23 21:38:42 +02:00
|
|
|
switch (msg)
|
2008-04-23 21:38:14 +02:00
|
|
|
{
|
2009-03-10 20:19:59 +01:00
|
|
|
case WM_LBUTTONDOWN:
|
2009-03-12 06:35:33 +01:00
|
|
|
if ((link = WINHELP_FindLink(win, lParam)))
|
2008-04-23 21:38:14 +02:00
|
|
|
{
|
|
|
|
HLPFILE_WINDOWINFO* wi;
|
|
|
|
|
|
|
|
switch (link->cookie)
|
|
|
|
{
|
|
|
|
case hlp_link_link:
|
|
|
|
if ((hlpfile = WINHELP_LookupHelpFile(link->string)))
|
|
|
|
{
|
|
|
|
if (link->window == -1)
|
2010-06-13 15:39:35 +02:00
|
|
|
{
|
2008-04-23 21:38:14 +02:00
|
|
|
wi = win->info;
|
2010-06-13 15:39:35 +02:00
|
|
|
if (wi->win_style & WS_POPUP) wi = Globals.active_win->info;
|
|
|
|
}
|
2008-05-03 10:23:24 +02:00
|
|
|
else if (link->window < hlpfile->numWindows)
|
2008-04-23 21:38:14 +02:00
|
|
|
wi = &hlpfile->windows[link->window];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WINE_WARN("link to window %d/%d\n", link->window, hlpfile->numWindows);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, link->hash, wi, SW_NORMAL);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case hlp_link_popup:
|
|
|
|
if ((hlpfile = WINHELP_LookupHelpFile(link->string)))
|
|
|
|
WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, link->hash,
|
2008-04-23 21:38:42 +02:00
|
|
|
WINHELP_GetPopupWindowInfo(hlpfile, win, lParam),
|
2008-04-23 21:38:14 +02:00
|
|
|
SW_NORMAL);
|
|
|
|
break;
|
|
|
|
case hlp_link_macro:
|
2009-05-30 14:26:33 +02:00
|
|
|
MACRO_ExecuteMacro(win, link->string);
|
2008-04-23 21:38:14 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WINE_FIXME("Unknown link cookie %d\n", link->cookie);
|
|
|
|
}
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
/***********************************************************************
|
|
|
|
*
|
2009-01-08 14:13:17 +01:00
|
|
|
* WINHELP_CheckPopup
|
2002-07-16 03:46:29 +02:00
|
|
|
*/
|
2009-01-08 14:13:17 +01:00
|
|
|
static BOOL WINHELP_CheckPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, LRESULT* lret)
|
2002-07-16 03:46:29 +02:00
|
|
|
{
|
2009-05-30 14:27:04 +02:00
|
|
|
WINHELP_WINDOW* popup;
|
2002-07-16 03:46:29 +02:00
|
|
|
|
2009-01-08 14:13:17 +01:00
|
|
|
if (!Globals.active_popup) return FALSE;
|
2002-07-16 03:46:29 +02:00
|
|
|
|
|
|
|
switch (msg)
|
1996-05-06 18:06:24 +02:00
|
|
|
{
|
2009-01-08 14:13:17 +01:00
|
|
|
case WM_NOTIFY:
|
|
|
|
{
|
|
|
|
MSGFILTER* msgf = (MSGFILTER*)lParam;
|
|
|
|
if (msgf->nmhdr.code == EN_MSGFILTER)
|
2008-05-01 21:17:29 +02:00
|
|
|
{
|
2009-01-08 14:13:17 +01:00
|
|
|
if (!WINHELP_CheckPopup(hWnd, msgf->msg, msgf->wParam, msgf->lParam, NULL))
|
|
|
|
return FALSE;
|
|
|
|
if (lret) *lret = 1;
|
|
|
|
return TRUE;
|
2008-05-01 21:17:29 +02:00
|
|
|
}
|
2008-06-27 21:29:07 +02:00
|
|
|
}
|
|
|
|
break;
|
2009-01-08 14:13:17 +01:00
|
|
|
case WM_ACTIVATE:
|
2010-06-04 22:12:39 +02:00
|
|
|
if (LOWORD(wParam) != WA_INACTIVE || (HWND)lParam == Globals.active_win->hMainWnd ||
|
2009-01-08 14:13:17 +01:00
|
|
|
(HWND)lParam == Globals.active_popup->hMainWnd ||
|
|
|
|
GetWindow((HWND)lParam, GW_OWNER) == Globals.active_win->hMainWnd)
|
|
|
|
break;
|
2010-06-13 15:39:35 +02:00
|
|
|
/* fall through */
|
2009-01-08 14:13:17 +01:00
|
|
|
case WM_LBUTTONDOWN:
|
2010-06-13 15:39:35 +02:00
|
|
|
if (msg == WM_LBUTTONDOWN)
|
|
|
|
WINHELP_HandleTextMouse(Globals.active_popup, msg, lParam);
|
2009-01-08 14:13:17 +01:00
|
|
|
/* fall through */
|
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
case WM_NCLBUTTONDOWN:
|
|
|
|
case WM_NCMBUTTONDOWN:
|
|
|
|
case WM_NCRBUTTONDOWN:
|
2009-05-30 14:27:04 +02:00
|
|
|
popup = Globals.active_popup;
|
2009-01-08 14:13:17 +01:00
|
|
|
Globals.active_popup = NULL;
|
2009-05-30 14:27:04 +02:00
|
|
|
WINHELP_ReleaseWindow(popup);
|
2016-05-09 18:09:46 +02:00
|
|
|
if (lret) *lret = 1;
|
2009-01-08 14:13:17 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-06-27 21:29:07 +02:00
|
|
|
|
2009-01-08 14:13:17 +01:00
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* WINHELP_ButtonWndProc
|
|
|
|
*/
|
|
|
|
static LRESULT CALLBACK WINHELP_ButtonWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
if (WINHELP_CheckPopup(hWnd, msg, wParam, lParam, NULL)) return 0;
|
2004-09-07 22:42:05 +02:00
|
|
|
|
2009-01-08 14:13:17 +01:00
|
|
|
if (msg == WM_KEYDOWN)
|
|
|
|
{
|
2004-09-07 22:42:05 +02:00
|
|
|
switch (wParam)
|
|
|
|
{
|
|
|
|
case VK_UP:
|
|
|
|
case VK_DOWN:
|
|
|
|
case VK_PRIOR:
|
|
|
|
case VK_NEXT:
|
|
|
|
case VK_ESCAPE:
|
2012-01-20 12:50:15 +01:00
|
|
|
return SendMessageA(GetParent(hWnd), msg, wParam, lParam);
|
2008-04-18 21:34:17 +02:00
|
|
|
}
|
1996-05-06 18:06:24 +02:00
|
|
|
}
|
2008-05-01 21:17:41 +02:00
|
|
|
|
2012-01-20 12:50:15 +01:00
|
|
|
return CallWindowProcA(Globals.button_proc, hWnd, msg, wParam, lParam);
|
2008-04-23 21:37:51 +02:00
|
|
|
}
|
|
|
|
|
1996-05-06 18:06:24 +02:00
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* WINHELP_ButtonBoxWndProc
|
|
|
|
*/
|
2002-07-16 03:46:29 +02:00
|
|
|
static LRESULT CALLBACK WINHELP_ButtonBoxWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
1996-05-06 18:06:24 +02:00
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
WINDOWPOS *winpos;
|
|
|
|
WINHELP_WINDOW *win;
|
|
|
|
WINHELP_BUTTON *button;
|
|
|
|
SIZE button_size;
|
|
|
|
INT x, y;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
2008-04-23 21:38:27 +02:00
|
|
|
if (WINHELP_CheckPopup(hWnd, msg, wParam, lParam, NULL)) return 0L;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
switch (msg)
|
1996-05-06 18:06:24 +02:00
|
|
|
{
|
|
|
|
case WM_WINDOWPOSCHANGING:
|
2002-07-16 03:46:29 +02:00
|
|
|
winpos = (WINDOWPOS*) lParam;
|
2012-01-20 12:50:15 +01:00
|
|
|
win = (WINHELP_WINDOW*) GetWindowLongPtrW(GetParent(hWnd), 0);
|
1996-05-06 18:06:24 +02:00
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
/* Update buttons */
|
|
|
|
button_size.cx = 0;
|
|
|
|
button_size.cy = 0;
|
|
|
|
for (button = win->first_button; button; button = button->next)
|
1996-05-06 18:06:24 +02:00
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
HDC hDc;
|
|
|
|
SIZE textsize;
|
|
|
|
if (!button->hWnd)
|
2004-09-07 22:42:05 +02:00
|
|
|
{
|
2012-01-20 12:50:15 +01:00
|
|
|
button->hWnd = CreateWindowA(STRING_BUTTON, button->lpszName,
|
2002-07-16 03:46:29 +02:00
|
|
|
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
|
|
|
0, 0, 0, 0,
|
|
|
|
hWnd, (HMENU) button->wParam,
|
|
|
|
Globals.hInstance, 0);
|
2008-07-12 10:36:49 +02:00
|
|
|
if (button->hWnd)
|
|
|
|
{
|
2004-09-07 22:42:05 +02:00
|
|
|
if (Globals.button_proc == NULL)
|
2008-07-12 10:36:49 +02:00
|
|
|
{
|
|
|
|
NONCLIENTMETRICSW ncm;
|
2012-01-20 12:50:15 +01:00
|
|
|
Globals.button_proc = (WNDPROC) GetWindowLongPtrA(button->hWnd, GWLP_WNDPROC);
|
2008-07-12 10:36:49 +02:00
|
|
|
|
|
|
|
ncm.cbSize = sizeof(NONCLIENTMETRICSW);
|
|
|
|
SystemParametersInfoW(SPI_GETNONCLIENTMETRICS,
|
|
|
|
sizeof(NONCLIENTMETRICSW), &ncm, 0);
|
|
|
|
Globals.hButtonFont = CreateFontIndirectW(&ncm.lfMenuFont);
|
|
|
|
}
|
2012-01-20 12:50:15 +01:00
|
|
|
SetWindowLongPtrA(button->hWnd, GWLP_WNDPROC, (LONG_PTR) WINHELP_ButtonWndProc);
|
2008-07-12 10:36:49 +02:00
|
|
|
if (Globals.hButtonFont)
|
2012-01-20 12:50:15 +01:00
|
|
|
SendMessageW(button->hWnd, WM_SETFONT, (WPARAM)Globals.hButtonFont, TRUE);
|
2004-09-07 22:42:05 +02:00
|
|
|
}
|
|
|
|
}
|
2002-07-16 03:46:29 +02:00
|
|
|
hDc = GetDC(button->hWnd);
|
2012-01-20 12:50:15 +01:00
|
|
|
GetTextExtentPointA(hDc, button->lpszName, strlen(button->lpszName), &textsize);
|
2002-07-16 03:46:29 +02:00
|
|
|
ReleaseDC(button->hWnd, hDc);
|
|
|
|
|
|
|
|
button_size.cx = max(button_size.cx, textsize.cx + BUTTON_CX);
|
|
|
|
button_size.cy = max(button_size.cy, textsize.cy + BUTTON_CY);
|
1996-05-06 18:06:24 +02:00
|
|
|
}
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
x = 0;
|
|
|
|
y = 0;
|
|
|
|
for (button = win->first_button; button; button = button->next)
|
1996-05-06 18:06:24 +02:00
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
SetWindowPos(button->hWnd, HWND_TOP, x, y, button_size.cx, button_size.cy, 0);
|
1996-05-06 18:06:24 +02:00
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
if (x + 2 * button_size.cx <= winpos->cx)
|
|
|
|
x += button_size.cx;
|
|
|
|
else
|
|
|
|
x = 0, y += button_size.cy;
|
1996-05-06 18:06:24 +02:00
|
|
|
}
|
2002-07-16 03:46:29 +02:00
|
|
|
winpos->cy = y + (x ? button_size.cy : 0);
|
|
|
|
break;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
|
|
|
case WM_COMMAND:
|
2012-01-20 12:50:15 +01:00
|
|
|
SendMessageW(GetParent(hWnd), msg, wParam, lParam);
|
2002-07-16 03:46:29 +02:00
|
|
|
break;
|
2004-09-25 02:28:59 +02:00
|
|
|
|
|
|
|
case WM_KEYDOWN:
|
|
|
|
switch (wParam)
|
|
|
|
{
|
|
|
|
case VK_UP:
|
|
|
|
case VK_DOWN:
|
|
|
|
case VK_PRIOR:
|
|
|
|
case VK_NEXT:
|
|
|
|
case VK_ESCAPE:
|
2012-01-20 12:50:15 +01:00
|
|
|
return SendMessageA(GetParent(hWnd), msg, wParam, lParam);
|
2004-09-25 02:28:59 +02:00
|
|
|
}
|
|
|
|
break;
|
1996-05-06 18:06:24 +02:00
|
|
|
}
|
|
|
|
|
2012-01-20 12:50:15 +01:00
|
|
|
return DefWindowProcA(hWnd, msg, wParam, lParam);
|
1996-05-06 18:06:24 +02:00
|
|
|
}
|
|
|
|
|
2002-11-20 20:46:18 +01:00
|
|
|
/******************************************************************
|
|
|
|
* WINHELP_HistoryWndProc
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static LRESULT CALLBACK WINHELP_HistoryWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
WINHELP_WINDOW* win;
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
HDC hDc;
|
2012-01-20 12:50:15 +01:00
|
|
|
TEXTMETRICW tm;
|
2004-09-22 04:46:38 +02:00
|
|
|
unsigned int i;
|
2002-11-20 20:46:18 +01:00
|
|
|
RECT r;
|
|
|
|
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_NCCREATE:
|
2012-01-20 12:50:15 +01:00
|
|
|
win = (WINHELP_WINDOW*)((LPCREATESTRUCTA)lParam)->lpCreateParams;
|
|
|
|
SetWindowLongPtrW(hWnd, 0, (ULONG_PTR)win);
|
2002-11-20 20:46:18 +01:00
|
|
|
win->hHistoryWnd = hWnd;
|
|
|
|
break;
|
|
|
|
case WM_CREATE:
|
|
|
|
hDc = GetDC(hWnd);
|
2012-01-20 12:50:15 +01:00
|
|
|
GetTextMetricsW(hDc, &tm);
|
2002-11-20 20:46:18 +01:00
|
|
|
GetWindowRect(hWnd, &r);
|
|
|
|
|
|
|
|
r.right = r.left + 30 * tm.tmAveCharWidth;
|
2018-08-10 12:27:55 +02:00
|
|
|
r.bottom = r.top + ARRAY_SIZE(Globals.history.set) * tm.tmHeight;
|
2012-01-20 12:50:15 +01:00
|
|
|
AdjustWindowRect(&r, GetWindowLongW(hWnd, GWL_STYLE), FALSE);
|
2002-11-20 20:46:18 +01:00
|
|
|
if (r.left < 0) {r.right -= r.left; r.left = 0;}
|
|
|
|
if (r.top < 0) {r.bottom -= r.top; r.top = 0;}
|
|
|
|
|
|
|
|
MoveWindow(hWnd, r.left, r.top, r.right, r.bottom, TRUE);
|
|
|
|
ReleaseDC(hWnd, hDc);
|
|
|
|
break;
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
hDc = GetDC(hWnd);
|
2012-01-20 12:50:15 +01:00
|
|
|
GetTextMetricsW(hDc, &tm);
|
2002-11-20 20:46:18 +01:00
|
|
|
i = HIWORD(lParam) / tm.tmHeight;
|
2008-04-22 21:59:38 +02:00
|
|
|
if (i < Globals.history.index)
|
2008-04-22 22:00:20 +02:00
|
|
|
WINHELP_CreateHelpWindow(&Globals.history.set[i], SW_SHOW, TRUE);
|
2002-11-20 20:46:18 +01:00
|
|
|
ReleaseDC(hWnd, hDc);
|
|
|
|
break;
|
|
|
|
case WM_PAINT:
|
|
|
|
hDc = BeginPaint(hWnd, &ps);
|
2012-01-20 12:50:15 +01:00
|
|
|
GetTextMetricsW(hDc, &tm);
|
2002-11-20 20:46:18 +01:00
|
|
|
|
2008-04-22 21:59:38 +02:00
|
|
|
for (i = 0; i < Globals.history.index; i++)
|
2002-11-20 20:46:18 +01:00
|
|
|
{
|
2008-04-22 21:59:51 +02:00
|
|
|
if (Globals.history.set[i].page->file == Globals.active_win->page->file)
|
|
|
|
{
|
2012-01-20 12:50:15 +01:00
|
|
|
TextOutA(hDc, 0, i * tm.tmHeight,
|
2008-04-22 21:59:51 +02:00
|
|
|
Globals.history.set[i].page->lpszTitle,
|
|
|
|
strlen(Globals.history.set[i].page->lpszTitle));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char buffer[1024];
|
|
|
|
const char* ptr1;
|
|
|
|
const char* ptr2;
|
|
|
|
unsigned len;
|
|
|
|
|
|
|
|
ptr1 = strrchr(Globals.history.set[i].page->file->lpszPath, '\\');
|
|
|
|
if (!ptr1) ptr1 = Globals.history.set[i].page->file->lpszPath;
|
|
|
|
else ptr1++;
|
|
|
|
ptr2 = strrchr(ptr1, '.');
|
|
|
|
len = ptr2 ? ptr2 - ptr1 : strlen(ptr1);
|
|
|
|
if (len > sizeof(buffer)) len = sizeof(buffer);
|
|
|
|
memcpy(buffer, ptr1, len);
|
|
|
|
if (len < sizeof(buffer)) buffer[len++] = ':';
|
2012-01-23 12:13:03 +01:00
|
|
|
lstrcpynA(&buffer[len], Globals.history.set[i].page->lpszTitle, sizeof(buffer) - len);
|
2012-01-20 12:50:15 +01:00
|
|
|
TextOutA(hDc, 0, i * tm.tmHeight, buffer, strlen(buffer));
|
2008-04-22 21:59:51 +02:00
|
|
|
}
|
2002-11-20 20:46:18 +01:00
|
|
|
}
|
|
|
|
EndPaint(hWnd, &ps);
|
|
|
|
break;
|
|
|
|
case WM_DESTROY:
|
2012-01-20 12:50:15 +01:00
|
|
|
win = (WINHELP_WINDOW*) GetWindowLongPtrW(hWnd, 0);
|
2002-11-20 20:46:18 +01:00
|
|
|
if (hWnd == win->hHistoryWnd)
|
|
|
|
win->hHistoryWnd = 0;
|
|
|
|
break;
|
|
|
|
}
|
2012-01-20 12:50:15 +01:00
|
|
|
return DefWindowProcA(hWnd, msg, wParam, lParam);
|
2002-11-20 20:46:18 +01:00
|
|
|
}
|
|
|
|
|
2009-01-08 14:13:17 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* cb_KWBTree
|
|
|
|
*
|
|
|
|
* HLPFILE_BPTreeCallback enumeration function for '|KWBTREE' internal file.
|
1996-05-06 18:06:24 +02:00
|
|
|
*
|
|
|
|
*/
|
2009-01-08 14:13:17 +01:00
|
|
|
static void cb_KWBTree(void *p, void **next, void *cookie)
|
1996-05-06 18:06:24 +02:00
|
|
|
{
|
2009-04-06 11:51:26 +02:00
|
|
|
HWND hListWnd = cookie;
|
2009-01-08 14:13:17 +01:00
|
|
|
int count;
|
2008-04-22 22:01:14 +02:00
|
|
|
|
2016-04-21 22:03:57 +02:00
|
|
|
WINE_TRACE("Adding %s to search list\n", debugstr_a((char *)p));
|
2012-01-20 12:50:15 +01:00
|
|
|
SendMessageA(hListWnd, LB_INSERTSTRING, -1, (LPARAM)p);
|
|
|
|
count = SendMessageW(hListWnd, LB_GETCOUNT, 0, 0);
|
|
|
|
SendMessageW(hListWnd, LB_SETITEMDATA, count-1, (LPARAM)p);
|
2009-01-08 14:13:17 +01:00
|
|
|
*next = (char*)p + strlen((char*)p) + 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct index_data
|
|
|
|
{
|
|
|
|
HLPFILE* hlpfile;
|
|
|
|
BOOL jump;
|
|
|
|
ULONG offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* WINHELP_IndexDlgProc
|
|
|
|
*
|
|
|
|
*/
|
2009-01-08 14:13:30 +01:00
|
|
|
static INT_PTR CALLBACK WINHELP_IndexDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
2009-01-08 14:13:17 +01:00
|
|
|
{
|
|
|
|
static struct index_data* id;
|
|
|
|
int sel;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
switch (msg)
|
1996-05-06 18:06:24 +02:00
|
|
|
{
|
2009-01-08 14:13:17 +01:00
|
|
|
case WM_INITDIALOG:
|
2012-01-20 12:50:15 +01:00
|
|
|
id = (struct index_data*)((PROPSHEETPAGEA*)lParam)->lParam;
|
2009-01-08 14:13:17 +01:00
|
|
|
HLPFILE_BPTreeEnum(id->hlpfile->kwbtree, cb_KWBTree,
|
|
|
|
GetDlgItem(hWnd, IDC_INDEXLIST));
|
|
|
|
id->jump = FALSE;
|
|
|
|
id->offset = 1;
|
|
|
|
return TRUE;
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (HIWORD(wParam))
|
2008-04-23 21:38:27 +02:00
|
|
|
{
|
2009-01-08 14:13:17 +01:00
|
|
|
case LBN_DBLCLK:
|
|
|
|
if (LOWORD(wParam) == IDC_INDEXLIST)
|
2012-01-20 12:50:15 +01:00
|
|
|
SendMessageW(GetParent(hWnd), PSM_PRESSBUTTON, PSBTN_OK, 0);
|
2009-01-08 14:13:17 +01:00
|
|
|
break;
|
2008-07-12 10:37:38 +02:00
|
|
|
}
|
|
|
|
break;
|
2008-06-27 21:28:44 +02:00
|
|
|
case WM_NOTIFY:
|
|
|
|
switch (((NMHDR*)lParam)->code)
|
|
|
|
{
|
|
|
|
case PSN_APPLY:
|
2012-01-20 12:50:15 +01:00
|
|
|
sel = SendDlgItemMessageW(hWnd, IDC_INDEXLIST, LB_GETCURSEL, 0, 0);
|
2007-12-12 22:56:18 +01:00
|
|
|
if (sel != LB_ERR)
|
|
|
|
{
|
|
|
|
BYTE *p;
|
|
|
|
int count;
|
|
|
|
|
2012-01-20 12:50:15 +01:00
|
|
|
p = (BYTE*)SendDlgItemMessageW(hWnd, IDC_INDEXLIST, LB_GETITEMDATA, sel, 0);
|
2007-12-12 22:56:18 +01:00
|
|
|
count = *(short*)((char *)p + strlen((char *)p) + 1);
|
|
|
|
if (count > 1)
|
|
|
|
{
|
2012-01-20 12:50:15 +01:00
|
|
|
MessageBoxA(hWnd, "count > 1 not supported yet", "Error", MB_OK | MB_ICONSTOP);
|
|
|
|
SetWindowLongPtrW(hWnd, DWLP_MSGRESULT, PSNRET_INVALID);
|
2007-12-12 22:56:18 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
2008-06-27 21:28:44 +02:00
|
|
|
id->offset = *(ULONG*)((char *)p + strlen((char *)p) + 3);
|
|
|
|
id->offset = *(long*)(id->hlpfile->kwdata + id->offset + 9);
|
|
|
|
if (id->offset == 0xFFFFFFFF)
|
2007-12-12 22:56:18 +01:00
|
|
|
{
|
2012-01-20 12:50:15 +01:00
|
|
|
MessageBoxA(hWnd, "macro keywords not supported yet", "Error", MB_OK | MB_ICONSTOP);
|
|
|
|
SetWindowLongPtrW(hWnd, DWLP_MSGRESULT, PSNRET_INVALID);
|
2007-12-12 22:56:18 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
2008-06-27 21:28:44 +02:00
|
|
|
id->jump = TRUE;
|
2012-01-20 12:50:15 +01:00
|
|
|
SetWindowLongPtrW(hWnd, DWLP_MSGRESULT, PSNRET_NOERROR);
|
2007-12-12 22:56:18 +01:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
default:
|
2008-06-27 21:28:44 +02:00
|
|
|
return FALSE;
|
2007-12-12 22:56:18 +01:00
|
|
|
}
|
2008-06-27 21:28:44 +02:00
|
|
|
break;
|
2007-12-12 22:56:18 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-07-05 21:33:19 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* WINHELP_SearchDlgProc
|
|
|
|
*
|
|
|
|
*/
|
2009-01-08 14:13:30 +01:00
|
|
|
static INT_PTR CALLBACK WINHELP_SearchDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
2008-07-05 21:33:19 +02:00
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
return TRUE;
|
|
|
|
case WM_NOTIFY:
|
|
|
|
switch (((NMHDR*)lParam)->code)
|
|
|
|
{
|
|
|
|
case PSN_APPLY:
|
2012-01-20 12:50:15 +01:00
|
|
|
SetWindowLongPtrW(hWnd, DWLP_MSGRESULT, PSNRET_NOERROR);
|
2008-07-05 21:33:19 +02:00
|
|
|
return TRUE;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-01-08 14:13:17 +01:00
|
|
|
/***********************************************************************
|
2007-12-12 22:56:18 +01:00
|
|
|
*
|
2009-01-08 14:13:17 +01:00
|
|
|
* WINHELP_MainWndProc
|
2007-12-12 22:56:18 +01:00
|
|
|
*/
|
2009-01-08 14:13:17 +01:00
|
|
|
static LRESULT CALLBACK WINHELP_MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
2007-12-12 22:56:18 +01:00
|
|
|
{
|
2009-01-08 14:13:17 +01:00
|
|
|
WINHELP_WINDOW *win;
|
|
|
|
WINHELP_BUTTON *button;
|
|
|
|
HWND hTextWnd;
|
|
|
|
LRESULT ret;
|
2007-12-12 22:56:18 +01:00
|
|
|
|
2009-01-08 14:13:17 +01:00
|
|
|
if (WINHELP_CheckPopup(hWnd, msg, wParam, lParam, &ret)) return ret;
|
2007-12-12 22:56:18 +01:00
|
|
|
|
2009-01-08 14:13:17 +01:00
|
|
|
switch (msg)
|
2007-12-12 22:56:18 +01:00
|
|
|
{
|
2009-01-08 14:13:17 +01:00
|
|
|
case WM_NCCREATE:
|
2012-01-20 12:50:15 +01:00
|
|
|
win = (WINHELP_WINDOW*) ((LPCREATESTRUCTA) lParam)->lpCreateParams;
|
|
|
|
SetWindowLongPtrW(hWnd, 0, (ULONG_PTR) win);
|
2009-01-08 14:13:17 +01:00
|
|
|
if (!win->page && Globals.isBook)
|
2012-01-20 12:50:15 +01:00
|
|
|
PostMessageW(hWnd, WM_COMMAND, MNID_FILE_OPEN, 0);
|
2009-01-08 14:13:17 +01:00
|
|
|
win->hMainWnd = hWnd;
|
|
|
|
break;
|
2007-12-12 22:56:18 +01:00
|
|
|
|
2009-01-08 14:13:17 +01:00
|
|
|
case WM_WINDOWPOSCHANGED:
|
2012-01-20 12:50:15 +01:00
|
|
|
WINHELP_LayoutMainWindow((WINHELP_WINDOW*) GetWindowLongPtrW(hWnd, 0));
|
2009-01-08 14:13:17 +01:00
|
|
|
break;
|
2008-06-27 21:28:44 +02:00
|
|
|
|
2009-01-08 14:13:17 +01:00
|
|
|
case WM_COMMAND:
|
2012-01-20 12:50:15 +01:00
|
|
|
win = (WINHELP_WINDOW*) GetWindowLongPtrW(hWnd, 0);
|
2011-04-08 12:03:25 +02:00
|
|
|
switch (LOWORD(wParam))
|
2009-01-08 14:13:17 +01:00
|
|
|
{
|
|
|
|
/* Menu FILE */
|
|
|
|
case MNID_FILE_OPEN: MACRO_FileOpen(); break;
|
|
|
|
case MNID_FILE_PRINT: MACRO_Print(); break;
|
|
|
|
case MNID_FILE_SETUP: MACRO_PrinterSetup(); break;
|
|
|
|
case MNID_FILE_EXIT: MACRO_Exit(); break;
|
|
|
|
|
|
|
|
/* Menu EDIT */
|
|
|
|
case MNID_EDIT_COPYDLG:
|
2012-01-20 12:50:15 +01:00
|
|
|
SendDlgItemMessageW(hWnd, CTL_ID_TEXT, WM_COPY, 0, 0);
|
2009-01-08 14:13:17 +01:00
|
|
|
break;
|
|
|
|
case MNID_EDIT_ANNOTATE:MACRO_Annotate(); break;
|
|
|
|
|
|
|
|
/* Menu Bookmark */
|
|
|
|
case MNID_BKMK_DEFINE: MACRO_BookmarkDefine(); break;
|
|
|
|
|
|
|
|
/* Menu Help */
|
|
|
|
case MNID_HELP_HELPON: MACRO_HelpOn(); break;
|
|
|
|
case MNID_HELP_HELPTOP: MACRO_HelpOnTop(); break;
|
|
|
|
case MNID_HELP_ABOUT: MACRO_About(); break;
|
|
|
|
|
|
|
|
/* Context help */
|
|
|
|
case MNID_CTXT_ANNOTATE:MACRO_Annotate(); break;
|
|
|
|
case MNID_CTXT_COPY: MACRO_CopyDialog(); break;
|
|
|
|
case MNID_CTXT_PRINT: MACRO_Print(); break;
|
|
|
|
case MNID_OPTS_HISTORY: MACRO_History(); break;
|
|
|
|
case MNID_OPTS_FONTS_SMALL:
|
|
|
|
case MNID_CTXT_FONTS_SMALL:
|
2012-01-20 12:50:15 +01:00
|
|
|
win = (WINHELP_WINDOW*) GetWindowLongPtrW(hWnd, 0);
|
2009-01-08 14:13:17 +01:00
|
|
|
if (win->font_scale != 0)
|
|
|
|
{
|
|
|
|
win->font_scale = 0;
|
|
|
|
WINHELP_SetupText(GetDlgItem(hWnd, CTL_ID_TEXT), win, 0 /* FIXME */);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MNID_OPTS_FONTS_NORMAL:
|
|
|
|
case MNID_CTXT_FONTS_NORMAL:
|
2012-01-20 12:50:15 +01:00
|
|
|
win = (WINHELP_WINDOW*) GetWindowLongPtrW(hWnd, 0);
|
2009-01-08 14:13:17 +01:00
|
|
|
if (win->font_scale != 1)
|
|
|
|
{
|
|
|
|
win->font_scale = 1;
|
|
|
|
WINHELP_SetupText(GetDlgItem(hWnd, CTL_ID_TEXT), win, 0 /* FIXME */);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MNID_OPTS_FONTS_LARGE:
|
|
|
|
case MNID_CTXT_FONTS_LARGE:
|
2012-01-20 12:50:15 +01:00
|
|
|
win = (WINHELP_WINDOW*) GetWindowLongPtrW(hWnd, 0);
|
2009-01-08 14:13:17 +01:00
|
|
|
if (win->font_scale != 2)
|
|
|
|
{
|
|
|
|
win->font_scale = 2;
|
|
|
|
WINHELP_SetupText(GetDlgItem(hWnd, CTL_ID_TEXT), win, 0 /* FIXME */);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* Buttons */
|
|
|
|
for (button = win->first_button; button; button = button->next)
|
|
|
|
if (wParam == button->wParam) break;
|
|
|
|
if (button)
|
2009-05-30 14:26:33 +02:00
|
|
|
MACRO_ExecuteMacro(win, button->lpszMacro);
|
2009-01-08 14:13:17 +01:00
|
|
|
else if (!HIWORD(wParam))
|
2012-01-20 12:50:15 +01:00
|
|
|
MessageBoxW(0, MAKEINTRESOURCEW(STID_NOT_IMPLEMENTED),
|
|
|
|
MAKEINTRESOURCEW(STID_WHERROR), MB_OK);
|
2009-01-08 14:13:17 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
/* EPP case WM_DESTROY: */
|
|
|
|
/* EPP if (Globals.hPopupWnd) DestroyWindow(Globals.hPopupWnd); */
|
|
|
|
/* EPP break; */
|
|
|
|
case WM_COPYDATA:
|
|
|
|
return WINHELP_HandleCommand((HWND)wParam, lParam);
|
|
|
|
|
|
|
|
case WM_CHAR:
|
|
|
|
if (wParam == 3)
|
|
|
|
{
|
2012-01-20 12:50:15 +01:00
|
|
|
SendDlgItemMessageW(hWnd, CTL_ID_TEXT, WM_COPY, 0, 0);
|
2009-01-08 14:13:17 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_KEYDOWN:
|
2012-01-20 12:50:15 +01:00
|
|
|
win = (WINHELP_WINDOW*) GetWindowLongPtrW(hWnd, 0);
|
2009-03-07 08:09:04 +01:00
|
|
|
hTextWnd = GetDlgItem(win->hMainWnd, CTL_ID_TEXT);
|
2009-01-08 14:13:17 +01:00
|
|
|
|
|
|
|
switch (wParam)
|
|
|
|
{
|
|
|
|
case VK_UP:
|
2012-01-20 12:50:15 +01:00
|
|
|
SendMessageW(hTextWnd, EM_SCROLL, SB_LINEUP, 0);
|
2009-03-07 08:09:04 +01:00
|
|
|
return 0;
|
2009-01-08 14:13:17 +01:00
|
|
|
case VK_DOWN:
|
2012-01-20 12:50:15 +01:00
|
|
|
SendMessageW(hTextWnd, EM_SCROLL, SB_LINEDOWN, 0);
|
2009-03-07 08:09:04 +01:00
|
|
|
return 0;
|
2009-01-08 14:13:17 +01:00
|
|
|
case VK_PRIOR:
|
2012-01-20 12:50:15 +01:00
|
|
|
SendMessageW(hTextWnd, EM_SCROLL, SB_PAGEUP, 0);
|
2009-03-07 08:09:04 +01:00
|
|
|
return 0;
|
2009-01-08 14:13:17 +01:00
|
|
|
case VK_NEXT:
|
2012-01-20 12:50:15 +01:00
|
|
|
SendMessageW(hTextWnd, EM_SCROLL, SB_PAGEDOWN, 0);
|
2009-01-08 14:13:17 +01:00
|
|
|
return 0;
|
|
|
|
case VK_ESCAPE:
|
|
|
|
MACRO_Exit();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_NOTIFY:
|
|
|
|
if (wParam == CTL_ID_TEXT)
|
|
|
|
{
|
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
switch (((NMHDR*)lParam)->code)
|
|
|
|
{
|
|
|
|
case EN_MSGFILTER:
|
|
|
|
{
|
|
|
|
const MSGFILTER* msgf = (const MSGFILTER*)lParam;
|
|
|
|
switch (msgf->msg)
|
|
|
|
{
|
|
|
|
case WM_KEYUP:
|
2009-05-30 14:27:04 +02:00
|
|
|
if (msgf->wParam == VK_ESCAPE)
|
2012-01-20 12:50:15 +01:00
|
|
|
WINHELP_ReleaseWindow((WINHELP_WINDOW*)GetWindowLongPtrW(hWnd, 0));
|
2009-01-08 14:13:17 +01:00
|
|
|
break;
|
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
{
|
|
|
|
HMENU hMenu;
|
|
|
|
POINT pt;
|
|
|
|
|
2012-01-20 12:50:15 +01:00
|
|
|
win = (WINHELP_WINDOW*) GetWindowLongPtrW(hWnd, 0);
|
|
|
|
hMenu = LoadMenuW(Globals.hInstance, MAKEINTRESOURCEW(CONTEXT_MENU));
|
2009-01-08 14:13:17 +01:00
|
|
|
switch (win->font_scale)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
CheckMenuItem(hMenu, MNID_CTXT_FONTS_SMALL,
|
|
|
|
MF_BYCOMMAND|MF_CHECKED);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WINE_FIXME("Unsupported %d\n", win->font_scale);
|
2012-11-07 23:19:21 +01:00
|
|
|
/* fall through */
|
2009-01-08 14:13:17 +01:00
|
|
|
case 1:
|
|
|
|
CheckMenuItem(hMenu, MNID_CTXT_FONTS_NORMAL,
|
|
|
|
MF_BYCOMMAND|MF_CHECKED);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
CheckMenuItem(hMenu, MNID_CTXT_FONTS_LARGE,
|
|
|
|
MF_BYCOMMAND|MF_CHECKED);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pt.x = (int)(short)LOWORD(msgf->lParam);
|
|
|
|
pt.y = (int)(short)HIWORD(msgf->lParam);
|
|
|
|
ClientToScreen(msgf->nmhdr.hwndFrom, &pt);
|
|
|
|
TrackPopupMenu(GetSubMenu(hMenu, 0), TPM_LEFTALIGN|TPM_TOPALIGN,
|
|
|
|
pt.x, pt.y, 0, hWnd, NULL);
|
|
|
|
DestroyMenu(hMenu);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2012-01-20 12:50:15 +01:00
|
|
|
return WINHELP_HandleTextMouse((WINHELP_WINDOW*)GetWindowLongPtrW(hWnd, 0),
|
2009-01-08 14:13:17 +01:00
|
|
|
msgf->msg, msgf->lParam);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EN_REQUESTRESIZE:
|
|
|
|
rc = ((REQRESIZE*)lParam)->rc;
|
2012-01-20 12:50:15 +01:00
|
|
|
win = (WINHELP_WINDOW*) GetWindowLongPtrW(hWnd, 0);
|
|
|
|
AdjustWindowRect(&rc, GetWindowLongW(win->hMainWnd, GWL_STYLE),
|
2009-01-08 14:13:17 +01:00
|
|
|
FALSE);
|
|
|
|
SetWindowPos(win->hMainWnd, HWND_TOP, 0, 0,
|
|
|
|
rc.right - rc.left, rc.bottom - rc.top,
|
|
|
|
SWP_NOMOVE | SWP_NOZORDER);
|
|
|
|
WINHELP_LayoutMainWindow(win);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_INITMENUPOPUP:
|
2012-01-20 12:50:15 +01:00
|
|
|
win = (WINHELP_WINDOW*) GetWindowLongPtrW(hWnd, 0);
|
2009-01-08 14:13:17 +01:00
|
|
|
CheckMenuItem((HMENU)wParam, MNID_OPTS_FONTS_SMALL,
|
2015-03-06 10:17:21 +01:00
|
|
|
(win->font_scale == 0) ? MF_CHECKED : MF_UNCHECKED);
|
2009-01-08 14:13:17 +01:00
|
|
|
CheckMenuItem((HMENU)wParam, MNID_OPTS_FONTS_NORMAL,
|
2015-03-06 10:17:21 +01:00
|
|
|
(win->font_scale == 1) ? MF_CHECKED : MF_UNCHECKED);
|
2009-01-08 14:13:17 +01:00
|
|
|
CheckMenuItem((HMENU)wParam, MNID_OPTS_FONTS_LARGE,
|
2015-03-06 10:17:21 +01:00
|
|
|
(win->font_scale == 2) ? MF_CHECKED : MF_UNCHECKED);
|
2009-01-08 14:13:17 +01:00
|
|
|
break;
|
2009-05-30 14:27:04 +02:00
|
|
|
case WM_DESTROY:
|
2012-01-20 12:50:15 +01:00
|
|
|
win = (WINHELP_WINDOW*) GetWindowLongPtrW(hWnd, 0);
|
2009-05-30 14:27:04 +02:00
|
|
|
WINHELP_DeleteWindow(win);
|
2009-01-08 14:13:17 +01:00
|
|
|
break;
|
|
|
|
}
|
2012-01-20 12:50:15 +01:00
|
|
|
return DefWindowProcA(hWnd, msg, wParam, lParam);
|
2009-01-08 14:13:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* WINHELP_CreateIndexWindow
|
|
|
|
*
|
|
|
|
* Displays a dialog with keywords of current help file.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINHELP_CreateIndexWindow(BOOL is_search)
|
|
|
|
{
|
|
|
|
HPROPSHEETPAGE psPage[3];
|
2012-01-20 12:50:15 +01:00
|
|
|
PROPSHEETPAGEA psp;
|
|
|
|
PROPSHEETHEADERA psHead;
|
2009-01-08 14:13:17 +01:00
|
|
|
struct index_data id;
|
|
|
|
char buf[256];
|
|
|
|
|
|
|
|
if (Globals.active_win && Globals.active_win->page && Globals.active_win->page->file)
|
|
|
|
id.hlpfile = Globals.active_win->page->file;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (id.hlpfile->kwbtree == NULL)
|
|
|
|
{
|
|
|
|
WINE_TRACE("No index provided\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
InitCommonControls();
|
|
|
|
|
|
|
|
id.jump = FALSE;
|
|
|
|
memset(&psp, 0, sizeof(psp));
|
|
|
|
psp.dwSize = sizeof(psp);
|
|
|
|
psp.dwFlags = 0;
|
2008-06-27 21:28:44 +02:00
|
|
|
psp.hInstance = Globals.hInstance;
|
|
|
|
|
2012-01-20 12:50:15 +01:00
|
|
|
psp.u.pszTemplate = MAKEINTRESOURCEA(IDD_INDEX);
|
2008-06-27 21:28:44 +02:00
|
|
|
psp.lParam = (LPARAM)&id;
|
|
|
|
psp.pfnDlgProc = WINHELP_IndexDlgProc;
|
2012-01-20 12:50:15 +01:00
|
|
|
psPage[0] = CreatePropertySheetPageA(&psp);
|
2008-06-27 21:28:44 +02:00
|
|
|
|
2012-01-20 12:50:15 +01:00
|
|
|
psp.u.pszTemplate = MAKEINTRESOURCEA(IDD_SEARCH);
|
2008-07-05 21:33:19 +02:00
|
|
|
psp.lParam = (LPARAM)&id;
|
|
|
|
psp.pfnDlgProc = WINHELP_SearchDlgProc;
|
2012-01-20 12:50:15 +01:00
|
|
|
psPage[1] = CreatePropertySheetPageA(&psp);
|
2008-07-05 21:33:19 +02:00
|
|
|
|
2008-06-27 21:28:44 +02:00
|
|
|
memset(&psHead, 0, sizeof(psHead));
|
|
|
|
psHead.dwSize = sizeof(psHead);
|
|
|
|
|
2012-01-20 12:50:15 +01:00
|
|
|
LoadStringA(Globals.hInstance, STID_PSH_INDEX, buf, sizeof(buf));
|
2008-06-27 21:28:44 +02:00
|
|
|
strcat(buf, Globals.active_win->info->caption);
|
|
|
|
|
|
|
|
psHead.pszCaption = buf;
|
2008-07-05 21:33:19 +02:00
|
|
|
psHead.nPages = 2;
|
|
|
|
psHead.u2.nStartPage = is_search ? 1 : 0;
|
2008-06-27 21:28:44 +02:00
|
|
|
psHead.hwndParent = Globals.active_win->hMainWnd;
|
|
|
|
psHead.u3.phpage = psPage;
|
|
|
|
psHead.dwFlags = PSH_NOAPPLYNOW;
|
|
|
|
|
2012-01-20 12:50:15 +01:00
|
|
|
PropertySheetA(&psHead);
|
2008-06-27 21:28:44 +02:00
|
|
|
if (id.jump)
|
2008-01-06 16:35:06 +01:00
|
|
|
{
|
2008-06-27 21:28:44 +02:00
|
|
|
WINE_TRACE("got %d as an offset\n", id.offset);
|
|
|
|
WINHELP_OpenHelpWindow(HLPFILE_PageByOffset, id.hlpfile, id.offset,
|
2008-04-22 22:01:08 +02:00
|
|
|
Globals.active_win->info, SW_NORMAL);
|
2008-01-06 16:35:06 +01:00
|
|
|
}
|
2007-12-12 22:56:18 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
2009-01-08 14:13:17 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* RegisterWinClasses
|
|
|
|
*/
|
|
|
|
static BOOL WINHELP_RegisterWinClasses(void)
|
|
|
|
{
|
2012-01-20 12:50:15 +01:00
|
|
|
WNDCLASSEXA class_main, class_button_box, class_history;
|
2009-01-08 14:13:17 +01:00
|
|
|
|
2010-04-19 20:13:11 +02:00
|
|
|
class_main.cbSize = sizeof(class_main);
|
2009-01-08 14:13:17 +01:00
|
|
|
class_main.style = CS_HREDRAW | CS_VREDRAW;
|
|
|
|
class_main.lpfnWndProc = WINHELP_MainWndProc;
|
|
|
|
class_main.cbClsExtra = 0;
|
2009-01-08 17:34:08 +01:00
|
|
|
class_main.cbWndExtra = sizeof(WINHELP_WINDOW *);
|
2009-01-08 14:13:17 +01:00
|
|
|
class_main.hInstance = Globals.hInstance;
|
2012-01-20 12:50:15 +01:00
|
|
|
class_main.hIcon = LoadIconW(Globals.hInstance, MAKEINTRESOURCEW(IDI_WINHELP));
|
|
|
|
class_main.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
|
2009-01-08 14:13:17 +01:00
|
|
|
class_main.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
|
|
|
class_main.lpszMenuName = 0;
|
|
|
|
class_main.lpszClassName = MAIN_WIN_CLASS_NAME;
|
2012-01-20 12:50:15 +01:00
|
|
|
class_main.hIconSm = LoadImageW(Globals.hInstance, MAKEINTRESOURCEW(IDI_WINHELP), IMAGE_ICON,
|
2010-04-19 20:13:11 +02:00
|
|
|
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),
|
|
|
|
LR_SHARED);
|
2009-01-08 14:13:17 +01:00
|
|
|
|
|
|
|
class_button_box = class_main;
|
|
|
|
class_button_box.lpfnWndProc = WINHELP_ButtonBoxWndProc;
|
|
|
|
class_button_box.cbWndExtra = 0;
|
|
|
|
class_button_box.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
|
|
|
|
class_button_box.lpszClassName = BUTTON_BOX_WIN_CLASS_NAME;
|
|
|
|
|
|
|
|
class_history = class_main;
|
|
|
|
class_history.lpfnWndProc = WINHELP_HistoryWndProc;
|
|
|
|
class_history.lpszClassName = HISTORY_WIN_CLASS_NAME;
|
|
|
|
|
2012-01-20 12:50:15 +01:00
|
|
|
return (RegisterClassExA(&class_main) &&
|
|
|
|
RegisterClassExA(&class_button_box) &&
|
|
|
|
RegisterClassExA(&class_history));
|
2009-01-08 14:13:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* WinMain
|
|
|
|
*/
|
|
|
|
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show)
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
LONG lHash = 0;
|
|
|
|
HLPFILE* hlpfile;
|
|
|
|
static CHAR default_wndname[] = "main";
|
|
|
|
LPSTR wndname = default_wndname;
|
|
|
|
WINHELP_DLL* dll;
|
2011-04-08 12:03:25 +02:00
|
|
|
HACCEL hAccel;
|
2009-01-08 14:13:17 +01:00
|
|
|
|
|
|
|
Globals.hInstance = hInstance;
|
|
|
|
|
2012-01-20 12:50:15 +01:00
|
|
|
if (LoadLibraryA("riched20.dll") == NULL)
|
|
|
|
return MessageBoxW(0, MAKEINTRESOURCEW(STID_NO_RICHEDIT),
|
|
|
|
MAKEINTRESOURCEW(STID_WHERROR), MB_OK);
|
2009-01-08 14:13:17 +01:00
|
|
|
|
|
|
|
/* Get options */
|
|
|
|
while (*cmdline && (*cmdline == ' ' || *cmdline == '-'))
|
|
|
|
{
|
|
|
|
CHAR option;
|
|
|
|
LPCSTR topic_id;
|
|
|
|
if (*cmdline++ == ' ') continue;
|
|
|
|
|
|
|
|
option = *cmdline;
|
|
|
|
if (option) cmdline++;
|
2018-01-09 12:25:30 +01:00
|
|
|
while (*cmdline == ' ') cmdline++;
|
2009-01-08 14:13:17 +01:00
|
|
|
switch (option)
|
|
|
|
{
|
|
|
|
case 'i':
|
|
|
|
case 'I':
|
|
|
|
topic_id = cmdline;
|
|
|
|
while (*cmdline && *cmdline != ' ') cmdline++;
|
|
|
|
if (*cmdline) *cmdline++ = '\0';
|
|
|
|
lHash = HLPFILE_Hash(topic_id);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '3':
|
|
|
|
case '4':
|
|
|
|
Globals.wVersion = option - '0';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'x':
|
|
|
|
show = SW_HIDE;
|
|
|
|
Globals.isBook = FALSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-04-21 22:03:57 +02:00
|
|
|
WINE_FIXME("Unsupported cmd line: %s\n", debugstr_a(cmdline));
|
2009-01-08 14:13:17 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create primary window */
|
|
|
|
if (!WINHELP_RegisterWinClasses())
|
|
|
|
{
|
|
|
|
WINE_FIXME("Couldn't register classes\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*cmdline)
|
|
|
|
{
|
|
|
|
char* ptr;
|
|
|
|
if ((*cmdline == '"') && (ptr = strchr(cmdline+1, '"')))
|
|
|
|
{
|
|
|
|
cmdline++;
|
|
|
|
*ptr = '\0';
|
|
|
|
}
|
|
|
|
if ((ptr = strchr(cmdline, '>')))
|
|
|
|
{
|
|
|
|
*ptr = '\0';
|
|
|
|
wndname = ptr + 1;
|
|
|
|
}
|
|
|
|
hlpfile = WINHELP_LookupHelpFile(cmdline);
|
|
|
|
if (!hlpfile) return 0;
|
|
|
|
}
|
|
|
|
else hlpfile = NULL;
|
|
|
|
WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, lHash,
|
|
|
|
WINHELP_GetWindowInfo(hlpfile, wndname), show);
|
|
|
|
|
|
|
|
/* Message loop */
|
2011-04-08 12:03:25 +02:00
|
|
|
hAccel = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(MAIN_ACCEL));
|
2012-01-20 12:50:15 +01:00
|
|
|
while ((Globals.win_list || Globals.active_popup) && GetMessageW(&msg, 0, 0, 0))
|
2009-01-08 14:13:17 +01:00
|
|
|
{
|
2011-04-08 12:03:25 +02:00
|
|
|
HWND hWnd = Globals.active_win ? Globals.active_win->hMainWnd : NULL;
|
|
|
|
if (!TranslateAcceleratorW(hWnd, hAccel, &msg))
|
|
|
|
{
|
|
|
|
TranslateMessage(&msg);
|
2012-01-20 12:50:15 +01:00
|
|
|
DispatchMessageW(&msg);
|
2011-04-08 12:03:25 +02:00
|
|
|
}
|
2009-01-08 14:13:17 +01:00
|
|
|
}
|
|
|
|
for (dll = Globals.dlls; dll; dll = dll->next)
|
|
|
|
{
|
|
|
|
if (dll->class & DC_INITTERM) dll->handler(DW_TERM, 0, 0);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|