2005-08-01 11:21:53 +02:00
|
|
|
/*
|
|
|
|
* Help Viewer Implementation
|
|
|
|
*
|
|
|
|
* Copyright 2005 James Hawkins
|
2007-02-28 04:00:35 +01:00
|
|
|
* Copyright 2007 Jacek Caban for CodeWeavers
|
2005-08-01 11:21:53 +02: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
|
2005-08-01 11:21:53 +02:00
|
|
|
*/
|
|
|
|
|
2007-02-22 22:45:16 +01:00
|
|
|
#include "hhctrl.h"
|
2005-08-01 11:21:53 +02:00
|
|
|
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "commctrl.h"
|
2007-02-06 20:47:29 +01:00
|
|
|
#include "wininet.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
2005-08-01 11:21:53 +02:00
|
|
|
|
2005-08-03 13:46:52 +02:00
|
|
|
#include "resource.h"
|
|
|
|
|
2007-02-06 20:47:29 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp);
|
|
|
|
|
2007-02-28 03:51:59 +01:00
|
|
|
static LRESULT Help_OnSize(HWND hWnd);
|
2005-09-28 12:16:02 +02:00
|
|
|
|
2005-08-01 11:21:53 +02:00
|
|
|
/* Window type defaults */
|
|
|
|
|
2005-08-03 12:56:55 +02:00
|
|
|
#define WINTYPE_DEFAULT_X 280
|
|
|
|
#define WINTYPE_DEFAULT_Y 100
|
|
|
|
#define WINTYPE_DEFAULT_WIDTH 740
|
|
|
|
#define WINTYPE_DEFAULT_HEIGHT 640
|
2005-09-20 14:00:46 +02:00
|
|
|
#define WINTYPE_DEFAULT_NAVWIDTH 250
|
2005-08-01 11:21:53 +02:00
|
|
|
|
2007-02-28 03:56:33 +01:00
|
|
|
#define TAB_TOP_PADDING 8
|
|
|
|
#define TAB_RIGHT_PADDING 4
|
2007-02-28 03:57:12 +01:00
|
|
|
#define TAB_MARGIN 8
|
2007-02-28 03:56:33 +01:00
|
|
|
|
2005-09-21 13:42:41 +02:00
|
|
|
static const WCHAR szEmpty[] = {0};
|
|
|
|
|
2005-08-02 16:55:11 +02:00
|
|
|
/* Loads a string from the resource file */
|
|
|
|
static LPWSTR HH_LoadString(DWORD dwID)
|
|
|
|
{
|
|
|
|
LPWSTR string = NULL;
|
2008-03-05 21:28:54 +01:00
|
|
|
LPCWSTR stringresource;
|
2005-08-02 16:55:11 +02:00
|
|
|
int iSize;
|
|
|
|
|
2008-03-05 21:28:54 +01:00
|
|
|
iSize = LoadStringW(hhctrl_hinstance, dwID, (LPWSTR)&stringresource, 0);
|
2005-08-02 16:55:11 +02:00
|
|
|
|
2008-03-05 21:28:54 +01:00
|
|
|
string = heap_alloc((iSize + 2) * sizeof(WCHAR)); /* some strings (tab text) needs double-null termination */
|
|
|
|
memcpy(string, stringresource, iSize*sizeof(WCHAR));
|
|
|
|
string[iSize] = 0;
|
2005-08-02 16:55:11 +02:00
|
|
|
|
|
|
|
return string;
|
|
|
|
}
|
|
|
|
|
2007-03-02 18:21:02 +01:00
|
|
|
static HRESULT navigate_url(HHInfo *info, LPCWSTR surl)
|
2007-02-28 03:55:39 +01:00
|
|
|
{
|
|
|
|
VARIANT url;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2007-03-02 18:21:02 +01:00
|
|
|
TRACE("%s\n", debugstr_w(surl));
|
|
|
|
|
2007-02-28 03:55:39 +01:00
|
|
|
V_VT(&url) = VT_BSTR;
|
|
|
|
V_BSTR(&url) = SysAllocString(surl);
|
|
|
|
|
|
|
|
hres = IWebBrowser2_Navigate2(info->web_browser, &url, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
VariantClear(&url);
|
|
|
|
|
2007-03-02 18:21:02 +01:00
|
|
|
if(FAILED(hres))
|
2007-03-05 13:48:23 +01:00
|
|
|
TRACE("Navigation failed: %08x\n", hres);
|
2007-03-02 18:21:02 +01:00
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL NavigateToUrl(HHInfo *info, LPCWSTR surl)
|
|
|
|
{
|
|
|
|
ChmPath chm_path;
|
|
|
|
BOOL ret;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2008-04-14 22:17:27 +02:00
|
|
|
static const WCHAR url_indicator[] = {':', '/', '/'};
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_w(surl));
|
|
|
|
|
|
|
|
if (strstrW(surl, url_indicator)) {
|
|
|
|
hres = navigate_url(info, surl);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
return TRUE;
|
|
|
|
} /* look up in chm if it doesn't look like a full url */
|
2007-03-02 18:21:02 +01:00
|
|
|
|
|
|
|
SetChmPath(&chm_path, info->pCHMInfo->szFile, surl);
|
|
|
|
ret = NavigateToChm(info, chm_path.chm_file, chm_path.chm_index);
|
|
|
|
|
2007-12-09 16:29:44 +01:00
|
|
|
heap_free(chm_path.chm_file);
|
|
|
|
heap_free(chm_path.chm_index);
|
2007-03-02 18:21:02 +01:00
|
|
|
|
|
|
|
return ret;
|
2007-02-28 03:55:39 +01:00
|
|
|
}
|
|
|
|
|
2007-02-28 03:49:20 +01:00
|
|
|
BOOL NavigateToChm(HHInfo *info, LPCWSTR file, LPCWSTR index)
|
2007-02-06 20:47:29 +01:00
|
|
|
{
|
|
|
|
WCHAR buf[INTERNET_MAX_URL_LENGTH];
|
|
|
|
WCHAR full_path[MAX_PATH];
|
2007-02-28 03:55:39 +01:00
|
|
|
LPWSTR ptr;
|
2007-02-06 20:47:29 +01:00
|
|
|
|
|
|
|
static const WCHAR url_format[] =
|
2007-03-02 18:21:02 +01:00
|
|
|
{'m','k',':','@','M','S','I','T','S','t','o','r','e',':','%','s',':',':','%','s',0};
|
2007-02-06 20:47:29 +01:00
|
|
|
|
2007-02-28 03:55:39 +01:00
|
|
|
TRACE("%p %s %s\n", info, debugstr_w(file), debugstr_w(index));
|
|
|
|
|
2007-02-28 03:47:13 +01:00
|
|
|
if (!info->web_browser)
|
2007-02-06 20:47:29 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2008-02-14 15:38:44 +01:00
|
|
|
if(!GetFullPathNameW(file, sizeof(full_path)/sizeof(full_path[0]), full_path, NULL)) {
|
2007-02-06 20:47:29 +01:00
|
|
|
WARN("GetFullPathName failed: %u\n", GetLastError());
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
wsprintfW(buf, url_format, full_path, index);
|
|
|
|
|
2007-02-28 03:55:39 +01:00
|
|
|
/* FIXME: HACK */
|
|
|
|
if((ptr = strchrW(buf, '#')))
|
|
|
|
*ptr = 0;
|
2007-02-06 20:47:29 +01:00
|
|
|
|
2007-03-02 18:21:02 +01:00
|
|
|
return SUCCEEDED(navigate_url(info, buf));
|
2007-02-06 20:47:29 +01:00
|
|
|
}
|
|
|
|
|
2005-09-21 13:42:41 +02:00
|
|
|
/* Size Bar */
|
|
|
|
|
|
|
|
#define SIZEBAR_WIDTH 4
|
|
|
|
|
|
|
|
static const WCHAR szSizeBarClass[] = {
|
|
|
|
'H','H',' ','S','i','z','e','B','a','r',0
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Draw the SizeBar */
|
|
|
|
static void SB_OnPaint(HWND hWnd)
|
|
|
|
{
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
HDC hdc;
|
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
hdc = BeginPaint(hWnd, &ps);
|
|
|
|
|
|
|
|
GetClientRect(hWnd, &rc);
|
|
|
|
|
|
|
|
/* dark frame */
|
|
|
|
rc.right += 1;
|
|
|
|
rc.bottom -= 1;
|
|
|
|
FrameRect(hdc, &rc, GetStockObject(GRAY_BRUSH));
|
|
|
|
|
|
|
|
/* white highlight */
|
|
|
|
SelectObject(hdc, GetStockObject(WHITE_PEN));
|
|
|
|
MoveToEx(hdc, rc.right, 1, NULL);
|
|
|
|
LineTo(hdc, 1, 1);
|
|
|
|
LineTo(hdc, 1, rc.bottom - 1);
|
|
|
|
|
|
|
|
|
|
|
|
MoveToEx(hdc, 0, rc.bottom, NULL);
|
|
|
|
LineTo(hdc, rc.right, rc.bottom);
|
|
|
|
|
|
|
|
EndPaint(hWnd, &ps);
|
|
|
|
}
|
|
|
|
|
2005-09-28 12:16:02 +02:00
|
|
|
static void SB_OnLButtonDown(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
SetCapture(hWnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SB_OnLButtonUp(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
HHInfo *pHHInfo = (HHInfo *)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
|
2006-10-25 17:41:58 +02:00
|
|
|
POINT pt;
|
|
|
|
|
|
|
|
pt.x = (short)LOWORD(lParam);
|
|
|
|
pt.y = (short)HIWORD(lParam);
|
2005-09-28 12:16:02 +02:00
|
|
|
|
|
|
|
/* update the window sizes */
|
2007-02-28 03:46:15 +01:00
|
|
|
pHHInfo->WinType.iNavWidth += pt.x;
|
2005-09-28 12:16:02 +02:00
|
|
|
Help_OnSize(hWnd);
|
|
|
|
|
|
|
|
ReleaseCapture();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SB_OnMouseMove(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
/* ignore WM_MOUSEMOVE if not dragging the SizeBar */
|
|
|
|
if (!(wParam & MK_LBUTTON))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-08-02 22:02:25 +02:00
|
|
|
static LRESULT CALLBACK SizeBar_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
2005-09-21 13:42:41 +02:00
|
|
|
{
|
|
|
|
switch (message)
|
|
|
|
{
|
2005-09-28 12:16:02 +02:00
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
SB_OnLButtonDown(hWnd, wParam, lParam);
|
|
|
|
break;
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
SB_OnLButtonUp(hWnd, wParam, lParam);
|
|
|
|
break;
|
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
SB_OnMouseMove(hWnd, wParam, lParam);
|
|
|
|
break;
|
2005-09-21 13:42:41 +02:00
|
|
|
case WM_PAINT:
|
|
|
|
SB_OnPaint(hWnd);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return DefWindowProcW(hWnd, message, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void HH_RegisterSizeBarClass(HHInfo *pHHInfo)
|
|
|
|
{
|
|
|
|
WNDCLASSEXW wcex;
|
|
|
|
|
|
|
|
wcex.cbSize = sizeof(WNDCLASSEXW);
|
|
|
|
wcex.style = 0;
|
2007-02-28 03:50:14 +01:00
|
|
|
wcex.lpfnWndProc = SizeBar_WndProc;
|
2005-09-21 13:42:41 +02:00
|
|
|
wcex.cbClsExtra = 0;
|
|
|
|
wcex.cbWndExtra = 0;
|
2007-02-22 22:57:40 +01:00
|
|
|
wcex.hInstance = hhctrl_hinstance;
|
2005-09-21 13:42:41 +02:00
|
|
|
wcex.hIcon = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION);
|
|
|
|
wcex.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_SIZEWE);
|
|
|
|
wcex.hbrBackground = (HBRUSH)(COLOR_MENU + 1);
|
|
|
|
wcex.lpszMenuName = NULL;
|
|
|
|
wcex.lpszClassName = szSizeBarClass;
|
|
|
|
wcex.hIconSm = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION);
|
|
|
|
|
|
|
|
RegisterClassExW(&wcex);
|
|
|
|
}
|
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
static void SB_GetSizeBarRect(HHInfo *info, RECT *rc)
|
2005-09-21 13:42:41 +02:00
|
|
|
{
|
|
|
|
RECT rectWND, rectTB, rectNP;
|
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
GetClientRect(info->WinType.hwndHelp, &rectWND);
|
|
|
|
GetClientRect(info->WinType.hwndToolBar, &rectTB);
|
|
|
|
GetClientRect(info->WinType.hwndNavigation, &rectNP);
|
2005-09-21 13:42:41 +02:00
|
|
|
|
|
|
|
rc->left = rectNP.right;
|
|
|
|
rc->top = rectTB.bottom;
|
|
|
|
rc->bottom = rectWND.bottom - rectTB.bottom;
|
|
|
|
rc->right = SIZEBAR_WIDTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL HH_AddSizeBar(HHInfo *pHHInfo)
|
|
|
|
{
|
|
|
|
HWND hWnd;
|
2007-02-28 03:46:15 +01:00
|
|
|
HWND hwndParent = pHHInfo->WinType.hwndHelp;
|
2005-09-21 13:42:41 +02:00
|
|
|
DWORD dwStyles = WS_CHILDWINDOW | WS_VISIBLE | WS_OVERLAPPED;
|
|
|
|
DWORD dwExStyles = WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR;
|
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
SB_GetSizeBarRect(pHHInfo, &rc);
|
|
|
|
|
|
|
|
hWnd = CreateWindowExW(dwExStyles, szSizeBarClass, szEmpty, dwStyles,
|
|
|
|
rc.left, rc.top, rc.right, rc.bottom,
|
2007-02-22 22:57:40 +01:00
|
|
|
hwndParent, NULL, hhctrl_hinstance, NULL);
|
2005-09-21 13:42:41 +02:00
|
|
|
if (!hWnd)
|
|
|
|
return FALSE;
|
|
|
|
|
2005-09-28 12:16:02 +02:00
|
|
|
/* store the pointer to the HH info struct */
|
|
|
|
SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)pHHInfo);
|
|
|
|
|
2005-09-21 13:42:41 +02:00
|
|
|
pHHInfo->hwndSizeBar = hWnd;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-08-03 12:56:55 +02:00
|
|
|
/* Child Window */
|
|
|
|
|
|
|
|
static const WCHAR szChildClass[] = {
|
|
|
|
'H','H',' ','C','h','i','l','d',0
|
|
|
|
};
|
|
|
|
|
2007-02-28 03:56:33 +01:00
|
|
|
static LRESULT Child_OnPaint(HWND hWnd)
|
2005-08-15 11:40:24 +02:00
|
|
|
{
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
HDC hdc;
|
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
hdc = BeginPaint(hWnd, &ps);
|
|
|
|
|
|
|
|
/* Only paint the Navigation pane, identified by the fact
|
|
|
|
* that it has a child window
|
|
|
|
*/
|
|
|
|
if (GetWindow(hWnd, GW_CHILD))
|
|
|
|
{
|
|
|
|
GetClientRect(hWnd, &rc);
|
|
|
|
|
|
|
|
/* set the border color */
|
|
|
|
SelectObject(hdc, GetStockObject(DC_PEN));
|
|
|
|
SetDCPenColor(hdc, GetSysColor(COLOR_BTNSHADOW));
|
|
|
|
|
2005-09-20 14:00:46 +02:00
|
|
|
/* Draw the top border */
|
|
|
|
LineTo(hdc, rc.right, 0);
|
2005-08-15 11:40:24 +02:00
|
|
|
|
2005-09-20 14:00:46 +02:00
|
|
|
SelectObject(hdc, GetStockObject(WHITE_PEN));
|
|
|
|
MoveToEx(hdc, 0, 1, NULL);
|
|
|
|
LineTo(hdc, rc.right, 1);
|
2005-08-15 11:40:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
EndPaint(hWnd, &ps);
|
2007-02-28 03:56:33 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-02-28 03:57:12 +01:00
|
|
|
static void ResizeTabChild(HHInfo *info, HWND hwnd)
|
|
|
|
{
|
|
|
|
RECT rect, tabrc;
|
|
|
|
DWORD cnt;
|
|
|
|
|
|
|
|
GetClientRect(info->WinType.hwndNavigation, &rect);
|
|
|
|
SendMessageW(info->hwndTabCtrl, TCM_GETITEMRECT, 0, (LPARAM)&tabrc);
|
|
|
|
cnt = SendMessageW(info->hwndTabCtrl, TCM_GETROWCOUNT, 0, 0);
|
|
|
|
|
|
|
|
rect.left = TAB_MARGIN;
|
|
|
|
rect.top = TAB_TOP_PADDING + cnt*(tabrc.bottom-tabrc.top) + TAB_MARGIN;
|
|
|
|
rect.right -= TAB_RIGHT_PADDING + TAB_MARGIN;
|
|
|
|
rect.bottom -= TAB_MARGIN;
|
|
|
|
|
|
|
|
SetWindowPos(hwnd, NULL, rect.left, rect.top, rect.right-rect.left,
|
|
|
|
rect.bottom-rect.top, SWP_NOZORDER | SWP_NOACTIVATE);
|
|
|
|
}
|
|
|
|
|
2007-02-28 03:56:33 +01:00
|
|
|
static LRESULT Child_OnSize(HWND hwnd)
|
|
|
|
{
|
|
|
|
HHInfo *info = (HHInfo*)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
|
|
|
|
RECT rect;
|
|
|
|
|
|
|
|
if(!info || hwnd != info->WinType.hwndNavigation)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
GetClientRect(hwnd, &rect);
|
|
|
|
SetWindowPos(info->hwndTabCtrl, HWND_TOP, 0, 0,
|
|
|
|
rect.right - TAB_RIGHT_PADDING,
|
|
|
|
rect.bottom - TAB_TOP_PADDING, SWP_NOMOVE);
|
2007-02-28 03:57:12 +01:00
|
|
|
|
|
|
|
ResizeTabChild(info, info->tabs[TAB_CONTENTS].hwnd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT OnTabChange(HWND hwnd)
|
|
|
|
{
|
|
|
|
HHInfo *info = (HHInfo*)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
|
|
|
|
|
|
|
|
TRACE("%p\n", hwnd);
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if(info->tabs[info->current_tab].hwnd)
|
|
|
|
ShowWindow(info->tabs[info->current_tab].hwnd, SW_HIDE);
|
|
|
|
|
|
|
|
info->current_tab = SendMessageW(info->hwndTabCtrl, TCM_GETCURSEL, 0, 0);
|
|
|
|
|
|
|
|
if(info->tabs[info->current_tab].hwnd)
|
|
|
|
ShowWindow(info->tabs[info->current_tab].hwnd, SW_SHOW);
|
|
|
|
|
2007-02-28 03:56:33 +01:00
|
|
|
return 0;
|
2005-08-15 11:40:24 +02:00
|
|
|
}
|
|
|
|
|
2007-02-28 04:00:35 +01:00
|
|
|
static LRESULT OnTopicChange(HWND hwnd, ContentItem *item)
|
|
|
|
{
|
|
|
|
HHInfo *info = (HHInfo*)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
|
|
|
|
LPCWSTR chmfile = NULL;
|
|
|
|
ContentItem *iter = item;
|
|
|
|
|
|
|
|
if(!item || !info)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
TRACE("name %s loal %s\n", debugstr_w(item->name), debugstr_w(item->local));
|
|
|
|
|
|
|
|
while(iter) {
|
|
|
|
if(iter->merge.chm_file) {
|
|
|
|
chmfile = iter->merge.chm_file;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
iter = iter->parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
NavigateToChm(info, chmfile, item->local);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-08-02 22:02:25 +02:00
|
|
|
static LRESULT CALLBACK Child_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
2005-08-03 12:56:55 +02:00
|
|
|
{
|
|
|
|
switch (message)
|
|
|
|
{
|
2007-02-28 03:56:33 +01:00
|
|
|
case WM_PAINT:
|
|
|
|
return Child_OnPaint(hWnd);
|
|
|
|
case WM_SIZE:
|
|
|
|
return Child_OnSize(hWnd);
|
2007-02-28 03:57:12 +01:00
|
|
|
case WM_NOTIFY: {
|
|
|
|
NMHDR *nmhdr = (NMHDR*)lParam;
|
|
|
|
switch(nmhdr->code) {
|
|
|
|
case TCN_SELCHANGE:
|
|
|
|
return OnTabChange(hWnd);
|
2007-02-28 04:00:35 +01:00
|
|
|
case TVN_SELCHANGEDW:
|
|
|
|
return OnTopicChange(hWnd, (ContentItem*)((NMTREEVIEWW *)lParam)->itemNew.lParam);
|
2007-02-28 03:57:12 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2007-02-28 03:56:33 +01:00
|
|
|
default:
|
|
|
|
return DefWindowProcW(hWnd, message, wParam, lParam);
|
2005-08-03 12:56:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void HH_RegisterChildWndClass(HHInfo *pHHInfo)
|
|
|
|
{
|
|
|
|
WNDCLASSEXW wcex;
|
|
|
|
|
|
|
|
wcex.cbSize = sizeof(WNDCLASSEXW);
|
|
|
|
wcex.style = 0;
|
2007-02-28 03:50:14 +01:00
|
|
|
wcex.lpfnWndProc = Child_WndProc;
|
2005-08-03 12:56:55 +02:00
|
|
|
wcex.cbClsExtra = 0;
|
|
|
|
wcex.cbWndExtra = 0;
|
2007-02-22 22:57:40 +01:00
|
|
|
wcex.hInstance = hhctrl_hinstance;
|
2005-08-03 12:56:55 +02:00
|
|
|
wcex.hIcon = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION);
|
|
|
|
wcex.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW);
|
2005-09-20 14:00:46 +02:00
|
|
|
wcex.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
2005-08-03 12:56:55 +02:00
|
|
|
wcex.lpszMenuName = NULL;
|
|
|
|
wcex.lpszClassName = szChildClass;
|
|
|
|
wcex.hIconSm = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION);
|
|
|
|
|
|
|
|
RegisterClassExW(&wcex);
|
|
|
|
}
|
|
|
|
|
2005-08-01 11:21:53 +02:00
|
|
|
/* Toolbar */
|
|
|
|
|
2005-08-02 16:55:11 +02:00
|
|
|
#define ICON_SIZE 20
|
|
|
|
|
2005-09-19 17:25:18 +02:00
|
|
|
static void TB_OnClick(HWND hWnd, DWORD dwID)
|
|
|
|
{
|
2007-02-28 03:47:13 +01:00
|
|
|
HHInfo *info = (HHInfo *)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
|
2005-09-19 17:25:18 +02:00
|
|
|
|
|
|
|
switch (dwID)
|
|
|
|
{
|
|
|
|
case IDTB_STOP:
|
2007-02-28 03:47:13 +01:00
|
|
|
DoPageAction(info, WB_STOP);
|
2005-09-19 17:25:18 +02:00
|
|
|
break;
|
|
|
|
case IDTB_REFRESH:
|
2007-02-28 03:47:13 +01:00
|
|
|
DoPageAction(info, WB_REFRESH);
|
2005-09-19 17:25:18 +02:00
|
|
|
break;
|
|
|
|
case IDTB_BACK:
|
2007-02-28 03:47:13 +01:00
|
|
|
DoPageAction(info, WB_GOBACK);
|
2005-09-19 17:25:18 +02:00
|
|
|
break;
|
|
|
|
case IDTB_HOME:
|
2007-02-28 03:47:13 +01:00
|
|
|
NavigateToChm(info, info->pCHMInfo->szFile, info->WinType.pszHome);
|
2005-09-19 17:25:18 +02:00
|
|
|
break;
|
|
|
|
case IDTB_FORWARD:
|
2007-02-28 03:47:13 +01:00
|
|
|
DoPageAction(info, WB_GOFORWARD);
|
2005-09-19 17:25:18 +02:00
|
|
|
break;
|
|
|
|
case IDTB_EXPAND:
|
|
|
|
case IDTB_CONTRACT:
|
|
|
|
case IDTB_SYNC:
|
|
|
|
case IDTB_PRINT:
|
|
|
|
case IDTB_OPTIONS:
|
|
|
|
case IDTB_BROWSE_FWD:
|
|
|
|
case IDTB_BROWSE_BACK:
|
|
|
|
case IDTB_JUMP1:
|
|
|
|
case IDTB_JUMP2:
|
|
|
|
case IDTB_CUSTOMIZE:
|
|
|
|
case IDTB_ZOOM:
|
|
|
|
case IDTB_TOC_NEXT:
|
|
|
|
case IDTB_TOC_PREV:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-02 16:55:11 +02:00
|
|
|
static void TB_AddButton(TBBUTTON *pButtons, DWORD dwIndex, DWORD dwID)
|
|
|
|
{
|
|
|
|
/* FIXME: Load the correct button bitmaps */
|
|
|
|
pButtons[dwIndex].iBitmap = STD_PRINT;
|
|
|
|
pButtons[dwIndex].idCommand = dwID;
|
|
|
|
pButtons[dwIndex].fsState = TBSTATE_ENABLED;
|
|
|
|
pButtons[dwIndex].fsStyle = BTNS_BUTTON;
|
|
|
|
pButtons[dwIndex].dwData = 0;
|
|
|
|
pButtons[dwIndex].iString = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void TB_AddButtonsFromFlags(TBBUTTON *pButtons, DWORD dwButtonFlags, LPDWORD pdwNumButtons)
|
|
|
|
{
|
|
|
|
*pdwNumButtons = 0;
|
|
|
|
|
|
|
|
if (dwButtonFlags & HHWIN_BUTTON_EXPAND)
|
|
|
|
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_EXPAND);
|
|
|
|
|
|
|
|
if (dwButtonFlags & HHWIN_BUTTON_BACK)
|
|
|
|
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_BACK);
|
|
|
|
|
|
|
|
if (dwButtonFlags & HHWIN_BUTTON_FORWARD)
|
|
|
|
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_FORWARD);
|
|
|
|
|
|
|
|
if (dwButtonFlags & HHWIN_BUTTON_STOP)
|
|
|
|
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_STOP);
|
|
|
|
|
|
|
|
if (dwButtonFlags & HHWIN_BUTTON_REFRESH)
|
|
|
|
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_REFRESH);
|
|
|
|
|
|
|
|
if (dwButtonFlags & HHWIN_BUTTON_HOME)
|
|
|
|
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_HOME);
|
|
|
|
|
|
|
|
if (dwButtonFlags & HHWIN_BUTTON_SYNC)
|
|
|
|
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_SYNC);
|
|
|
|
|
|
|
|
if (dwButtonFlags & HHWIN_BUTTON_OPTIONS)
|
|
|
|
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_OPTIONS);
|
|
|
|
|
|
|
|
if (dwButtonFlags & HHWIN_BUTTON_PRINT)
|
|
|
|
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_PRINT);
|
|
|
|
|
|
|
|
if (dwButtonFlags & HHWIN_BUTTON_JUMP1)
|
|
|
|
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_JUMP1);
|
|
|
|
|
|
|
|
if (dwButtonFlags & HHWIN_BUTTON_JUMP2)
|
|
|
|
TB_AddButton(pButtons,(*pdwNumButtons)++, IDTB_JUMP2);
|
|
|
|
|
|
|
|
if (dwButtonFlags & HHWIN_BUTTON_ZOOM)
|
|
|
|
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_ZOOM);
|
|
|
|
|
|
|
|
if (dwButtonFlags & HHWIN_BUTTON_TOC_NEXT)
|
|
|
|
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_TOC_NEXT);
|
|
|
|
|
|
|
|
if (dwButtonFlags & HHWIN_BUTTON_TOC_PREV)
|
|
|
|
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_TOC_PREV);
|
|
|
|
}
|
|
|
|
|
2005-08-01 11:21:53 +02:00
|
|
|
static BOOL HH_AddToolbar(HHInfo *pHHInfo)
|
|
|
|
{
|
2005-08-02 16:55:11 +02:00
|
|
|
HWND hToolbar;
|
2007-02-28 03:46:15 +01:00
|
|
|
HWND hwndParent = pHHInfo->WinType.hwndHelp;
|
2005-09-06 11:20:42 +02:00
|
|
|
DWORD toolbarFlags;
|
2005-08-02 16:55:11 +02:00
|
|
|
TBBUTTON buttons[IDTB_TOC_PREV - IDTB_EXPAND];
|
|
|
|
TBADDBITMAP tbAB;
|
|
|
|
DWORD dwStyles, dwExStyles;
|
|
|
|
DWORD dwNumButtons, dwIndex;
|
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
if (pHHInfo->WinType.fsWinProperties & HHWIN_PARAM_TB_FLAGS)
|
|
|
|
toolbarFlags = pHHInfo->WinType.fsToolBarFlags;
|
2005-09-06 11:20:42 +02:00
|
|
|
else
|
|
|
|
toolbarFlags = HHWIN_DEF_BUTTONS;
|
|
|
|
|
2005-08-02 16:55:11 +02:00
|
|
|
TB_AddButtonsFromFlags(buttons, toolbarFlags, &dwNumButtons);
|
|
|
|
|
|
|
|
dwStyles = WS_CHILDWINDOW | WS_VISIBLE | TBSTYLE_FLAT |
|
|
|
|
TBSTYLE_WRAPABLE | TBSTYLE_TOOLTIPS | CCS_NODIVIDER;
|
|
|
|
dwExStyles = WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR;
|
|
|
|
|
|
|
|
hToolbar = CreateWindowExW(dwExStyles, TOOLBARCLASSNAMEW, NULL, dwStyles,
|
|
|
|
0, 0, 0, 0, hwndParent, NULL,
|
2007-02-22 22:57:40 +01:00
|
|
|
hhctrl_hinstance, NULL);
|
2005-08-02 16:55:11 +02:00
|
|
|
if (!hToolbar)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
SendMessageW(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(ICON_SIZE, ICON_SIZE));
|
|
|
|
SendMessageW(hToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
|
|
|
|
SendMessageW(hToolbar, WM_SETFONT, (WPARAM)pHHInfo->hFont, TRUE);
|
|
|
|
|
|
|
|
/* FIXME: Load correct icons for all buttons */
|
|
|
|
tbAB.hInst = HINST_COMMCTRL;
|
|
|
|
tbAB.nID = IDB_STD_LARGE_COLOR;
|
|
|
|
SendMessageW(hToolbar, TB_ADDBITMAP, 0, (LPARAM)&tbAB);
|
|
|
|
|
|
|
|
for (dwIndex = 0; dwIndex < dwNumButtons; dwIndex++)
|
|
|
|
{
|
|
|
|
LPWSTR szBuf = HH_LoadString(buttons[dwIndex].idCommand);
|
|
|
|
DWORD dwLen = strlenW(szBuf);
|
2008-04-09 10:03:58 +02:00
|
|
|
szBuf[dwLen + 1] = 0; /* Double-null terminate */
|
2005-08-02 16:55:11 +02:00
|
|
|
|
|
|
|
buttons[dwIndex].iString = (DWORD)SendMessageW(hToolbar, TB_ADDSTRINGW, 0, (LPARAM)szBuf);
|
2007-12-09 16:29:44 +01:00
|
|
|
heap_free(szBuf);
|
2005-08-02 16:55:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SendMessageW(hToolbar, TB_ADDBUTTONSW, dwNumButtons, (LPARAM)&buttons);
|
|
|
|
SendMessageW(hToolbar, TB_AUTOSIZE, 0, 0);
|
|
|
|
ShowWindow(hToolbar, SW_SHOW);
|
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
pHHInfo->WinType.hwndToolBar = hToolbar;
|
2005-08-01 11:21:53 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Navigation Pane */
|
|
|
|
|
2005-08-03 12:56:55 +02:00
|
|
|
static void NP_GetNavigationRect(HHInfo *pHHInfo, RECT *rc)
|
|
|
|
{
|
2007-02-28 03:46:15 +01:00
|
|
|
HWND hwndParent = pHHInfo->WinType.hwndHelp;
|
|
|
|
HWND hwndToolbar = pHHInfo->WinType.hwndToolBar;
|
2005-08-03 12:56:55 +02:00
|
|
|
RECT rectWND, rectTB;
|
|
|
|
|
|
|
|
GetClientRect(hwndParent, &rectWND);
|
|
|
|
GetClientRect(hwndToolbar, &rectTB);
|
|
|
|
|
|
|
|
rc->left = 0;
|
|
|
|
rc->top = rectTB.bottom;
|
|
|
|
rc->bottom = rectWND.bottom - rectTB.bottom;
|
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
if (!(pHHInfo->WinType.fsValidMembers & HHWIN_PARAM_NAV_WIDTH) &&
|
|
|
|
pHHInfo->WinType.iNavWidth == 0)
|
2005-09-28 12:16:02 +02:00
|
|
|
{
|
2007-02-28 03:46:15 +01:00
|
|
|
pHHInfo->WinType.iNavWidth = WINTYPE_DEFAULT_NAVWIDTH;
|
2005-09-28 12:16:02 +02:00
|
|
|
}
|
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
rc->right = pHHInfo->WinType.iNavWidth;
|
2005-08-03 12:56:55 +02:00
|
|
|
}
|
|
|
|
|
2007-02-28 03:57:12 +01:00
|
|
|
static DWORD NP_CreateTab(HINSTANCE hInstance, HWND hwndTabCtrl, DWORD index)
|
2005-08-03 13:46:52 +02:00
|
|
|
{
|
|
|
|
TCITEMW tie;
|
2007-02-28 03:57:12 +01:00
|
|
|
LPWSTR tabText = HH_LoadString(index);
|
|
|
|
DWORD ret;
|
2005-08-03 13:46:52 +02:00
|
|
|
|
|
|
|
tie.mask = TCIF_TEXT;
|
|
|
|
tie.pszText = tabText;
|
|
|
|
|
2007-02-28 03:57:12 +01:00
|
|
|
ret = SendMessageW( hwndTabCtrl, TCM_INSERTITEMW, index, (LPARAM)&tie );
|
|
|
|
|
2007-12-09 16:29:44 +01:00
|
|
|
heap_free(tabText);
|
2007-02-28 03:57:12 +01:00
|
|
|
return ret;
|
2005-08-03 13:46:52 +02:00
|
|
|
}
|
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
static BOOL HH_AddNavigationPane(HHInfo *info)
|
2005-08-01 11:21:53 +02:00
|
|
|
{
|
2005-08-03 13:46:52 +02:00
|
|
|
HWND hWnd, hwndTabCtrl;
|
2007-02-28 03:46:15 +01:00
|
|
|
HWND hwndParent = info->WinType.hwndHelp;
|
2005-08-03 12:56:55 +02:00
|
|
|
DWORD dwStyles = WS_CHILDWINDOW | WS_VISIBLE;
|
|
|
|
DWORD dwExStyles = WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR;
|
|
|
|
RECT rc;
|
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
NP_GetNavigationRect(info, &rc);
|
2005-08-03 12:56:55 +02:00
|
|
|
|
|
|
|
hWnd = CreateWindowExW(dwExStyles, szChildClass, szEmpty, dwStyles,
|
|
|
|
rc.left, rc.top, rc.right, rc.bottom,
|
2007-02-22 22:57:40 +01:00
|
|
|
hwndParent, NULL, hhctrl_hinstance, NULL);
|
2005-08-03 12:56:55 +02:00
|
|
|
if (!hWnd)
|
|
|
|
return FALSE;
|
|
|
|
|
2007-02-28 03:56:33 +01:00
|
|
|
SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)info);
|
|
|
|
|
2005-08-03 13:46:52 +02:00
|
|
|
hwndTabCtrl = CreateWindowExW(dwExStyles, WC_TABCONTROLW, szEmpty, dwStyles,
|
2005-09-20 14:00:46 +02:00
|
|
|
0, TAB_TOP_PADDING,
|
|
|
|
rc.right - TAB_RIGHT_PADDING,
|
|
|
|
rc.bottom - TAB_TOP_PADDING,
|
2007-02-22 22:57:40 +01:00
|
|
|
hWnd, NULL, hhctrl_hinstance, NULL);
|
2005-08-03 13:46:52 +02:00
|
|
|
if (!hwndTabCtrl)
|
|
|
|
return FALSE;
|
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
if (*info->WinType.pszToc)
|
2007-02-28 03:57:12 +01:00
|
|
|
info->tabs[TAB_CONTENTS].id = NP_CreateTab(hhctrl_hinstance, hwndTabCtrl, IDS_CONTENTS);
|
2005-09-06 11:20:42 +02:00
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
if (*info->WinType.pszIndex)
|
2007-02-28 03:57:12 +01:00
|
|
|
info->tabs[TAB_INDEX].id = NP_CreateTab(hhctrl_hinstance, hwndTabCtrl, IDS_INDEX);
|
2005-09-06 11:20:42 +02:00
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
if (info->WinType.fsWinProperties & HHWIN_PROP_TAB_SEARCH)
|
2007-02-28 03:57:12 +01:00
|
|
|
info->tabs[TAB_SEARCH].id = NP_CreateTab(hhctrl_hinstance, hwndTabCtrl, IDS_SEARCH);
|
2005-09-06 11:20:42 +02:00
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
if (info->WinType.fsWinProperties & HHWIN_PROP_TAB_FAVORITES)
|
2007-02-28 03:57:12 +01:00
|
|
|
info->tabs[TAB_FAVORITES].id = NP_CreateTab(hhctrl_hinstance, hwndTabCtrl, IDS_FAVORITES);
|
2005-08-03 13:46:52 +02:00
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
SendMessageW(hwndTabCtrl, WM_SETFONT, (WPARAM)info->hFont, TRUE);
|
2005-08-03 13:46:52 +02:00
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
info->hwndTabCtrl = hwndTabCtrl;
|
|
|
|
info->WinType.hwndNavigation = hWnd;
|
2005-08-01 11:21:53 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* HTML Pane */
|
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
static void HP_GetHTMLRect(HHInfo *info, RECT *rc)
|
2005-08-03 12:56:55 +02:00
|
|
|
{
|
2005-09-21 13:42:41 +02:00
|
|
|
RECT rectTB, rectWND, rectNP, rectSB;
|
2005-08-03 12:56:55 +02:00
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
GetClientRect(info->WinType.hwndHelp, &rectWND);
|
|
|
|
GetClientRect(info->WinType.hwndToolBar, &rectTB);
|
|
|
|
GetClientRect(info->WinType.hwndNavigation, &rectNP);
|
|
|
|
GetClientRect(info->hwndSizeBar, &rectSB);
|
2005-08-03 12:56:55 +02:00
|
|
|
|
2005-09-21 13:42:41 +02:00
|
|
|
rc->left = rectNP.right + rectSB.right;
|
2005-08-03 12:56:55 +02:00
|
|
|
rc->top = rectTB.bottom;
|
2005-09-21 13:42:41 +02:00
|
|
|
rc->right = rectWND.right - rc->left;
|
2005-08-03 12:56:55 +02:00
|
|
|
rc->bottom = rectWND.bottom - rectTB.bottom;
|
|
|
|
}
|
|
|
|
|
2005-08-01 11:21:53 +02:00
|
|
|
static BOOL HH_AddHTMLPane(HHInfo *pHHInfo)
|
|
|
|
{
|
2005-08-03 12:56:55 +02:00
|
|
|
HWND hWnd;
|
2007-02-28 03:46:15 +01:00
|
|
|
HWND hwndParent = pHHInfo->WinType.hwndHelp;
|
2005-08-03 12:56:55 +02:00
|
|
|
DWORD dwStyles = WS_CHILDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN;
|
|
|
|
DWORD dwExStyles = WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | WS_EX_CLIENTEDGE;
|
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
HP_GetHTMLRect(pHHInfo, &rc);
|
|
|
|
|
|
|
|
hWnd = CreateWindowExW(dwExStyles, szChildClass, szEmpty, dwStyles,
|
|
|
|
rc.left, rc.top, rc.right, rc.bottom,
|
2007-02-22 22:57:40 +01:00
|
|
|
hwndParent, NULL, hhctrl_hinstance, NULL);
|
2005-08-03 12:56:55 +02:00
|
|
|
if (!hWnd)
|
|
|
|
return FALSE;
|
|
|
|
|
2007-02-28 03:47:13 +01:00
|
|
|
if (!InitWebBrowser(pHHInfo, hWnd))
|
2005-09-13 12:32:47 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2005-08-03 12:56:55 +02:00
|
|
|
/* store the pointer to the HH info struct */
|
2005-08-08 13:01:31 +02:00
|
|
|
SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)pHHInfo);
|
2005-08-03 12:56:55 +02:00
|
|
|
|
|
|
|
ShowWindow(hWnd, SW_SHOW);
|
|
|
|
UpdateWindow(hWnd);
|
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
pHHInfo->WinType.hwndHTML = hWnd;
|
2005-08-01 11:21:53 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-02-28 03:58:18 +01:00
|
|
|
static BOOL AddContentTab(HHInfo *info)
|
|
|
|
{
|
|
|
|
info->tabs[TAB_CONTENTS].hwnd = CreateWindowExW(WS_EX_CLIENTEDGE, WC_TREEVIEWW,
|
|
|
|
szEmpty, WS_CHILD | WS_BORDER | 0x25, 50, 50, 100, 100,
|
|
|
|
info->WinType.hwndNavigation, NULL, hhctrl_hinstance, NULL);
|
|
|
|
if(!info->tabs[TAB_CONTENTS].hwnd) {
|
|
|
|
ERR("Could not create treeview control\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ResizeTabChild(info, info->tabs[TAB_CONTENTS].hwnd);
|
|
|
|
ShowWindow(info->tabs[TAB_CONTENTS].hwnd, SW_SHOW);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-08-01 11:21:53 +02:00
|
|
|
/* Viewer Window */
|
|
|
|
|
2007-02-28 03:51:59 +01:00
|
|
|
static LRESULT Help_OnSize(HWND hWnd)
|
2005-08-15 12:21:56 +02:00
|
|
|
{
|
|
|
|
HHInfo *pHHInfo = (HHInfo *)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
|
2005-09-25 17:17:42 +02:00
|
|
|
DWORD dwSize;
|
2005-08-15 12:21:56 +02:00
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
if (!pHHInfo)
|
2007-02-28 03:51:59 +01:00
|
|
|
return 0;
|
2005-08-15 12:21:56 +02:00
|
|
|
|
2005-09-25 17:17:42 +02:00
|
|
|
NP_GetNavigationRect(pHHInfo, &rc);
|
2007-02-28 03:46:15 +01:00
|
|
|
SetWindowPos(pHHInfo->WinType.hwndNavigation, HWND_TOP, 0, 0,
|
2005-09-25 17:17:42 +02:00
|
|
|
rc.right, rc.bottom, SWP_NOMOVE);
|
|
|
|
|
|
|
|
SB_GetSizeBarRect(pHHInfo, &rc);
|
|
|
|
SetWindowPos(pHHInfo->hwndSizeBar, HWND_TOP, rc.left, rc.top,
|
|
|
|
rc.right, rc.bottom, SWP_SHOWWINDOW);
|
2005-08-15 12:21:56 +02:00
|
|
|
|
|
|
|
HP_GetHTMLRect(pHHInfo, &rc);
|
2007-02-28 03:46:15 +01:00
|
|
|
SetWindowPos(pHHInfo->WinType.hwndHTML, HWND_TOP, rc.left, rc.top,
|
2005-09-25 17:17:42 +02:00
|
|
|
rc.right, rc.bottom, SWP_SHOWWINDOW);
|
|
|
|
|
|
|
|
/* Resize browser window taking the frame size into account */
|
|
|
|
dwSize = GetSystemMetrics(SM_CXFRAME);
|
2007-02-28 03:47:13 +01:00
|
|
|
ResizeWebBrowser(pHHInfo, rc.right - dwSize, rc.bottom - dwSize);
|
2007-02-28 03:51:59 +01:00
|
|
|
|
|
|
|
return 0;
|
2005-08-15 12:21:56 +02:00
|
|
|
}
|
|
|
|
|
2006-08-02 22:02:25 +02:00
|
|
|
static LRESULT CALLBACK Help_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
2005-08-01 11:21:53 +02:00
|
|
|
{
|
|
|
|
switch (message)
|
|
|
|
{
|
2007-02-28 03:51:59 +01:00
|
|
|
case WM_COMMAND:
|
|
|
|
if (HIWORD(wParam) == BN_CLICKED)
|
|
|
|
TB_OnClick(hWnd, LOWORD(wParam));
|
|
|
|
break;
|
|
|
|
case WM_SIZE:
|
|
|
|
return Help_OnSize(hWnd);
|
2007-02-28 03:52:39 +01:00
|
|
|
case WM_CLOSE:
|
|
|
|
ReleaseHelpViewer((HHInfo *)GetWindowLongPtrW(hWnd, GWLP_USERDATA));
|
|
|
|
return 0;
|
2007-02-28 03:51:59 +01:00
|
|
|
case WM_DESTROY:
|
2007-02-28 03:54:25 +01:00
|
|
|
if(hh_process)
|
|
|
|
PostQuitMessage(0);
|
2007-02-28 03:51:59 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return DefWindowProcW(hWnd, message, wParam, lParam);
|
2005-08-01 11:21:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
static BOOL HH_CreateHelpWindow(HHInfo *info)
|
2005-08-01 11:21:53 +02:00
|
|
|
{
|
|
|
|
HWND hWnd;
|
2007-02-28 03:46:15 +01:00
|
|
|
RECT winPos = info->WinType.rcWindowPos;
|
2005-08-01 11:21:53 +02:00
|
|
|
WNDCLASSEXW wcex;
|
|
|
|
DWORD dwStyles, dwExStyles;
|
|
|
|
DWORD x, y, width, height;
|
|
|
|
|
|
|
|
static const WCHAR windowClassW[] = {
|
|
|
|
'H','H',' ', 'P','a','r','e','n','t',0
|
|
|
|
};
|
|
|
|
|
|
|
|
wcex.cbSize = sizeof(WNDCLASSEXW);
|
|
|
|
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
2007-02-28 03:50:14 +01:00
|
|
|
wcex.lpfnWndProc = Help_WndProc;
|
2005-08-01 11:21:53 +02:00
|
|
|
wcex.cbClsExtra = 0;
|
|
|
|
wcex.cbWndExtra = 0;
|
2007-02-22 22:57:40 +01:00
|
|
|
wcex.hInstance = hhctrl_hinstance;
|
2005-08-01 11:21:53 +02:00
|
|
|
wcex.hIcon = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION);
|
|
|
|
wcex.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW);
|
2005-08-15 11:40:24 +02:00
|
|
|
wcex.hbrBackground = (HBRUSH)(COLOR_MENU + 1);
|
2005-08-01 11:21:53 +02:00
|
|
|
wcex.lpszMenuName = NULL;
|
|
|
|
wcex.lpszClassName = windowClassW;
|
|
|
|
wcex.hIconSm = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION);
|
|
|
|
|
|
|
|
RegisterClassExW(&wcex);
|
|
|
|
|
2005-09-06 11:20:42 +02:00
|
|
|
/* Read in window parameters if available */
|
2007-02-28 03:46:15 +01:00
|
|
|
if (info->WinType.fsValidMembers & HHWIN_PARAM_STYLES)
|
|
|
|
dwStyles = info->WinType.dwStyles;
|
2005-09-06 11:20:42 +02:00
|
|
|
else
|
|
|
|
dwStyles = WS_OVERLAPPEDWINDOW | WS_VISIBLE |
|
|
|
|
WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
|
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
if (info->WinType.fsValidMembers & HHWIN_PARAM_EXSTYLES)
|
|
|
|
dwExStyles = info->WinType.dwExStyles;
|
2005-09-06 11:20:42 +02:00
|
|
|
else
|
|
|
|
dwExStyles = WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_APPWINDOW |
|
|
|
|
WS_EX_WINDOWEDGE | WS_EX_RIGHTSCROLLBAR;
|
2005-08-01 11:21:53 +02:00
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
if (info->WinType.fsValidMembers & HHWIN_PARAM_RECT)
|
2005-09-06 11:20:42 +02:00
|
|
|
{
|
|
|
|
x = winPos.left;
|
|
|
|
y = winPos.top;
|
|
|
|
width = winPos.right - x;
|
|
|
|
height = winPos.bottom - y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x = WINTYPE_DEFAULT_X;
|
|
|
|
y = WINTYPE_DEFAULT_Y;
|
|
|
|
width = WINTYPE_DEFAULT_WIDTH;
|
|
|
|
height = WINTYPE_DEFAULT_HEIGHT;
|
|
|
|
}
|
2005-08-01 11:21:53 +02:00
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
hWnd = CreateWindowExW(dwExStyles, windowClassW, info->WinType.pszCaption,
|
2007-02-22 22:57:40 +01:00
|
|
|
dwStyles, x, y, width, height, NULL, NULL, hhctrl_hinstance, NULL);
|
2005-08-01 11:21:53 +02:00
|
|
|
if (!hWnd)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
ShowWindow(hWnd, SW_SHOW);
|
|
|
|
UpdateWindow(hWnd);
|
|
|
|
|
|
|
|
/* store the pointer to the HH info struct */
|
2007-02-28 03:46:15 +01:00
|
|
|
SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)info);
|
2005-08-01 11:21:53 +02:00
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
info->WinType.hwndHelp = hWnd;
|
2005-08-01 11:21:53 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void HH_CreateFont(HHInfo *pHHInfo)
|
|
|
|
{
|
|
|
|
LOGFONTW lf;
|
|
|
|
|
|
|
|
GetObjectW(GetStockObject(ANSI_VAR_FONT), sizeof(LOGFONTW), &lf);
|
|
|
|
lf.lfWeight = FW_NORMAL;
|
|
|
|
lf.lfItalic = FALSE;
|
|
|
|
lf.lfUnderline = FALSE;
|
|
|
|
|
|
|
|
pHHInfo->hFont = CreateFontIndirectW(&lf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void HH_InitRequiredControls(DWORD dwControls)
|
|
|
|
{
|
|
|
|
INITCOMMONCONTROLSEX icex;
|
|
|
|
|
|
|
|
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
|
|
|
icex.dwICC = dwControls;
|
|
|
|
InitCommonControlsEx(&icex);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Creates the whole package */
|
2007-02-28 03:48:45 +01:00
|
|
|
static BOOL CreateViewer(HHInfo *pHHInfo)
|
2005-08-01 11:21:53 +02:00
|
|
|
{
|
|
|
|
HH_CreateFont(pHHInfo);
|
|
|
|
|
|
|
|
if (!HH_CreateHelpWindow(pHHInfo))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
HH_InitRequiredControls(ICC_BAR_CLASSES);
|
|
|
|
|
|
|
|
if (!HH_AddToolbar(pHHInfo))
|
|
|
|
return FALSE;
|
|
|
|
|
2005-08-03 12:56:55 +02:00
|
|
|
HH_RegisterChildWndClass(pHHInfo);
|
|
|
|
|
2005-08-01 11:21:53 +02:00
|
|
|
if (!HH_AddNavigationPane(pHHInfo))
|
|
|
|
return FALSE;
|
|
|
|
|
2005-09-21 13:42:41 +02:00
|
|
|
HH_RegisterSizeBarClass(pHHInfo);
|
|
|
|
|
|
|
|
if (!HH_AddSizeBar(pHHInfo))
|
|
|
|
return FALSE;
|
|
|
|
|
2005-08-01 11:21:53 +02:00
|
|
|
if (!HH_AddHTMLPane(pHHInfo))
|
|
|
|
return FALSE;
|
|
|
|
|
2007-02-28 03:58:18 +01:00
|
|
|
if (!AddContentTab(pHHInfo))
|
|
|
|
return FALSE;
|
|
|
|
|
2007-02-28 03:59:07 +01:00
|
|
|
InitContent(pHHInfo);
|
|
|
|
|
2005-08-01 11:21:53 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-02-28 03:49:20 +01:00
|
|
|
void ReleaseHelpViewer(HHInfo *info)
|
2005-08-01 11:21:53 +02:00
|
|
|
{
|
2007-03-02 18:21:02 +01:00
|
|
|
TRACE("(%p)\n", info);
|
|
|
|
|
2007-02-28 03:46:15 +01:00
|
|
|
if (!info)
|
2005-08-01 11:21:53 +02:00
|
|
|
return;
|
|
|
|
|
2005-09-06 11:20:42 +02:00
|
|
|
/* Free allocated strings */
|
2007-12-13 13:48:00 +01:00
|
|
|
heap_free(info->pszType);
|
|
|
|
heap_free(info->pszCaption);
|
|
|
|
heap_free(info->pszToc);
|
|
|
|
heap_free(info->pszIndex);
|
|
|
|
heap_free(info->pszFile);
|
|
|
|
heap_free(info->pszHome);
|
|
|
|
heap_free(info->pszJump1);
|
|
|
|
heap_free(info->pszJump2);
|
|
|
|
heap_free(info->pszUrlJump1);
|
|
|
|
heap_free(info->pszUrlJump2);
|
2007-02-28 03:46:15 +01:00
|
|
|
|
|
|
|
if (info->pCHMInfo)
|
|
|
|
CloseCHM(info->pCHMInfo);
|
|
|
|
|
2007-02-28 03:47:13 +01:00
|
|
|
ReleaseWebBrowser(info);
|
2007-02-28 03:59:07 +01:00
|
|
|
ReleaseContent(info);
|
2007-02-28 03:48:45 +01:00
|
|
|
|
2007-02-28 03:52:39 +01:00
|
|
|
if(info->WinType.hwndHelp)
|
|
|
|
DestroyWindow(info->WinType.hwndHelp);
|
|
|
|
|
2007-12-09 16:29:44 +01:00
|
|
|
heap_free(info);
|
2007-02-28 03:48:45 +01:00
|
|
|
OleUninitialize();
|
2005-09-13 12:32:47 +02:00
|
|
|
}
|
|
|
|
|
2007-02-28 03:49:20 +01:00
|
|
|
HHInfo *CreateHelpViewer(LPCWSTR filename)
|
2005-09-06 11:20:42 +02:00
|
|
|
{
|
2007-12-09 16:29:44 +01:00
|
|
|
HHInfo *info = heap_alloc_zero(sizeof(HHInfo));
|
2007-02-28 03:48:45 +01:00
|
|
|
|
|
|
|
OleInitialize(NULL);
|
|
|
|
|
|
|
|
info->pCHMInfo = OpenCHM(filename);
|
|
|
|
if(!info->pCHMInfo) {
|
|
|
|
ReleaseHelpViewer(info);
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-09-06 11:20:42 +02:00
|
|
|
|
2007-12-13 13:48:00 +01:00
|
|
|
if (!LoadWinTypeFromCHM(info)) {
|
2007-02-28 03:48:45 +01:00
|
|
|
ReleaseHelpViewer(info);
|
2007-02-23 03:30:38 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-02-28 03:48:45 +01:00
|
|
|
if(!CreateViewer(info)) {
|
|
|
|
ReleaseHelpViewer(info);
|
2007-02-23 03:30:02 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-02-28 03:48:45 +01:00
|
|
|
return info;
|
2005-09-06 11:20:42 +02:00
|
|
|
}
|