2 * Help Viewer Implementation
4 * Copyright 2005 James Hawkins
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #include "wine/unicode.h"
35 #include "webbrowser.h"
37 /* Window type defaults */
39 #define WINTYPE_DEFAULT_X 280
40 #define WINTYPE_DEFAULT_Y 100
41 #define WINTYPE_DEFAULT_WIDTH 740
42 #define WINTYPE_DEFAULT_HEIGHT 640
43 #define WINTYPE_DEFAULT_NAVWIDTH 251
45 typedef struct tagHHInfo
47 HH_WINTYPEW *pHHWinType;
56 extern HINSTANCE hhctrl_hinstance;
58 static LPWSTR HH_ANSIToUnicode(LPCSTR ansi)
63 count = MultiByteToWideChar(CP_ACP, 0, ansi, -1, NULL, 0);
64 unicode = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR));
65 MultiByteToWideChar(CP_ACP, 0, ansi, -1, unicode, count);
70 /* Loads a string from the resource file */
71 static LPWSTR HH_LoadString(DWORD dwID)
76 iSize = LoadStringW(hhctrl_hinstance, dwID, NULL, 0);
77 iSize += 2; /* some strings (tab text) needs double-null termination */
79 string = HeapAlloc(GetProcessHeap(), 0, iSize * sizeof(WCHAR));
80 LoadStringW(hhctrl_hinstance, dwID, string, iSize);
87 static const WCHAR szChildClass[] = {
88 'H','H',' ','C','h','i','l','d',0
91 static const WCHAR szEmpty[] = {0};
93 static void Child_OnPaint(HWND hWnd)
99 hdc = BeginPaint(hWnd, &ps);
101 /* Only paint the Navigation pane, identified by the fact
102 * that it has a child window
104 if (GetWindow(hWnd, GW_CHILD))
106 GetClientRect(hWnd, &rc);
108 /* set the border color */
109 SelectObject(hdc, GetStockObject(DC_PEN));
110 SetDCPenColor(hdc, GetSysColor(COLOR_BTNSHADOW));
112 /* Draw the top and right borders */
113 MoveToEx(hdc, 0, 0, NULL);
114 LineTo(hdc, rc.right - 1, 0);
115 LineTo(hdc, rc.right - 1, rc.bottom);
117 /* Fill in the background, taking the border lines into account */
120 FillRect(hdc, &rc, GetSysColorBrush(COLOR_3DFACE));
126 LRESULT CALLBACK Child_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
134 return DefWindowProcW(hWnd, message, wParam, lParam);
140 static void HH_RegisterChildWndClass(HHInfo *pHHInfo)
144 wcex.cbSize = sizeof(WNDCLASSEXW);
146 wcex.lpfnWndProc = (WNDPROC)Child_WndProc;
149 wcex.hInstance = pHHInfo->hInstance;
150 wcex.hIcon = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION);
151 wcex.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW);
152 wcex.hbrBackground = (HBRUSH)(COLOR_3DFACE);
153 wcex.lpszMenuName = NULL;
154 wcex.lpszClassName = szChildClass;
155 wcex.hIconSm = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION);
157 RegisterClassExW(&wcex);
164 static void TB_OnClick(HWND hWnd, DWORD dwID)
166 HHInfo *pHHInfo = (HHInfo *)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
171 WB_DoPageAction(pHHInfo->pWBInfo, WB_STOP);
174 WB_DoPageAction(pHHInfo->pWBInfo, WB_REFRESH);
177 WB_DoPageAction(pHHInfo->pWBInfo, WB_GOBACK);
181 WCHAR szUrl[MAX_PATH];
183 CHM_CreateITSUrl(pHHInfo->pCHMInfo, pHHInfo->pHHWinType->pszHome, szUrl);
184 WB_Navigate(pHHInfo->pWBInfo, szUrl);
188 WB_DoPageAction(pHHInfo->pWBInfo, WB_GOFORWARD);
195 case IDTB_BROWSE_FWD:
196 case IDTB_BROWSE_BACK:
207 static void TB_AddButton(TBBUTTON *pButtons, DWORD dwIndex, DWORD dwID)
209 /* FIXME: Load the correct button bitmaps */
210 pButtons[dwIndex].iBitmap = STD_PRINT;
211 pButtons[dwIndex].idCommand = dwID;
212 pButtons[dwIndex].fsState = TBSTATE_ENABLED;
213 pButtons[dwIndex].fsStyle = BTNS_BUTTON;
214 pButtons[dwIndex].dwData = 0;
215 pButtons[dwIndex].iString = 0;
218 static void TB_AddButtonsFromFlags(TBBUTTON *pButtons, DWORD dwButtonFlags, LPDWORD pdwNumButtons)
222 if (dwButtonFlags & HHWIN_BUTTON_EXPAND)
223 TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_EXPAND);
225 if (dwButtonFlags & HHWIN_BUTTON_BACK)
226 TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_BACK);
228 if (dwButtonFlags & HHWIN_BUTTON_FORWARD)
229 TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_FORWARD);
231 if (dwButtonFlags & HHWIN_BUTTON_STOP)
232 TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_STOP);
234 if (dwButtonFlags & HHWIN_BUTTON_REFRESH)
235 TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_REFRESH);
237 if (dwButtonFlags & HHWIN_BUTTON_HOME)
238 TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_HOME);
240 if (dwButtonFlags & HHWIN_BUTTON_SYNC)
241 TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_SYNC);
243 if (dwButtonFlags & HHWIN_BUTTON_OPTIONS)
244 TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_OPTIONS);
246 if (dwButtonFlags & HHWIN_BUTTON_PRINT)
247 TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_PRINT);
249 if (dwButtonFlags & HHWIN_BUTTON_JUMP1)
250 TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_JUMP1);
252 if (dwButtonFlags & HHWIN_BUTTON_JUMP2)
253 TB_AddButton(pButtons,(*pdwNumButtons)++, IDTB_JUMP2);
255 if (dwButtonFlags & HHWIN_BUTTON_ZOOM)
256 TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_ZOOM);
258 if (dwButtonFlags & HHWIN_BUTTON_TOC_NEXT)
259 TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_TOC_NEXT);
261 if (dwButtonFlags & HHWIN_BUTTON_TOC_PREV)
262 TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_TOC_PREV);
265 static BOOL HH_AddToolbar(HHInfo *pHHInfo)
268 HWND hwndParent = pHHInfo->pHHWinType->hwndHelp;
270 TBBUTTON buttons[IDTB_TOC_PREV - IDTB_EXPAND];
272 DWORD dwStyles, dwExStyles;
273 DWORD dwNumButtons, dwIndex;
275 if (pHHInfo->pHHWinType->fsWinProperties & HHWIN_PARAM_TB_FLAGS)
276 toolbarFlags = pHHInfo->pHHWinType->fsToolBarFlags;
278 toolbarFlags = HHWIN_DEF_BUTTONS;
280 TB_AddButtonsFromFlags(buttons, toolbarFlags, &dwNumButtons);
282 dwStyles = WS_CHILDWINDOW | WS_VISIBLE | TBSTYLE_FLAT |
283 TBSTYLE_WRAPABLE | TBSTYLE_TOOLTIPS | CCS_NODIVIDER;
284 dwExStyles = WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR;
286 hToolbar = CreateWindowExW(dwExStyles, TOOLBARCLASSNAMEW, NULL, dwStyles,
287 0, 0, 0, 0, hwndParent, NULL,
288 pHHInfo->hInstance, NULL);
292 SendMessageW(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(ICON_SIZE, ICON_SIZE));
293 SendMessageW(hToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
294 SendMessageW(hToolbar, WM_SETFONT, (WPARAM)pHHInfo->hFont, TRUE);
296 /* FIXME: Load correct icons for all buttons */
297 tbAB.hInst = HINST_COMMCTRL;
298 tbAB.nID = IDB_STD_LARGE_COLOR;
299 SendMessageW(hToolbar, TB_ADDBITMAP, 0, (LPARAM)&tbAB);
301 for (dwIndex = 0; dwIndex < dwNumButtons; dwIndex++)
303 LPWSTR szBuf = HH_LoadString(buttons[dwIndex].idCommand);
304 DWORD dwLen = strlenW(szBuf);
305 szBuf[dwLen + 2] = 0; /* Double-null terminate */
307 buttons[dwIndex].iString = (DWORD)SendMessageW(hToolbar, TB_ADDSTRINGW, 0, (LPARAM)szBuf);
308 HeapFree(GetProcessHeap(), 0, szBuf);
311 SendMessageW(hToolbar, TB_ADDBUTTONSW, dwNumButtons, (LPARAM)&buttons);
312 SendMessageW(hToolbar, TB_AUTOSIZE, 0, 0);
313 ShowWindow(hToolbar, SW_SHOW);
315 pHHInfo->pHHWinType->hwndToolBar = hToolbar;
319 /* Navigation Pane */
321 #define TAB_PADDING 2
322 #define TAB_TOP_PADDING 8
323 #define TAB_RIGHT_PADDING 4
325 static void NP_GetNavigationRect(HHInfo *pHHInfo, RECT *rc)
327 HWND hwndParent = pHHInfo->pHHWinType->hwndHelp;
328 HWND hwndToolbar = pHHInfo->pHHWinType->hwndToolBar;
329 RECT rectWND, rectTB;
331 GetClientRect(hwndParent, &rectWND);
332 GetClientRect(hwndToolbar, &rectTB);
335 rc->top = rectTB.bottom;
336 rc->bottom = rectWND.bottom - rectTB.bottom;
338 if (pHHInfo->pHHWinType->fsValidMembers & HHWIN_PARAM_NAV_WIDTH)
339 rc->right = pHHInfo->pHHWinType->iNavWidth;
341 rc->right = WINTYPE_DEFAULT_NAVWIDTH;
344 static void NP_CreateTab(HINSTANCE hInstance, HWND hwndTabCtrl, DWORD dwStrID, DWORD dwIndex)
347 LPWSTR tabText = HH_LoadString(dwStrID);
349 tie.mask = TCIF_TEXT;
350 tie.pszText = tabText;
352 TabCtrl_InsertItemW(hwndTabCtrl, dwIndex, &tie);
353 HeapFree(GetProcessHeap(), 0, tabText);
356 static BOOL HH_AddNavigationPane(HHInfo *pHHInfo)
358 HWND hWnd, hwndTabCtrl;
359 HWND hwndParent = pHHInfo->pHHWinType->hwndHelp;
360 DWORD dwStyles = WS_CHILDWINDOW | WS_VISIBLE;
361 DWORD dwExStyles = WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR;
365 NP_GetNavigationRect(pHHInfo, &rc);
367 hWnd = CreateWindowExW(dwExStyles, szChildClass, szEmpty, dwStyles,
368 rc.left, rc.top, rc.right, rc.bottom,
369 hwndParent, NULL, pHHInfo->hInstance, NULL);
373 hwndTabCtrl = CreateWindowExW(dwExStyles, WC_TABCONTROLW, szEmpty, dwStyles,
374 TAB_PADDING, TAB_TOP_PADDING,
375 rc.right - TAB_PADDING - TAB_RIGHT_PADDING,
376 rc.bottom - TAB_PADDING - TAB_TOP_PADDING,
377 hWnd, NULL, pHHInfo->hInstance, NULL);
381 if (*pHHInfo->pHHWinType->pszToc)
382 NP_CreateTab(pHHInfo->hInstance, hwndTabCtrl, IDS_CONTENTS, dwIndex++);
384 if (*pHHInfo->pHHWinType->pszIndex)
385 NP_CreateTab(pHHInfo->hInstance, hwndTabCtrl, IDS_INDEX, dwIndex++);
387 if (pHHInfo->pHHWinType->fsWinProperties & HHWIN_PROP_TAB_SEARCH)
388 NP_CreateTab(pHHInfo->hInstance, hwndTabCtrl, IDS_SEARCH, dwIndex++);
390 if (pHHInfo->pHHWinType->fsWinProperties & HHWIN_PROP_TAB_FAVORITES)
391 NP_CreateTab(pHHInfo->hInstance, hwndTabCtrl, IDS_FAVORITES, dwIndex++);
393 SendMessageW(hwndTabCtrl, WM_SETFONT, (WPARAM)pHHInfo->hFont, TRUE);
395 pHHInfo->hwndTabCtrl = hwndTabCtrl;
396 pHHInfo->pHHWinType->hwndNavigation = hWnd;
402 static void HP_GetHTMLRect(HHInfo *pHHInfo, RECT *rc)
404 HWND hwndParent = pHHInfo->pHHWinType->hwndHelp;
405 HWND hwndToolbar = pHHInfo->pHHWinType->hwndToolBar;
406 HWND hwndNavigation = pHHInfo->pHHWinType->hwndNavigation;
407 RECT rectTB, rectWND, rectNP;
409 GetClientRect(hwndParent, &rectWND);
410 GetClientRect(hwndToolbar, &rectTB);
411 GetClientRect(hwndNavigation, &rectNP);
413 rc->left = rectNP.right;
414 rc->top = rectTB.bottom;
415 rc->right = rectWND.right - rectNP.right;
416 rc->bottom = rectWND.bottom - rectTB.bottom;
419 static BOOL HH_AddHTMLPane(HHInfo *pHHInfo)
422 HWND hwndParent = pHHInfo->pHHWinType->hwndHelp;
423 DWORD dwStyles = WS_CHILDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN;
424 DWORD dwExStyles = WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | WS_EX_CLIENTEDGE;
427 HP_GetHTMLRect(pHHInfo, &rc);
429 hWnd = CreateWindowExW(dwExStyles, szChildClass, szEmpty, dwStyles,
430 rc.left, rc.top, rc.right, rc.bottom,
431 hwndParent, NULL, pHHInfo->hInstance, NULL);
435 if (!WB_EmbedBrowser(pHHInfo->pWBInfo, hWnd))
438 /* store the pointer to the HH info struct */
439 SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)pHHInfo);
441 ShowWindow(hWnd, SW_SHOW);
444 pHHInfo->pHHWinType->hwndHTML = hWnd;
450 static void Help_OnSize(HWND hWnd, LPARAM lParam)
452 HHInfo *pHHInfo = (HHInfo *)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
458 /* Only resize the Navigation pane vertically */
461 NP_GetNavigationRect(pHHInfo, &rc);
462 SetWindowPos(pHHInfo->pHHWinType->hwndNavigation, HWND_TOP, 0, 0,
463 rc.right, rc.bottom, SWP_NOMOVE);
465 GetClientRect(pHHInfo->pHHWinType->hwndNavigation, &rc);
466 SetWindowPos(pHHInfo->hwndTabCtrl, HWND_TOP, 0, 0,
467 rc.right - TAB_PADDING - TAB_RIGHT_PADDING,
468 rc.bottom - TAB_PADDING - TAB_TOP_PADDING, SWP_NOMOVE);
471 HP_GetHTMLRect(pHHInfo, &rc);
472 SetWindowPos(pHHInfo->pHHWinType->hwndHTML, HWND_TOP, 0, 0,
473 LOWORD(lParam), HIWORD(lParam), SWP_NOMOVE);
476 LRESULT CALLBACK Help_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
484 if (HIWORD(wParam) == BN_CLICKED)
485 TB_OnClick(hWnd, LOWORD(wParam));
488 Help_OnSize(hWnd, lParam);
491 hdc = BeginPaint(hWnd, &ps);
499 return DefWindowProcW(hWnd, message, wParam, lParam);
505 static BOOL HH_CreateHelpWindow(HHInfo *pHHInfo)
508 HINSTANCE hInstance = pHHInfo->hInstance;
509 RECT winPos = pHHInfo->pHHWinType->rcWindowPos;
511 DWORD dwStyles, dwExStyles;
512 DWORD x, y, width, height;
514 static const WCHAR windowClassW[] = {
515 'H','H',' ', 'P','a','r','e','n','t',0
518 wcex.cbSize = sizeof(WNDCLASSEXW);
519 wcex.style = CS_HREDRAW | CS_VREDRAW;
520 wcex.lpfnWndProc = (WNDPROC)Help_WndProc;
523 wcex.hInstance = hInstance;
524 wcex.hIcon = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION);
525 wcex.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW);
526 wcex.hbrBackground = (HBRUSH)(COLOR_MENU + 1);
527 wcex.lpszMenuName = NULL;
528 wcex.lpszClassName = windowClassW;
529 wcex.hIconSm = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION);
531 RegisterClassExW(&wcex);
533 /* Read in window parameters if available */
534 if (pHHInfo->pHHWinType->fsValidMembers & HHWIN_PARAM_STYLES)
535 dwStyles = pHHInfo->pHHWinType->dwStyles;
537 dwStyles = WS_OVERLAPPEDWINDOW | WS_VISIBLE |
538 WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
540 if (pHHInfo->pHHWinType->fsValidMembers & HHWIN_PARAM_EXSTYLES)
541 dwExStyles = pHHInfo->pHHWinType->dwExStyles;
543 dwExStyles = WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_APPWINDOW |
544 WS_EX_WINDOWEDGE | WS_EX_RIGHTSCROLLBAR;
546 if (pHHInfo->pHHWinType->fsValidMembers & HHWIN_PARAM_RECT)
550 width = winPos.right - x;
551 height = winPos.bottom - y;
555 x = WINTYPE_DEFAULT_X;
556 y = WINTYPE_DEFAULT_Y;
557 width = WINTYPE_DEFAULT_WIDTH;
558 height = WINTYPE_DEFAULT_HEIGHT;
561 hWnd = CreateWindowExW(dwExStyles, windowClassW, pHHInfo->pHHWinType->pszCaption,
562 dwStyles, x, y, width, height, NULL, NULL, hInstance, NULL);
566 ShowWindow(hWnd, SW_SHOW);
569 /* store the pointer to the HH info struct */
570 SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)pHHInfo);
572 pHHInfo->pHHWinType->hwndHelp = hWnd;
576 static void HH_CreateFont(HHInfo *pHHInfo)
580 GetObjectW(GetStockObject(ANSI_VAR_FONT), sizeof(LOGFONTW), &lf);
581 lf.lfWeight = FW_NORMAL;
583 lf.lfUnderline = FALSE;
585 pHHInfo->hFont = CreateFontIndirectW(&lf);
588 static void HH_InitRequiredControls(DWORD dwControls)
590 INITCOMMONCONTROLSEX icex;
592 icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
593 icex.dwICC = dwControls;
594 InitCommonControlsEx(&icex);
597 /* Creates the whole package */
598 static BOOL HH_CreateViewer(HHInfo *pHHInfo)
600 HH_CreateFont(pHHInfo);
602 if (!HH_CreateHelpWindow(pHHInfo))
605 HH_InitRequiredControls(ICC_BAR_CLASSES);
607 if (!HH_AddToolbar(pHHInfo))
610 HH_RegisterChildWndClass(pHHInfo);
612 if (!HH_AddNavigationPane(pHHInfo))
615 if (!HH_AddHTMLPane(pHHInfo))
621 static HHInfo *HH_OpenHH(HINSTANCE hInstance, LPWSTR szCmdLine)
623 HHInfo *pHHInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HHInfo));
625 pHHInfo->pHHWinType = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HH_WINTYPEW));
626 pHHInfo->pCHMInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(CHMInfo));
627 pHHInfo->pWBInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(WBInfo));
628 pHHInfo->hInstance = hInstance;
629 pHHInfo->szCmdLine = szCmdLine;
634 static void HH_Close(HHInfo *pHHInfo)
639 /* Free allocated strings */
640 if (pHHInfo->pHHWinType)
642 HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszType);
643 HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszCaption);
644 HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszToc);
645 HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszType);
646 HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszIndex);
647 HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszFile);
648 HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszHome);
649 HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszJump1);
650 HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszJump2);
651 HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszUrlJump1);
652 HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszUrlJump2);
655 HeapFree(GetProcessHeap(), 0, pHHInfo->pHHWinType);
656 HeapFree(GetProcessHeap(), 0, pHHInfo->szCmdLine);
658 if (pHHInfo->pCHMInfo)
660 CHM_CloseCHM(pHHInfo->pCHMInfo);
661 HeapFree(GetProcessHeap(), 0, pHHInfo->pCHMInfo);
664 if (pHHInfo->pWBInfo)
666 WB_UnEmbedBrowser(pHHInfo->pWBInfo);
667 HeapFree(GetProcessHeap(), 0, pHHInfo->pWBInfo);
671 static void HH_OpenDefaultTopic(HHInfo *pHHInfo)
674 LPCWSTR defTopic = pHHInfo->pHHWinType->pszFile;
676 CHM_CreateITSUrl(pHHInfo->pCHMInfo, defTopic, url);
677 WB_Navigate(pHHInfo->pWBInfo, url);
680 static BOOL HH_OpenCHM(HHInfo *pHHInfo)
682 if (!CHM_OpenCHM(pHHInfo->pCHMInfo, pHHInfo->szCmdLine))
685 if (!CHM_LoadWinTypeFromCHM(pHHInfo->pCHMInfo, pHHInfo->pHHWinType))
691 /* FIXME: Check szCmdLine for bad arguments */
692 int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine)
697 if (OleInitialize(NULL) != S_OK)
700 pHHInfo = HH_OpenHH(hInstance, HH_ANSIToUnicode(szCmdLine));
701 if (!pHHInfo || !HH_OpenCHM(pHHInfo) || !HH_CreateViewer(pHHInfo))
707 HH_OpenDefaultTopic(pHHInfo);
709 while (GetMessageW(&msg, 0, 0, 0))
711 TranslateMessage(&msg);
712 DispatchMessageW(&msg);
716 HeapFree(GetProcessHeap(), 0, pHHInfo);