Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1754 lines
65 KiB

  1. // Copyright (C) Microsoft Corporation 1996, All Rights reserved.
  2. #include "header.h"
  3. #include <commctrl.h>
  4. #include "contain.h"
  5. #include "secwin.h"
  6. #include "strtable.h"
  7. #include "resource.h"
  8. #include "cnotes.h"
  9. #include "system.h"
  10. #include "stdio.h"
  11. #include "string.h"
  12. #include "parserhh.h"
  13. #include "collect.h"
  14. #include "hhtypes.h"
  15. #include "toc.h"
  16. #include "highlite.h"
  17. #include "htmlhelp.h"
  18. #include "htmlpriv.h"
  19. #include <wininet.h>
  20. #include "cdefinss.h"
  21. #include "subset.h"
  22. #include <windowsx.h>
  23. #include "adsearch.h" // Used so we can update the subset combo in the AFTS tab after the define subset wizard.
  24. #ifdef _DEBUG
  25. #undef THIS_FILE
  26. static const char THIS_FILE[] = __FILE__;
  27. #endif
  28. extern BOOL g_HackForBug_HtmlHelpDB_1884;
  29. //////////////////////////////////////////////////////////////////////////
  30. //
  31. // Internal Helper Prototypes
  32. //
  33. LRESULT OnKeyDown(HWND hwnd, WPARAM wParam, LPARAM lParam) ;
  34. void DrawNavWnd(HWND hWnd) ;
  35. LRESULT OnAppCommand(HWND hwnd, WPARAM wParam, LPARAM lParam);
  36. #ifndef APPCOMMAND_BROWSER_BACKWARD
  37. #define FAPPCOMMAND_MASK 0xF000
  38. #define GET_APPCOMMAND_LPARAM(lParam) ((short)(HIWORD(lParam) & ~FAPPCOMMAND_MASK))
  39. #define WM_APPCOMMAND 0x0319
  40. #define APPCOMMAND_BROWSER_BACKWARD 1
  41. #define APPCOMMAND_BROWSER_FORWARD 2
  42. #define APPCOMMAND_BROWSER_REFRESH 3
  43. #define APPCOMMAND_BROWSER_STOP 4
  44. #define APPCOMMAND_BROWSER_SEARCH 5
  45. #define APPCOMMAND_BROWSER_FAVORITES 6
  46. #define APPCOMMAND_BROWSER_HOME 7
  47. #endif
  48. //
  49. // CAboutDlg
  50. //
  51. class CAboutDlg : public CDlg
  52. {
  53. public:
  54. CAboutDlg(HWND hwndParent) : CDlg(hwndParent, IDD_ABOUT) {
  55. }
  56. BOOL OnBeginOrEnd();
  57. };
  58. BOOL CAboutDlg::OnBeginOrEnd()
  59. {
  60. if (m_fInitializing) {
  61. SetWindowText(IDC_VERSION, GetStringResource(IDS_VERSION));
  62. }
  63. return TRUE;
  64. }
  65. static void UpdateSearchHiMenu(CHHWinType* phh, TBBUTTON * tbbtn);
  66. static void doOptionsMenu(CHHWinType* phh, HWND hwnd);
  67. void doWindowInformation(HWND hwndParent, CHHWinType* phh);
  68. extern BOOL AddTitleToGlobalList(PCSTR pszITSSFile);
  69. LRESULT WINAPI HelpWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  70. {
  71. CHHWinType* phh;
  72. if (msg == MSG_MOUSEWHEEL) {
  73. phh = FindWindowIndex(hwnd);
  74. if (phh)
  75. return phh->m_pCIExpContainer->ForwardMessage(msg, wParam, lParam);
  76. return 0;
  77. }
  78. switch(msg) {
  79. /*
  80. case WM_UPDATEUISTATE:
  81. {
  82. char buf[500] ;
  83. sprintf(buf, "hWnd = %x, Element = %x, State = %x", hwnd, HIWORD(wParam), LOWORD(wParam)) ;
  84. MessageBox(hwnd, buf, "WM_UPDATEUISTATE", MB_OK);
  85. }
  86. return DefWindowProc(hwnd, msg, wParam, lParam);
  87. case WM_CHANGEUISTATE:
  88. {
  89. char buf[500] ;
  90. sprintf(buf, "hWnd = %x, Element = %x, State = %x", hwnd, HIWORD(wParam), LOWORD(wParam)) ;
  91. MessageBox(hwnd, buf, "WM_UPDATEUISTATE", MB_OK);
  92. }
  93. return DefWindowProc(hwnd, msg, wParam, lParam);
  94. */
  95. case WM_CREATE:
  96. phh = FindWindowIndex(hwnd);
  97. if (phh)
  98. {
  99. UiStateInitialize(phh->GetHwnd()) ;
  100. }
  101. return 0 ;
  102. case WM_NCCREATE:
  103. return TRUE;
  104. case WM_APPCOMMAND:
  105. if (OnAppCommand(hwnd, wParam, lParam) == 1)
  106. return 1;
  107. return DefWindowProc(hwnd, msg, wParam, lParam);
  108. case WM_ACTIVATE:
  109. phh = FindWindowIndex(hwnd);
  110. if (phh)
  111. {
  112. if (LOWORD(wParam) != WA_INACTIVE)
  113. {
  114. //SetForegroundWindow(hwnd);
  115. if (!phh->RestoreCtrlWithFocus())
  116. {
  117. if (phh->m_pCIExpContainer) //TODO: Architect out these checks
  118. {
  119. if ( phh->m_pCIExpContainer->m_hWnd == phh->m_hwndFocused )
  120. {
  121. phh->m_pCIExpContainer->SetFocus();
  122. }
  123. else
  124. {
  125. if (phh->IsExpandedNavPane())
  126. {
  127. phh->m_pCIExpContainer->UIDeactivateIE();
  128. int iTabIndex = (int)::SendMessage(phh->m_hwndFocused, TCM_GETCURSEL, 0, 0);
  129. phh->doSelectTab(phh->tabOrder[iTabIndex]);
  130. }
  131. else
  132. phh->m_pCIExpContainer->SetFocus(TRUE);
  133. }
  134. }
  135. }
  136. // Don't expand if activation is part of creation
  137. if (phh->IsProperty(HHWIN_PROP_TAB_AUTOHIDESHOW) && !phh->IsExpandedNavPane())
  138. {
  139. MSG peekmsg;
  140. if (PeekMessage(&peekmsg, hwnd, WM_SYSCOMMAND, WM_SYSCOMMAND, PM_NOREMOVE) )
  141. {
  142. if ( (peekmsg.wParam & 0xFFF0) == SC_MINIMIZE )
  143. return 0;
  144. }
  145. else
  146. DWORD dwErr = GetLastError();
  147. if ( !HIWORD(wParam) && !phh->m_fActivated)
  148. PostMessage(hwnd, WM_COMMAND, IDTB_AUTO_SHOW, 0);
  149. }
  150. if (!phh->m_fActivated)
  151. phh->m_fActivated = TRUE;
  152. //
  153. // !!Hack alert!!
  154. //
  155. // For some unknown reason winhelp popup's create painting problems. I believe that the root of the
  156. // problem lies in the way winhelp popup's are implemented. It seems that the popup paints on the window
  157. // that it sits over and then upon dismissal it invalidates the area it painted on but it does not call
  158. // UpdateWindow(). Obviously we can't do anything about that now. This code detects the case where we have
  159. // received activation from a winhelp popup and forces a WM_PAINT message to go to the ie window.
  160. //
  161. if ( g_HackForBug_HtmlHelpDB_1884 )
  162. {
  163. if (phh->m_pCIExpContainer)
  164. UpdateWindow(phh->m_pCIExpContainer->m_hWnd);
  165. g_HackForBug_HtmlHelpDB_1884 = 0;
  166. }
  167. }
  168. else
  169. {
  170. phh->SaveCtrlWithFocus() ;
  171. phh->m_fActivated = FALSE;
  172. if ( phh->IsProperty(HHWIN_PROP_TAB_AUTOHIDESHOW) && !phh->fNotExpanded)
  173. {
  174. MSG peekmsg;
  175. while (PeekMessage(&peekmsg, hwnd, WM_SYSCOMMAND, WM_SYSCOMMAND, PM_NOREMOVE))
  176. {
  177. if ( (peekmsg.wParam & 0xFFF0) == SC_MINIMIZE )
  178. return 0;
  179. }
  180. if (!HIWORD(wParam) ) // if not minimized
  181. phh->ToggleExpansion();//SendMessage(hwnd, WM_COMMAND, IDTB_CONTRACT, 0);
  182. }
  183. }
  184. }
  185. return FALSE;
  186. case WM_DESTROY:
  187. // Find the index into our array of HELPWINDOWS structures
  188. phh = FindWindowIndex(hwnd);
  189. if (phh)
  190. {
  191. // shutdown the child windows and controls.
  192. for(int j=0; j< c_NUMNAVPANES; j++)
  193. {
  194. if ( phh->m_aNavPane[j] )
  195. {
  196. delete phh->m_aNavPane[j];
  197. phh->m_aNavPane[j] = NULL;
  198. }
  199. }
  200. if ( phh->m_pTabCtrl )
  201. {
  202. delete phh->m_pTabCtrl;
  203. phh->m_pTabCtrl = NULL;
  204. }
  205. if ( phh->m_pSizeBar )
  206. {
  207. delete phh->m_pSizeBar;
  208. phh->m_pSizeBar = NULL;
  209. }
  210. if ( phh->hwndToolBar )
  211. {
  212. DestroyWindow( phh->hwndToolBar );
  213. phh->hwndToolBar = NULL;
  214. }
  215. if( phh->m_hImageListGray ) {
  216. ImageList_Destroy( phh->m_hImageListGray );
  217. phh->m_hImageListGray = NULL;
  218. }
  219. if( phh->m_hImageList ) {
  220. ImageList_Destroy( phh->m_hImageList );
  221. phh->m_hImageList = NULL;
  222. }
  223. // Get the desktop window.
  224. HWND hWndDesktop = ::GetDesktopWindow() ;
  225. if (hWndDesktop != phh->hwndCaller)
  226. {
  227. // VS98 Bug 14755 - We were setting the foreground window to be that
  228. // of the desktop when we were embedded in vs98. To fix the bug,
  229. // we let windows pick the foreground window.
  230. SetForegroundWindow(phh->hwndCaller);
  231. }
  232. // Check to see if we are destroying the last window.
  233. // If not, then just set the current phh->hwndHelp
  234. // member to NULL so the WIN_TYPE can be used again.
  235. //
  236. BOOL bOtherWindowsExist = FALSE;
  237. // Determine if other windows exist.
  238. //
  239. for (int i = 0; i < g_cWindowSlots; i++)
  240. {
  241. if (pahwnd[i] != NULL && pahwnd[i]->hwndHelp != NULL && pahwnd[i] != phh)
  242. bOtherWindowsExist = TRUE;
  243. }
  244. // If other windows exist, then remove this window handle from the
  245. // the current HH_WIN_TYPE. If we are asked to display another topic
  246. // of this window type the hwndHelp member will be used to store the
  247. // handle of the new window created.
  248. //
  249. if(bOtherWindowsExist)
  250. {
  251. phh->hwndHelp = NULL;
  252. // Delete the container
  253. //
  254. if (phh->m_pCIExpContainer)
  255. {
  256. phh->m_pCIExpContainer->ShutDown();
  257. phh->m_pCIExpContainer = NULL;
  258. }
  259. phh->m_phmData = NULL;
  260. }
  261. else
  262. {
  263. // This is the last window. Destroy all HH_WIN_TYPE objects.
  264. //
  265. for (int i = 0; i < g_cWindowSlots; i++)
  266. {
  267. if (pahwnd[i] != NULL)
  268. {
  269. delete pahwnd[i];
  270. pahwnd[i] = NULL;
  271. }
  272. }
  273. }
  274. }
  275. return DefWindowProc(hwnd, msg, wParam, lParam);
  276. case WM_MENUCHAR: // translate the accelerator key strokes.
  277. sim_menuchar:
  278. PostMessage(hwnd, WMP_HH_TRANS_ACCELERATOR, ToLower(static_cast<char>(LOWORD(wParam))), (LPARAM)NULL);
  279. return MAKELONG( 0, MNC_CLOSE) ;
  280. case WMP_HH_TRANS_ACCELERATOR:
  281. phh = FindWindowIndex(hwnd);
  282. if (!phh)
  283. phh = FindWindowIndex(GetParent(hwnd));
  284. if (!phh)
  285. break;
  286. return phh->ManualTranslateAccelerator(ToLower(static_cast<char>(LOWORD(wParam))));
  287. case WM_KEYDOWN:
  288. return OnKeyDown(hwnd, wParam, lParam) ;
  289. case WM_SIZE:
  290. switch (wParam) {
  291. case SIZE_RESTORED:
  292. case SIZE_MAXIMIZED:
  293. case SIZE_MAXSHOW:
  294. phh = FindWindowIndex(hwnd);
  295. if (phh)
  296. {
  297. if (hwnd == *phh)
  298. {
  299. if (phh->hwndToolBar )
  300. phh->WrapTB();
  301. if (phh->hwndHTML)
  302. {
  303. ResizeWindow(phh);
  304. }
  305. else if (phh->m_pCIExpContainer)
  306. {
  307. // non tri-pane window
  308. ::GetClientRect(phh->hwndHelp, &phh->rcHTML);
  309. phh->m_pCIExpContainer->SizeIt(RECT_WIDTH(phh->rcHTML), RECT_HEIGHT(phh->rcHTML));
  310. }
  311. }
  312. }
  313. break;
  314. }
  315. return DefWindowProc(hwnd, msg, wParam, lParam);
  316. case WM_SYSCOMMAND:
  317. if ((LOWORD(wParam) >= IDC_SELECT_TAB_FIRST) && (LOWORD(wParam) <= IDC_SELECT_TAB_LAST))
  318. {
  319. phh = FindWindowIndex(hwnd);
  320. if (!phh)
  321. phh = FindWindowIndex(GetParent(hwnd));
  322. if (phh)
  323. phh->doSelectTab(LOWORD(wParam) - IDC_SELECT_TAB_FIRST) ;
  324. }
  325. else if (LOWORD(wParam) == IDM_VERSION) {
  326. if (IsHelpAuthor(hwnd)) {
  327. phh = FindWindowIndex(hwnd);
  328. if (!phh)
  329. phh = FindWindowIndex(GetParent(hwnd));
  330. doHhctrlVersion(hwnd,
  331. (phh && phh->m_phmData && phh->m_phmData->GetInfo() ? phh->m_phmData->GetInfo()->GetCompilerInformation() : NULL));
  332. }
  333. else
  334. goto about;
  335. break;
  336. }
  337. else if (LOWORD(wParam) == ID_JUMP_URL) {
  338. JumpURL:
  339. phh = FindWindowIndex(hwnd);
  340. if (!phh)
  341. phh = FindWindowIndex(GetParent(hwnd));
  342. if (!phh)
  343. break;
  344. char szDstUrl[INTERNET_MAX_URL_LENGTH];
  345. CStr cszCurUrl;
  346. phh->m_pCIExpContainer->m_pWebBrowserApp->GetLocationURL(&cszCurUrl);
  347. if (doJumpUrl(hwnd, cszCurUrl, szDstUrl) && szDstUrl[0])
  348. phh->m_pCIExpContainer->m_pWebBrowserApp->Navigate(szDstUrl, NULL, NULL, NULL, NULL);
  349. break;
  350. }
  351. else if (LOWORD(wParam) == IDM_WINDOW_INFO) {
  352. phh = FindWindowIndex(hwnd);
  353. if (!phh)
  354. phh = FindWindowIndex(GetParent(hwnd));
  355. doWindowInformation(hwnd, phh);
  356. break;
  357. }
  358. #ifdef _DEBUG
  359. else if (LOWORD(wParam) == ID_VIEW_MEMORY) {
  360. OnReportMemoryUsage();
  361. break;
  362. }
  363. else if (LOWORD(wParam) == ID_DEBUG_BREAK) {
  364. #ifdef _DEBUG
  365. DebugBreak();
  366. #endif
  367. break;
  368. }
  369. #endif
  370. return DefWindowProc(hwnd, msg, wParam, lParam);
  371. case WM_INITMENU:
  372. HMENU hMenu;
  373. if ( (phh = FindWindowIndex(hwnd)) )
  374. {
  375. hMenu = GetMenu(hwnd);
  376. if( hMenu ) {
  377. if( phh->IsExpandedNavPane() )
  378. CheckMenuItem(hMenu, HHM_HIDE_SHOW, MF_CHECKED);
  379. else
  380. CheckMenuItem(hMenu, HHM_HIDE_SHOW, MF_UNCHECKED);
  381. if( !phh->m_iZoomMin && !phh->m_iZoomMax ) {
  382. CheckMenuItem(hMenu, IDTB_ZOOM_SMALLEST, MF_UNCHECKED);
  383. CheckMenuItem(hMenu, IDTB_ZOOM_SMALLER, MF_UNCHECKED);
  384. CheckMenuItem(hMenu, IDTB_ZOOM_MEDIUM, MF_UNCHECKED);
  385. CheckMenuItem(hMenu, IDTB_ZOOM_LARGER, MF_UNCHECKED);
  386. CheckMenuItem(hMenu, IDTB_ZOOM_LARGEST, MF_UNCHECKED);
  387. EnableMenuItem(hMenu, IDTB_ZOOM_SMALLEST, MF_GRAYED);
  388. EnableMenuItem(hMenu, IDTB_ZOOM_SMALLER, MF_GRAYED);
  389. EnableMenuItem(hMenu, IDTB_ZOOM_MEDIUM, MF_GRAYED);
  390. EnableMenuItem(hMenu, IDTB_ZOOM_LARGER, MF_GRAYED);
  391. EnableMenuItem(hMenu, IDTB_ZOOM_LARGEST, MF_GRAYED);
  392. }
  393. else {
  394. if( phh->m_iZoom == phh->m_iZoomMin )
  395. CheckMenuItem(hMenu, IDTB_ZOOM_SMALLEST, MF_CHECKED);
  396. else
  397. CheckMenuItem(hMenu, IDTB_ZOOM_SMALLEST, MF_UNCHECKED);
  398. if( phh->m_iZoom == phh->m_iZoomMin+1 )
  399. CheckMenuItem(hMenu, IDTB_ZOOM_SMALLER, MF_CHECKED);
  400. else
  401. CheckMenuItem(hMenu, IDTB_ZOOM_SMALLER, MF_UNCHECKED);
  402. if( phh->m_iZoom == phh->m_iZoomMin+2 )
  403. CheckMenuItem(hMenu, IDTB_ZOOM_MEDIUM, MF_CHECKED);
  404. else
  405. CheckMenuItem(hMenu, IDTB_ZOOM_MEDIUM, MF_UNCHECKED);
  406. if( phh->m_iZoom == phh->m_iZoomMax-1 )
  407. CheckMenuItem(hMenu, IDTB_ZOOM_LARGER, MF_CHECKED);
  408. else
  409. CheckMenuItem(hMenu, IDTB_ZOOM_LARGER, MF_UNCHECKED);
  410. if( phh->m_iZoom == phh->m_iZoomMax )
  411. CheckMenuItem(hMenu, IDTB_ZOOM_LARGEST, MF_CHECKED);
  412. else
  413. CheckMenuItem(hMenu, IDTB_ZOOM_LARGEST, MF_UNCHECKED);
  414. }
  415. // See if selection exists in doc window
  416. //
  417. if ( phh && phh->m_pCIExpContainer )
  418. {
  419. LPDISPATCH lpDispatch = phh->m_pCIExpContainer->m_pWebBrowserApp->GetDocument();
  420. if(lpDispatch)
  421. {
  422. WCHAR *pSelectText = GetSelectionText(lpDispatch);
  423. lpDispatch->Release();
  424. if(pSelectText)
  425. {
  426. SysFreeString(pSelectText);
  427. EnableMenuItem(hMenu, HHM_COPY, MF_BYCOMMAND | MF_ENABLED) ;
  428. }
  429. else
  430. EnableMenuItem(hMenu, HHM_COPY, MF_BYCOMMAND | MF_GRAYED) ;
  431. }
  432. else
  433. EnableMenuItem(hMenu, HHM_COPY, MF_BYCOMMAND | MF_GRAYED) ;
  434. }
  435. if (phh->GetCurrentNavPaneIndex() == HHWIN_NAVTYPE_TOC)
  436. {
  437. CheckMenuItem(hMenu, HHM_CONTENTS , MF_CHECKED);
  438. CheckMenuItem(hMenu, HHM_INDEX , MF_UNCHECKED);
  439. CheckMenuItem(hMenu, HHM_SEARCH , MF_UNCHECKED);
  440. CheckMenuItem(hMenu, HHM_FAVORITES , MF_UNCHECKED);
  441. }
  442. else if (phh->GetCurrentNavPaneIndex() == HHWIN_NAVTYPE_INDEX)
  443. {
  444. CheckMenuItem(hMenu, HHM_INDEX , MF_CHECKED);
  445. CheckMenuItem(hMenu, HHM_CONTENTS , MF_UNCHECKED);
  446. CheckMenuItem(hMenu, HHM_SEARCH , MF_UNCHECKED);
  447. CheckMenuItem(hMenu, HHM_FAVORITES , MF_UNCHECKED);
  448. }
  449. else if (phh->GetCurrentNavPaneIndex() == HHWIN_NAVTYPE_SEARCH)
  450. {
  451. CheckMenuItem(hMenu, HHM_SEARCH , MF_CHECKED);
  452. CheckMenuItem(hMenu, HHM_INDEX , MF_UNCHECKED);
  453. CheckMenuItem(hMenu, HHM_CONTENTS , MF_UNCHECKED);
  454. CheckMenuItem(hMenu, HHM_FAVORITES , MF_UNCHECKED);
  455. }
  456. else if (phh->GetCurrentNavPaneIndex() == HHWIN_NAVTYPE_FAVORITES)
  457. {
  458. CheckMenuItem(hMenu, HHM_FAVORITES , MF_CHECKED);
  459. CheckMenuItem(hMenu, HHM_INDEX , MF_UNCHECKED);
  460. CheckMenuItem(hMenu, HHM_SEARCH , MF_UNCHECKED);
  461. CheckMenuItem(hMenu, HHM_CONTENTS , MF_UNCHECKED);
  462. }
  463. if ( phh->m_phmData
  464. && phh->m_phmData->m_pTitleCollection // Bug 4163: Why? TODO: Too much checking on state.
  465. && phh->m_phmData->m_pTitleCollection->m_pSearchHighlight)
  466. {
  467. if ( phh->m_phmData->m_pTitleCollection->m_pSearchHighlight->m_bHighlightEnabled )
  468. CheckMenuItem(hMenu, HHM_SEARCHHILITE , MF_CHECKED);
  469. else
  470. CheckMenuItem(hMenu, HHM_SEARCHHILITE , MF_UNCHECKED);
  471. }
  472. else
  473. EnableMenuItem(hMenu, HHM_SEARCHHILITE, MF_BYCOMMAND | MF_GRAYED);
  474. if (phh->m_pCIExpContainer->m_pInPlaceActive)
  475. {
  476. EnableMenuItem(hMenu, HHM_SELECTALL, MF_BYCOMMAND | MF_ENABLED) ;
  477. EnableMenuItem(hMenu, HHM_VIEWSOURCE, MF_BYCOMMAND | MF_ENABLED) ;
  478. }
  479. else
  480. {
  481. EnableMenuItem(hMenu, HHM_SELECTALL, MF_BYCOMMAND | MF_GRAYED) ;
  482. EnableMenuItem(hMenu, HHM_VIEWSOURCE, MF_BYCOMMAND | MF_GRAYED) ;
  483. }
  484. }
  485. break;
  486. }
  487. case WM_COMMAND:
  488. phh = FindWindowIndex(hwnd);
  489. if (!phh)
  490. phh = FindWindowIndex(GetParent(hwnd));
  491. if (!phh)
  492. break;
  493. switch (LOWORD(wParam))
  494. {
  495. case IDC_SS_COMBO:
  496. if ( phh->m_pCIExpContainer )
  497. phh->m_pCIExpContainer->UIDeactivateIE();
  498. SetFocus(GetDlgItem(hwnd,IDC_SS_PICKER));
  499. break;
  500. case IDC_SS_PICKER:
  501. if ( HIWORD(wParam) == CBN_SELCHANGE )
  502. {
  503. if ( phh->m_phmData && phh->m_phmData->m_pTitleCollection && phh->m_phmData->m_pTitleCollection->m_pSSList )
  504. {
  505. HWND hWndCB = (HWND)lParam;
  506. INT_PTR i;
  507. TCHAR szSel[MAX_SS_NAME_LEN];
  508. CStructuralSubset* pSS, *pSSCur;
  509. pSSCur = phh->m_phmData->m_pTitleCollection->m_pSSList->GetTOC();
  510. if ( (i = SendMessage(hWndCB, CB_GETCURSEL, 0, 0L)) != -1 )
  511. {
  512. SendMessage(hWndCB, CB_GETLBTEXT, i, (LPARAM)szSel);
  513. if ( (pSS = phh->m_phmData->m_pTitleCollection->m_pSSList->GetSubset(szSel)) && pSS != pSSCur )
  514. {
  515. phh->m_phmData->m_pTitleCollection->m_pSSList->SetFTS(pSS);
  516. phh->m_phmData->m_pTitleCollection->m_pSSList->SetF1(pSS);
  517. phh->m_phmData->m_pTitleCollection->m_pSSList->SetTOC(pSS);
  518. pSS->SelectAsTOCSubset(phh->m_phmData->m_pTitleCollection);
  519. phh->UpdateInformationTypes(); // This call re-draws the TOC.
  520. }
  521. else
  522. {
  523. if ( pSS = phh->m_phmData->m_pTitleCollection->m_pSSList->GetEC() )
  524. {
  525. phh->m_phmData->m_pTitleCollection->m_pSSList->SetFTS(pSS);
  526. phh->m_phmData->m_pTitleCollection->m_pSSList->SetF1(pSS);
  527. phh->m_phmData->m_pTitleCollection->m_pSSList->SetTOC(pSS);
  528. pSS->SelectAsTOCSubset(phh->m_phmData->m_pTitleCollection);
  529. phh->UpdateInformationTypes(); // This call re-draws the TOC.
  530. }
  531. }
  532. }
  533. }
  534. }
  535. break;
  536. case IDTB_HILITE:
  537. searchhighlight:
  538. if ( phh )
  539. {
  540. if (phh->OnTrackNotifyCaller(HHACT_HIGHLIGHT))
  541. break;
  542. const int MENUITEMSTRINGLEN = 80;
  543. if ( !(phh->m_phmData->m_pTitleCollection) && !(phh->m_phmData->m_pTitleCollection->m_pSearchHighlight) )
  544. break;
  545. if ( phh->m_phmData->m_pTitleCollection->m_pSearchHighlight->m_bHighlightEnabled )
  546. { // its currently on; turn it off
  547. phh->m_phmData->m_pTitleCollection->m_pSearchHighlight->EnableHighlight(FALSE); // TURN HIGHLIGHTING OFF
  548. }
  549. else
  550. { // its currently off; turn it on.
  551. phh->m_phmData->m_pTitleCollection->m_pSearchHighlight->EnableHighlight(TRUE); // TURN HIGHLIGHTING ON
  552. }
  553. }
  554. break;
  555. case IDTB_CUSTOMIZE:
  556. if ( !phh )
  557. break;
  558. if (phh->OnTrackNotifyCaller(HHACT_CUSTOMIZE))
  559. break;
  560. // Currently only forward this to the TOC, because that the way the code was.
  561. if (phh->curNavType == HHWIN_NAVTYPE_TOC)
  562. {
  563. // ASSERT(phh->m_aNavPane[phh->curNavType]) ;
  564. if( phh && phh->m_aNavPane[phh->curNavType] )
  565. phh->m_aNavPane[phh->curNavType]->OnCommand(hwnd, LOWORD(ID_CUSTOMIZE_INFO_TYPES), HIWORD(0), 0L);
  566. }
  567. /*
  568. else if (phh->curNavType == HHWIN_NAVTYPE_INDEX)
  569. break; //phh->m_aNavPane[HH_TAB_INDEX]->OnCommand(LOWORD(wParam), HIWORD(wParam));
  570. else if (phh->curNavType == HHWIN_NAVTYPE_SEARCH)
  571. break; //phh->m_aNavPane[HH_TAB_SEARCH]->OnCommand(LOWORD(wParam), HIWORD(wParam), lParam );
  572. */
  573. break;
  574. case HHM_HOMEPAGE:
  575. case IDTB_HOME:
  576. if (!phh)
  577. break;
  578. if (phh->OnTrackNotifyCaller(HHACT_HOME))
  579. break;
  580. if (phh->pszHome)
  581. phh->m_pCIExpContainer->m_pWebBrowserApp->Navigate(phh->pszHome, NULL, NULL, NULL, NULL);
  582. else
  583. MsgBox(IDS_NO_HOMEPAGE, (MB_OK | MB_ICONINFORMATION | MB_TASKMODAL));
  584. break;
  585. case IDTB_JUMP1:
  586. if (!phh)
  587. break;
  588. if (phh->OnTrackNotifyCaller(HHACT_JUMP1))
  589. break;
  590. if (phh->pszUrlJump1)
  591. phh->m_pCIExpContainer->m_pWebBrowserApp->Navigate(
  592. phh->pszUrlJump1, NULL, NULL, NULL, NULL);
  593. break;
  594. case IDTB_JUMP2:
  595. jump2:
  596. if (!phh)
  597. break;
  598. if (phh->OnTrackNotifyCaller(HHACT_JUMP2))
  599. break;
  600. if (phh->pszUrlJump2)
  601. phh->m_pCIExpContainer->m_pWebBrowserApp->Navigate(
  602. phh->pszUrlJump2, NULL, NULL, NULL, NULL);
  603. break;
  604. case IDTB_REFRESH:
  605. if (phh) {
  606. if (phh->OnTrackNotifyCaller(HHACT_REFRESH))
  607. break;
  608. phh->m_pCIExpContainer->m_pWebBrowserApp->Refresh();
  609. }
  610. break;
  611. case IDTB_BACK:
  612. if (phh) {
  613. if (phh->OnTrackNotifyCaller(HHACT_BACK))
  614. break;
  615. phh->m_pCIExpContainer->m_pWebBrowserApp->GoBack();
  616. }
  617. break;
  618. case IDTB_FORWARD:
  619. if (phh) {
  620. if (phh->OnTrackNotifyCaller(HHACT_FORWARD))
  621. break;
  622. phh->m_pCIExpContainer->m_pWebBrowserApp->GoForward();
  623. }
  624. break;
  625. case IDTB_STOP:
  626. if (phh) {
  627. if (phh->OnTrackNotifyCaller(HHACT_STOP))
  628. break;
  629. phh->m_pCIExpContainer->m_pWebBrowserApp->Stop();
  630. }
  631. break;
  632. case IDTB_ZOOM:
  633. if (phh) {
  634. if (phh->OnTrackNotifyCaller(HHACT_ZOOM))
  635. break;
  636. phh->ZoomIn();
  637. }
  638. break;
  639. case IDTB_ZOOM_SMALLEST:
  640. if (phh) {
  641. if (phh->OnTrackNotifyCaller(HHACT_ZOOM))
  642. break;
  643. phh->Zoom(phh->m_iZoomMin);
  644. }
  645. break;
  646. case IDTB_ZOOM_SMALLER:
  647. if (phh) {
  648. if (phh->OnTrackNotifyCaller(HHACT_ZOOM))
  649. break;
  650. phh->Zoom(phh->m_iZoomMin+1);
  651. }
  652. break;
  653. case IDTB_ZOOM_MEDIUM:
  654. if (phh) {
  655. if (phh->OnTrackNotifyCaller(HHACT_ZOOM))
  656. break;
  657. phh->Zoom(phh->m_iZoomMin+2);
  658. }
  659. break;
  660. case IDTB_ZOOM_LARGER:
  661. if (phh) {
  662. if (phh->OnTrackNotifyCaller(HHACT_ZOOM))
  663. break;
  664. phh->Zoom(phh->m_iZoomMax-1);
  665. }
  666. break;
  667. case IDTB_ZOOM_LARGEST:
  668. if (phh) {
  669. if (phh->OnTrackNotifyCaller(HHACT_ZOOM))
  670. break;
  671. phh->Zoom(phh->m_iZoomMax);
  672. }
  673. break;
  674. case IDTB_TOC_NEXT: // ALT-<downarrow>
  675. if (phh)
  676. {
  677. if ( HIWORD(wParam) ) // Have we gotten here via a keyboard accelerator ?
  678. {
  679. HWND hwnd_focus;
  680. hwnd_focus = GetFocus();
  681. if ( GetWindowLong(hwnd_focus, GWL_ID) == IDC_ADVSRC_KEYWORD_COMBO )
  682. {
  683. // The combo box has the drop down window style. Sooao, drop it down.
  684. ::SendMessage(GetParent( hwnd_focus), CB_SHOWDROPDOWN, (WPARAM)TRUE, (LPARAM)0);
  685. break;
  686. }
  687. else if ( hwnd_focus == GetDlgItem(hwnd,IDC_SS_PICKER) )
  688. {
  689. SendMessage(hwnd_focus, CB_SHOWDROPDOWN, (WPARAM)1, (LPARAM)0);
  690. break;
  691. }
  692. }
  693. if (phh->OnTrackNotifyCaller(HHACT_TOC_NEXT))
  694. break;
  695. phh->OnTocNext(TRUE);
  696. }
  697. break;
  698. case IDTB_TOC_PREV:
  699. if (phh)
  700. {
  701. if ( HIWORD(wParam) ) // Have we gotten here via a keyboard accelerator ?
  702. {
  703. HWND hwnd_focus;
  704. hwnd_focus = GetFocus();
  705. if ( GetWindowLong(hwnd_focus, GWL_ID) == IDC_ADVSRC_KEYWORD_COMBO )
  706. {
  707. // The combo box has the drop down window style. Sooao, fold it up.
  708. ::SendMessage(GetParent( hwnd_focus), CB_SHOWDROPDOWN, (WPARAM)0, (LPARAM)0);
  709. break;
  710. }
  711. else if ( hwnd_focus == GetDlgItem(hwnd,IDC_SS_PICKER) )
  712. {
  713. SendMessage(hwnd_focus, CB_SHOWDROPDOWN, (WPARAM)0, (LPARAM)0);
  714. break;
  715. }
  716. }
  717. if (phh->OnTrackNotifyCaller(HHACT_TOC_PREV))
  718. break;
  719. phh->OnTocPrev(TRUE);
  720. }
  721. break;
  722. case HHM_HIDE_SHOW:
  723. case IDTB_CONTRACT:
  724. case IDTB_EXPAND:
  725. if (phh)
  726. {
  727. if (phh->OnTrackNotifyCaller(LOWORD(wParam) == IDTB_CONTRACT ?
  728. HHACT_CONTRACT : HHACT_EXPAND))
  729. break;
  730. TBBUTTON tbbtn;
  731. BOOL fUpdateMenu;
  732. MENUITEMINFO mii;
  733. ZERO_STRUCTURE ( mii );
  734. mii.cbSize = sizeof( MENUITEMINFO );
  735. // update the menu items
  736. WPARAM btn_index = SendMessage(phh->hwndToolBar, TB_COMMANDTOINDEX, IDTB_OPTIONS, 0L);
  737. fUpdateMenu = SendMessage(phh->hwndToolBar, TB_GETBUTTON, btn_index, (LPARAM)(LPTBBUTTON)&tbbtn )!=0;
  738. mii.fMask = MIIM_STATE;
  739. mii.fState = (phh->IsExpandedNavPane() ? MFS_DISABLED : MFS_ENABLED);
  740. if ( fUpdateMenu )
  741. SetMenuItemInfo((HMENU)tbbtn.dwData, IDTB_CONTRACT, FALSE, &mii);
  742. mii.fState = (phh->IsExpandedNavPane() ? MFS_ENABLED : MFS_DISABLED);
  743. if ( fUpdateMenu)
  744. SetMenuItemInfo((HMENU)tbbtn.dwData, IDTB_EXPAND, FALSE, &mii);
  745. phh->ToggleExpansion(false);
  746. phh->m_pCIExpContainer->SetFocus();
  747. // phh->m_pCIExpContainer->m_pWebBrowserApp->Refresh();
  748. ResizeWindow(phh);
  749. }
  750. break;
  751. case IDGA_TOGGLE_PANE:
  752. //
  753. // Toggle focus and UI activation between the nav-tabs and the topic window.
  754. //
  755. if ( phh && phh->m_pCIExpContainer )
  756. {
  757. if ( phh->m_pCIExpContainer->IsUIActive() )
  758. {
  759. if (phh->m_pTabCtrl)
  760. {
  761. phh->m_pCIExpContainer->UIDeactivateIE(); // deactive topic window (IE)
  762. HWND hWndTabCtrl = phh->m_pTabCtrl->hWnd();
  763. int iTabIndex = (int)::SendMessage(hWndTabCtrl, TCM_GETCURSEL, 0, 0);
  764. phh->doSelectTab(phh->tabOrder[iTabIndex]);
  765. }
  766. }
  767. else
  768. phh->m_pCIExpContainer->SetFocus();
  769. }
  770. break;
  771. case IDGA_F1_LOOKUP:
  772. if ( phh && phh->m_pCIExpContainer )
  773. {
  774. if ( phh->m_pCIExpContainer->IsUIActive() )
  775. {
  776. if( phh->m_pCIExpContainer->m_pWebBrowserApp )
  777. DoF1Lookup(phh->m_pCIExpContainer->m_pWebBrowserApp);
  778. }
  779. }
  780. break;
  781. case IDGA_NEXT_NAV_TAB:
  782. case IDGA_PREV_NAV_TAB:
  783. if ( phh && !phh->m_pCIExpContainer->IsUIActive() )
  784. { // IE does not have focus; so the CTRL-TAB is for the navigation tab.
  785. // even though we pretranslate the accelerators to IE first then to the
  786. // HH second we dont want to process CTRL-TAB if IE does not and IE has focus.
  787. // This would lead to inconsistent actions based on what is displayed in the IE pane.
  788. // CTRL-TAB moves between buttons in the IE pane.
  789. // display the next tab in the tab order of the navigation pane. ( if there
  790. // is a navigation pane)
  791. if ( phh->m_pTabCtrl )
  792. {
  793. HWND hWndTabCtrl = phh->m_pTabCtrl->hWnd();
  794. int iTabIndex = (int)::SendMessage(hWndTabCtrl, TCM_GETCURSEL, 0, 0);
  795. if ( LOWORD(wParam) == IDGA_NEXT_NAV_TAB )
  796. iTabIndex = iTabIndex+1 >= phh->m_pTabCtrl->MaxTabs() ? 0:iTabIndex+1;
  797. else if ( LOWORD(wParam) == IDGA_PREV_NAV_TAB )
  798. iTabIndex = (iTabIndex-1 < 0 ? phh->m_pTabCtrl->MaxTabs()-1:iTabIndex-1);
  799. phh->doSelectTab(phh->tabOrder[iTabIndex]);
  800. }
  801. }
  802. break;
  803. case HHM_SEARCHHILITE:
  804. goto searchhighlight;
  805. case HHM_ABOUT:
  806. {
  807. about:
  808. CAboutDlg about(hwnd);
  809. about.DoModal();
  810. break;
  811. }
  812. case HHM_SYNC:
  813. case IDTB_SYNC:
  814. if (!phh)
  815. break;
  816. if (phh->OnTrackNotifyCaller(HHACT_SYNC))
  817. break;
  818. if (!IsEmptyString(phh->pszToc))
  819. {
  820. CStr cszUrl;
  821. phh->m_pCIExpContainer->m_pWebBrowserApp->GetLocationURL(&cszUrl);
  822. phh->doSelectTab(HH_TAB_CONTENTS) ;
  823. CToc* ptoc = reinterpret_cast<CToc*>(phh->m_aNavPane[HH_TAB_CONTENTS]) ; // HACKHACK: Should use dynamic cast, but no RTTI.
  824. if (! ptoc )
  825. break;
  826. if (! ptoc->Synchronize(cszUrl) )
  827. {
  828. // If sync failed and we're using a subset, offer to switch to EC.
  829. //
  830. if ( phh->m_phmData && phh->m_phmData->m_pTitleCollection && phh->m_phmData->m_pTitleCollection->m_pSSList )
  831. {
  832. CStructuralSubset* pSSCur;
  833. HWND hWndCB;
  834. pSSCur = phh->m_phmData->m_pTitleCollection->m_pSSList->GetTOC();
  835. if (! pSSCur->IsEntire() )
  836. {
  837. if ( MsgBox(IDS_SWITCH_SUBSETS, MB_YESNO | MB_ICONQUESTION) == IDYES )
  838. {
  839. pSSCur = phh->m_phmData->m_pTitleCollection->m_pSSList->GetEC();
  840. phh->m_phmData->m_pTitleCollection->m_pSSList->SetTOC(pSSCur);
  841. phh->m_phmData->m_pTitleCollection->m_pSSList->SetFTS(pSSCur);
  842. phh->m_phmData->m_pTitleCollection->m_pSSList->SetF1(pSSCur);
  843. pSSCur->SelectAsTOCSubset(phh->m_phmData->m_pTitleCollection);
  844. ptoc->Refresh();
  845. ptoc->Synchronize(cszUrl);
  846. //
  847. // Select EC in the SS picker combo...
  848. //
  849. if ( (hWndCB = GetDlgItem(hwnd, IDC_SS_PICKER)) )
  850. SendMessage(hWndCB, CB_SELECTSTRING, -1, (LPARAM)pSSCur->GetName());
  851. }
  852. }
  853. }
  854. }
  855. }
  856. break;
  857. #ifndef CHIINDEX
  858. case HHM_PRINT:
  859. case IDTB_PRINT:
  860. if (phh) {
  861. if (phh->OnTrackNotifyCaller(HHACT_PRINT))
  862. break;
  863. phh->OnPrint();
  864. }
  865. break;
  866. #endif
  867. //REVIEW: Sending a key to ourselfs to do a menu item seems a little hokey.
  868. case HHM_CONTENTS:
  869. wParam = _Resource.TabCtrlKeys(HHWIN_NAVTYPE_TOC);
  870. goto sim_menuchar;
  871. case HHM_SEARCH:
  872. wParam = _Resource.TabCtrlKeys(HHWIN_NAVTYPE_SEARCH);
  873. goto sim_menuchar;
  874. case HHM_INDEX:
  875. wParam = _Resource.TabCtrlKeys(HHWIN_NAVTYPE_INDEX);
  876. goto sim_menuchar;
  877. case HHM_FAVORITES:
  878. wParam = _Resource.TabCtrlKeys(HHWIN_NAVTYPE_FAVORITES);
  879. goto sim_menuchar;
  880. case HHM_EXIT:
  881. PostMessage(hwnd, WM_CLOSE, 0, 0);
  882. return 0;
  883. case HHM_COPY:
  884. phh->m_pCIExpContainer->m_pIE3CmdTarget->Exec(NULL, OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
  885. break;
  886. case HHM_SELECTALL:
  887. phh->m_pCIExpContainer->m_pIE3CmdTarget->Exec(NULL, OLECMDID_SELECTALL, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
  888. break;
  889. case HHM_VIEWSOURCE:
  890. phh->m_pCIExpContainer->m_pIE3CmdTarget->Exec(&CGID_IWebBrowserPriv, HTMLID_VIEWSOURCE, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
  891. break;
  892. case HHM_FIND:
  893. phh->m_pCIExpContainer->m_pIE3CmdTarget->Exec(&CGID_IWebBrowserPriv, HTMLID_FIND, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
  894. break;
  895. case HHM_OPTIONS:
  896. phh->m_pCIExpContainer->m_pIE3CmdTarget->Exec(&CGID_IWebBrowserPriv, HTMLID_OPTIONS, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
  897. break;
  898. case IDTB_OPTIONS:
  899. if ( phh )
  900. doOptionsMenu(phh, hwnd);
  901. break;
  902. case HHM_DEFINE_SUBSET: {
  903. CDefineSS* pDefSSUI = new CDefineSS(GetCurrentCollection(NULL, NULL));
  904. if (pDefSSUI ) {
  905. pDefSSUI->DefineSubset(hwnd, NULL);
  906. delete pDefSSUI;
  907. }
  908. break;
  909. }
  910. case HHM_JUMP_URL:
  911. goto JumpURL;
  912. case HHM_LIB_HELP:
  913. if (!phh)
  914. break;
  915. if (phh->pszUrlJump1)
  916. {
  917. // DONDR: Fix this after VS6 release.
  918. // fix up the URL to point to the correct location of dshelp.. This is a total hack but
  919. // the best fix short of a complete change to the implementation which can't be done
  920. // for VS6
  921. char szURL[MAX_URL], szURL2[MAX_URL];
  922. strcpy(szURL, phh->pszUrlJump1);
  923. char *p = stristr(szURL, ".");
  924. if (p)
  925. {
  926. *p = NULL;
  927. CExTitle *pTitle = phh->m_phmData->m_pTitleCollection->FindTitleNonExact(szURL, 1033);
  928. if (pTitle)
  929. {
  930. strcpy(szURL, (g_bMsItsMonikerSupport ? txtMsItsMoniker : txtMkStore));
  931. strcat(szURL, phh->pszUrlJump1);
  932. pTitle->ConvertURL(szURL, szURL2);
  933. phh->m_pCIExpContainer->m_pWebBrowserApp->Navigate(szURL2, NULL, NULL, NULL, NULL);
  934. break;
  935. }
  936. }
  937. phh->m_pCIExpContainer->m_pWebBrowserApp->Navigate(phh->pszUrlJump1, NULL, NULL, NULL, NULL);
  938. }
  939. break;
  940. case HHM_DEV_ONLINE:
  941. goto jump2;
  942. case HHM_SELECT_ITP:
  943. if ( phh )
  944. {
  945. CChooseSubsets pDlg(hwnd, phh);
  946. pDlg.DoModal();
  947. }
  948. break;
  949. case HHM_DEFINE_ITP:
  950. if ( phh )
  951. {
  952. if (! phh->m_phmData->m_pInfoType )
  953. {
  954. phh->m_phmData->m_pInfoType = new CInfoType();
  955. phh->m_phmData->m_pInfoType->CopyTo( phh->m_phmData );
  956. }
  957. #if 0 // enable for subset filtering
  958. ChooseInformationTypes(phh->m_phmData->m_pInfoType, NULL, hwnd, NULL, phh);
  959. #else
  960. ChooseInformationTypes(phh->m_phmData->m_pInfoType, NULL, hwnd, NULL);
  961. #endif
  962. // If the search tab exists, then update the combo box. Slimy! We need a notification scheme for tabs.
  963. if (phh->m_aNavPane[HH_TAB_SEARCH])
  964. {
  965. CAdvancedSearchNavPane* pSearch = reinterpret_cast<CAdvancedSearchNavPane*>(phh->m_aNavPane[HH_TAB_SEARCH]) ;
  966. pSearch->UpdateSSCombo() ;
  967. }
  968. }
  969. break;
  970. case IDTB_AUTO_SHOW:
  971. if (phh) {
  972. /*
  973. * The user may have clicked the Show button in order
  974. * to activate the window. We want to trap that condition
  975. * so that we don't attempt to expand the window twice.
  976. */
  977. MSG peekmsg;
  978. while (PeekMessage(&peekmsg, hwnd, WM_COMMAND, WM_COMMAND, PM_NOREMOVE)) {
  979. if (LOWORD(peekmsg.wParam) == IDTB_EXPAND)
  980. return 0; // show command already pending
  981. }
  982. while (PeekMessage(&peekmsg, hwnd, WM_SYSCOMMAND, WM_SYSCOMMAND, PM_NOREMOVE)) {
  983. if ( (peekmsg.wParam & 0xFFF0) == SC_MINIMIZE )
  984. return 0;
  985. }
  986. if (phh->fNotExpanded)
  987. phh->ToggleExpansion();
  988. }
  989. break;
  990. #ifdef _DEBUG
  991. case IDTB_NOTES:
  992. if (phh) {
  993. if (phh->OnTrackNotifyCaller(HHACT_NOTES))
  994. break;
  995. if (!phh->m_pNotes)
  996. phh->m_pNotes = new CNotes(phh);
  997. if (phh->m_fNotesWindow)
  998. phh->m_pNotes->HideWindow(); // toggles m_fNotesWindow
  999. else
  1000. phh->m_pNotes->ShowWindow(); // toggles m_fNotesWindow
  1001. }
  1002. break;
  1003. #endif
  1004. default:
  1005. /* Maybe we have a tab selection command */
  1006. if (!phh)
  1007. break;
  1008. // Handle WM_COMMANDS for controls on the tabs...
  1009. //
  1010. if ((LOWORD(wParam) >= IDC_SELECT_TAB_FIRST) && (LOWORD(wParam) <= IDC_SELECT_TAB_LAST))
  1011. {
  1012. phh->doSelectTab(LOWORD(wParam) - IDC_SELECT_TAB_FIRST) ;
  1013. }
  1014. else
  1015. {
  1016. ASSERT(phh->curNavType >=0 && phh->curNavType < c_NUMNAVPANES) ;
  1017. if (phh->m_aNavPane[phh->curNavType])
  1018. {
  1019. phh->m_aNavPane[phh->curNavType]->OnCommand(hwnd, LOWORD(wParam), HIWORD(wParam), lParam);
  1020. }
  1021. }
  1022. break;
  1023. }
  1024. break;
  1025. case WM_NOTIFY:
  1026. ASSERT(::IsValidWindow(hwnd)) ;
  1027. phh = FindWindowIndex(hwnd);
  1028. if (!phh)
  1029. {
  1030. phh = FindWindowIndex(GetParent(hwnd));
  1031. }
  1032. if (phh)
  1033. {
  1034. ASSERT(phh->curNavType >=0 && phh->curNavType < c_NUMNAVPANES) ;
  1035. if (phh->m_aNavPane[phh->curNavType])
  1036. {
  1037. phh->m_aNavPane[phh->curNavType]->OnNotify(hwnd, wParam, lParam);
  1038. }
  1039. }
  1040. #define lpnm ((LPNMHDR)lParam)
  1041. if (lpnm->code == TBN_DROPDOWN)
  1042. {
  1043. doOptionsMenu(phh, hwnd);
  1044. return FALSE;
  1045. }
  1046. if (lpnm->code == TBN_GETINFOTIP && phh && phh->m_fNoToolBarText )
  1047. {
  1048. LPNMTBGETINFOTIP pTip;
  1049. pTip = (LPNMTBGETINFOTIP)lParam;
  1050. lstrcpyn(pTip->pszText, GetStringResource(pTip->iItem), pTip->cchTextMax);
  1051. }
  1052. break;
  1053. case WM_TCARD: // sent by TCard command of the OCX
  1054. phh = FindWindowIndex(hwnd);
  1055. if (phh) {
  1056. PostMessage(phh->hwndCaller, WM_TCARD, wParam, lParam);
  1057. }
  1058. break;
  1059. case WMP_JUMP_TO_URL:
  1060. phh = FindWindowIndex(hwnd);
  1061. if( phh ) {
  1062. // if we have an lParam then init this title
  1063. BOOL bSkipNewNavigate = FALSE;
  1064. if( lParam && !IsBadReadPtr( (void*)lParam, sizeof(PCSTR) ) ) {
  1065. // note if we cannot init the new title then we must abort
  1066. // the navigate below otherwise we get stuck into the infinite
  1067. // PostMessage loop. Also we must display an error message
  1068. // stating that the title could not be located otherwise
  1069. // it will silently fail (since we are skipping the navigate).
  1070. //
  1071. CStr PathName = (PCSTR) lParam;
  1072. if( !AddTitleToGlobalList( PathName ) )
  1073. bSkipNewNavigate = TRUE;
  1074. }
  1075. // if we have a wParam then navigate to this URL
  1076. if( !bSkipNewNavigate && wParam &&
  1077. !IsBadReadPtr( (void*)wParam, sizeof(PCSTR) ) ) {
  1078. phh->m_pCIExpContainer->m_pWebBrowserApp->Navigate(
  1079. (PCSTR) wParam, NULL, NULL, NULL, NULL);
  1080. }
  1081. }
  1082. LocalFree((HLOCAL) wParam);
  1083. if( lParam )
  1084. LocalFree((HLOCAL) lParam);
  1085. break;
  1086. case WMP_GET_CUR_FILE:
  1087. phh = FindWindowIndex(hwnd);
  1088. if (phh && phh->m_phmData) {
  1089. return (LRESULT) phh->m_phmData->GetCompiledFile();
  1090. }
  1091. else
  1092. return 0;
  1093. #if 0
  1094. case WMP_HH_TAB_KEY:
  1095. phh = FindWindowIndex(hwnd);
  1096. ASSERT(phh);
  1097. ASSERT(phh->m_pCIExpContainer);
  1098. phh->m_pCIExpContainer->SetFocus();
  1099. return 0;
  1100. #endif
  1101. case WM_QUERYNEWPALETTE:
  1102. case WM_PALETTECHANGED:
  1103. case WM_SYSCOLORCHANGE:
  1104. case WM_DISPLAYCHANGE:
  1105. case WM_ENTERSIZEMOVE:
  1106. case WM_EXITSIZEMOVE:
  1107. phh = FindWindowIndex(hwnd);
  1108. if (phh && phh->m_pCIExpContainer)
  1109. {
  1110. if ( msg == WM_EXITSIZEMOVE)
  1111. {
  1112. phh->m_pCIExpContainer->SizeIt(0, 0);
  1113. phh->m_pCIExpContainer->SizeIt(RECT_WIDTH(phh->rcHTML), RECT_HEIGHT(phh->rcHTML));
  1114. if ( phh->hwndToolBar )
  1115. {
  1116. // need to force a repaint due to a bug in the IE3.02 comctrl toolbar not
  1117. // repainting buttons on resize when buttons are wrapped to different rows.
  1118. // This is not a perfect fix. The buttons do not show up where they are
  1119. // suppose to be until the size move is completed.
  1120. GetClientRect(phh->hwndToolBar, &phh->rcToolBar);
  1121. InvalidateRect(phh->hwndToolBar, &phh->rcToolBar, TRUE);
  1122. UpdateWindow( phh->hwndToolBar );
  1123. }
  1124. }
  1125. phh->m_pCIExpContainer->ForwardMessage(msg, wParam, lParam);
  1126. }
  1127. return DefWindowProc(hwnd, msg, wParam, lParam);
  1128. break;
  1129. case WM_PAINT:
  1130. if ( (phh = FindHHWindowIndex(hwnd)) )
  1131. {
  1132. HWND hWnd;
  1133. if ( (hWnd = phh->GetToolBarHwnd()) )
  1134. {
  1135. RECT rc;
  1136. POINT pt;
  1137. PAINTSTRUCT ps;
  1138. HDC hdc;
  1139. GetWindowRect(hWnd, &rc); // to figure out Y coordinate.
  1140. pt.x = rc.left;
  1141. pt.y = rc.bottom;
  1142. ScreenToClient(hwnd, &pt);
  1143. GetWindowRect(phh->GetNavigationHwnd(), &rc); // For proper width.
  1144. hdc = BeginPaint(hwnd, &ps);
  1145. QRect(hdc, pt.x, pt.y, RECT_WIDTH(rc) + 5, 1, COLOR_BTNSHADOW); // the +5 is the width of the size bar window.
  1146. QRect(hdc, pt.x, pt.y+1, RECT_WIDTH(rc) + 5, 1, COLOR_BTNHILIGHT);
  1147. EndPaint(hwnd, &ps);
  1148. break;
  1149. }
  1150. }
  1151. /*** Fall Through ***/
  1152. default:
  1153. return DefWindowProc(hwnd, msg, wParam, lParam);
  1154. }
  1155. return 0;
  1156. }
  1157. LRESULT WINAPI ChildWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  1158. {
  1159. CHHWinType* phh;
  1160. if (msg == MSG_MOUSEWHEEL) {
  1161. phh = FindHHWindowIndex(hwnd);
  1162. if (phh)
  1163. return phh->m_pCIExpContainer->ForwardMessage(msg, wParam, lParam);
  1164. return 0;
  1165. }
  1166. switch(msg) {
  1167. case WM_MOUSEACTIVATE:
  1168. phh = FindHHWindowIndex(hwnd);
  1169. if ( phh->m_pCIExpContainer && phh->m_pCIExpContainer->m_hWnd == hwnd )
  1170. {
  1171. phh->m_hwndFocused = hwnd;
  1172. return 0;
  1173. }
  1174. else
  1175. {
  1176. if( phh && phh->m_pTabCtrl && phh->m_pCIExpContainer) {
  1177. phh->m_hwndFocused = phh->m_pTabCtrl->hWnd();
  1178. phh->m_pCIExpContainer->UIDeactivateIE(); // shdocvw is loosing focus need to uideactivate here.
  1179. }
  1180. }
  1181. break;
  1182. case WM_SIZE:
  1183. switch (wParam)
  1184. {
  1185. case SIZE_RESTORED:
  1186. case SIZE_MAXIMIZED:
  1187. case SIZE_MAXSHOW:
  1188. phh = FindHHWindowIndex(hwnd);
  1189. ASSERT(phh);
  1190. if (hwnd == phh->GetNavigationHwnd())
  1191. {
  1192. // This resize is needed when we have only a single nav pane.
  1193. // When we have a single nav pane, we do not have the toolbar ctrl
  1194. // and therefore m_pTabCtrl is null. this does mean that we do not
  1195. // size without the following line...
  1196. ResizeWindow(phh);
  1197. }
  1198. }
  1199. break;
  1200. case WM_NOTIFY:
  1201. ASSERT(::IsValidWindow(hwnd)) ;
  1202. phh = FindWindowIndex(GetParent(hwnd));
  1203. if (phh)
  1204. {
  1205. if ( wParam == IDC_KWD_VLIST )
  1206. {
  1207. phh->m_aNavPane[phh->curNavType]->OnVKListNotify((NMHDR*)lParam);
  1208. break;
  1209. }
  1210. //--- Handle the TAB Control
  1211. else if (wParam == ID_TAB_CONTROL)
  1212. {
  1213. LPNMHDR pNmHdr = (LPNMHDR)lParam;
  1214. int nIndex = phh->GetCurrentNavPaneIndex() ;
  1215. if (nIndex != phh->curNavType)
  1216. {
  1217. // HideWindow
  1218. ASSERT(phh->curNavType >=0 && phh->curNavType < c_NUMNAVPANES) ;
  1219. if (phh->m_aNavPane[phh->curNavType])
  1220. {
  1221. phh->m_aNavPane[phh->curNavType]->HideWindow();
  1222. }
  1223. phh->curNavType = nIndex;
  1224. // Create the new pane if required.
  1225. phh->CreateNavPane(phh->curNavType) ;
  1226. ASSERT(phh->curNavType >=0 && phh->curNavType < c_NUMNAVPANES) ;
  1227. if (phh->m_aNavPane[phh->curNavType])
  1228. {
  1229. phh->m_aNavPane[phh->curNavType]->ResizeWindow();
  1230. phh->m_aNavPane[phh->curNavType]->ShowWindow();
  1231. phh->m_aNavPane[phh->curNavType]->SetDefaultFocus() ;
  1232. }
  1233. }
  1234. break;
  1235. }
  1236. else
  1237. {
  1238. // If its not the tab control forward the messages to the panes.
  1239. ASSERT(phh->curNavType >=0 && phh->curNavType < c_NUMNAVPANES) ;
  1240. if (phh->m_aNavPane[phh->curNavType ])
  1241. {
  1242. ASSERT(phh->curNavType >=0 && phh->curNavType < c_NUMNAVPANES) ;
  1243. if (phh->m_aNavPane[phh->curNavType])
  1244. phh->m_aNavPane[phh->curNavType]->OnNotify(hwnd, wParam, lParam) ;
  1245. }
  1246. }
  1247. }
  1248. else { // couldn't find parent, how about parent's parent
  1249. phh = FindWindowIndex(GetParent(GetParent(hwnd)));
  1250. if (phh)
  1251. {
  1252. ASSERT(phh->curNavType >=0 && phh->curNavType < c_NUMNAVPANES) ;
  1253. if (phh->m_aNavPane[phh->curNavType])
  1254. {
  1255. phh->m_aNavPane[phh->curNavType]->OnNotify(hwnd, wParam, lParam) ;
  1256. }
  1257. }
  1258. }
  1259. break;
  1260. case WM_COMMAND:
  1261. //BUG:[paulde]Might need to make A/W call that matches THIS window's A/W type
  1262. return SendMessage(GetParent(hwnd), msg, wParam, lParam);
  1263. case WM_DRAWITEM:
  1264. phh = FindWindowIndex(GetParent(hwnd));
  1265. if (phh->curNavType == HHWIN_NAVTYPE_INDEX && phh->m_aNavPane[HH_TAB_INDEX])
  1266. {
  1267. phh->m_aNavPane[HH_TAB_INDEX]->OnDrawItem((UINT)wParam, (LPDRAWITEMSTRUCT) lParam);
  1268. }
  1269. break;
  1270. case WM_KEYDOWN:
  1271. /*
  1272. * We only want to process VK_ESCAPE on the down-key, because when
  1273. * you press ESCAPE in a dialog box, the down key cancels the dialog
  1274. * box, and then the Up key gets passed through to the app.
  1275. */
  1276. if (wParam == VK_ESCAPE) {
  1277. PostMessage(GetParent(hwnd), WM_CLOSE, 0, 0);
  1278. return 0;
  1279. }
  1280. return DefWindowProc(hwnd, msg, wParam, lParam);
  1281. case WM_PAINT: //TODO: Make a class for the navigation window.
  1282. phh = FindHHWindowIndex(hwnd);
  1283. if (phh && hwnd == phh->GetNavigationHwnd() && ::IsWindow(hwnd))
  1284. {
  1285. PAINTSTRUCT ps;
  1286. HDC hdc = BeginPaint(hwnd, &ps) ;
  1287. DrawNavWnd(hwnd) ;
  1288. EndPaint(hwnd, &ps) ;
  1289. break ;
  1290. }
  1291. /*** Fall Through ***/
  1292. default:
  1293. if (IsWindowUnicode(hwnd))
  1294. return DefWindowProcW(hwnd, msg, wParam, lParam);
  1295. else
  1296. return DefWindowProcA(hwnd, msg, wParam, lParam);
  1297. }
  1298. return 0;
  1299. }
  1300. static void UpdateSearchHiMenu(CHHWinType* phh, TBBUTTON * tbbtn)
  1301. {
  1302. MENUITEMINFO mii;
  1303. CStr cszMenuItem;
  1304. if ( phh && phh->m_phmData && phh->m_phmData->m_pTitleCollection &&
  1305. phh->m_phmData->m_pTitleCollection->m_pSearchHighlight &&
  1306. phh->m_phmData->m_pTitleCollection->m_pSearchHighlight->m_bHighlightEnabled )
  1307. { // its currently on; turn it off
  1308. cszMenuItem = GetStringResource( IDS_OPTION_HILITING_OFF );// the string to display for the menu item
  1309. }
  1310. else
  1311. { // its currently off; turn it on.
  1312. cszMenuItem = GetStringResource( IDS_OPTION_HILITING_ON );// the string to display for the menu item
  1313. }
  1314. ZERO_STRUCTURE ( mii );
  1315. mii.cbSize = sizeof(MENUITEMINFO);
  1316. mii.fMask = MIIM_TYPE;
  1317. mii.fType = MFT_STRING;
  1318. mii.hSubMenu = NULL;
  1319. mii.hbmpChecked = NULL; // bitmap to display when checked
  1320. mii.hbmpUnchecked = NULL; // bitmap to display when not checked
  1321. mii.dwItemData = NULL; // data associated with the menu item
  1322. mii.dwTypeData = cszMenuItem.psz;
  1323. mii.cch = (ULONG)strlen( mii.dwTypeData ); // length of the string.
  1324. if(g_bWinNT5)
  1325. {
  1326. DWORD cp = CodePageFromLCID(MAKELCID(_Module.m_Language.GetUiLanguage(),SORT_DEFAULT));
  1327. DWORD dwSize = (sizeof(WCHAR) * mii.cch) + 4;
  1328. WCHAR *pwcString = (WCHAR *) lcMalloc(dwSize);
  1329. if(!pwcString)
  1330. return;
  1331. MultiByteToWideChar(cp, MB_PRECOMPOSED, cszMenuItem.psz, -1, pwcString, dwSize);
  1332. mii.dwTypeData = (char *) pwcString;
  1333. SetMenuItemInfoW((HMENU)tbbtn->dwData, IDTB_HILITE, FALSE,(LPMENUITEMINFOW) &mii);
  1334. lcFree(pwcString);
  1335. }
  1336. else
  1337. SetMenuItemInfo((HMENU)tbbtn->dwData, IDTB_HILITE, FALSE, &mii);
  1338. return;
  1339. }
  1340. static void doOptionsMenu(CHHWinType* phh, HWND hwnd)
  1341. {
  1342. TBBUTTON tbbtn;
  1343. POINT pt;
  1344. RECT rcBtn;
  1345. WPARAM btn_index;
  1346. DWORD dwErr;
  1347. #define lpnm ((LPNMHDR)lParam)
  1348. #define lpnmTB ((LPNMTOOLBAR)lParam)
  1349. if (phh && phh->hwndToolBar) {
  1350. btn_index = SendMessage(phh->hwndToolBar, TB_COMMANDTOINDEX, IDTB_OPTIONS, 0L);
  1351. SendMessage(phh->hwndToolBar, TB_GETBUTTON, btn_index, (LPARAM) (LPTBBUTTON) &tbbtn);
  1352. if (!SendMessage(phh->hwndToolBar, TB_GETITEMRECT, btn_index, (LPARAM) (LPRECT) &rcBtn))
  1353. return;
  1354. if (tbbtn.dwData) {
  1355. if(g_bWinNT5)
  1356. {
  1357. if (!phh->IsExpandedNavPane())
  1358. ModifyMenuW((HMENU)tbbtn.dwData,
  1359. 0, MF_BYPOSITION | MF_STRING, IDTB_EXPAND,
  1360. GetStringResourceW(IDS_OPTION_SHOW));
  1361. else
  1362. ModifyMenuW((HMENU)tbbtn.dwData,
  1363. 0, MF_BYPOSITION | MF_STRING, IDTB_CONTRACT,
  1364. GetStringResourceW(IDS_OPTION_HIDE));
  1365. }
  1366. else
  1367. {
  1368. if (!phh->IsExpandedNavPane())
  1369. ModifyMenu((HMENU)tbbtn.dwData,
  1370. 0, MF_BYPOSITION | MF_STRING, IDTB_EXPAND,
  1371. GetStringResource(IDS_OPTION_SHOW));
  1372. else
  1373. ModifyMenu((HMENU)tbbtn.dwData,
  1374. 0, MF_BYPOSITION | MF_STRING, IDTB_CONTRACT,
  1375. GetStringResource(IDS_OPTION_HIDE));
  1376. }
  1377. UpdateSearchHiMenu(phh, &tbbtn);
  1378. EnableMenuItem((HMENU)tbbtn.dwData, IDTB_CUSTOMIZE, MF_BYCOMMAND | MF_ENABLED);
  1379. // ASSERT(phh->m_aNavPane[HH_TAB_CONTENTS]) ;
  1380. if( phh && phh->m_aNavPane[HH_TAB_CONTENTS] ) {
  1381. CToc* ptoc = reinterpret_cast<CToc*>(phh->m_aNavPane[HH_TAB_CONTENTS]) ; // HACKHACK: Should use dynamic cast, but no RTTI.
  1382. if ((phh->curNavType == HHWIN_NAVTYPE_TOC) &&
  1383. (!ptoc || (ptoc->m_pInfoType->HowManyInfoTypes() <= 0) ||
  1384. (ptoc->m_pInfoType->GetFirstHidden() == 1)))
  1385. EnableMenuItem((HMENU) tbbtn.dwData, IDTB_CUSTOMIZE, MF_BYCOMMAND | MF_GRAYED);
  1386. else if (phh->curNavType == HHWIN_NAVTYPE_INDEX)
  1387. EnableMenuItem((HMENU) tbbtn.dwData, IDTB_CUSTOMIZE, MF_BYCOMMAND | MF_GRAYED);
  1388. else if (phh->curNavType == HHWIN_NAVTYPE_SEARCH)
  1389. EnableMenuItem((HMENU) tbbtn.dwData, IDTB_CUSTOMIZE, MF_BYCOMMAND | MF_GRAYED);
  1390. }
  1391. pt.x = pt.y = 0;
  1392. ScreenToClient(phh->hwndHelp, &pt);
  1393. if ( !TrackPopupMenu((HMENU)tbbtn.dwData,
  1394. TPM_LEFTALIGN|TPM_TOPALIGN|TPM_LEFTBUTTON|TPM_NONOTIFY,
  1395. rcBtn.left-pt.x, rcBtn.bottom-pt.y, 0, hwnd, NULL) )
  1396. dwErr = GetLastError();
  1397. }
  1398. }
  1399. }
  1400. void ResizeWindow(CHHWinType* phh, bool bRecalcHtmlFrame /*=true*/)
  1401. {
  1402. if (phh) // Needs to be valid.
  1403. {
  1404. if (phh->hwndHTML)
  1405. {
  1406. if (bRecalcHtmlFrame)
  1407. {
  1408. phh->CalcHtmlPaneRect(); // Don't recalc if the sizebar is calling us. See sizebar.cpp
  1409. }
  1410. MoveWindow(phh->hwndHTML, phh->rcHTML.left,
  1411. phh->rcHTML.top, RECT_WIDTH(phh->rcHTML),
  1412. RECT_HEIGHT(phh->rcHTML), TRUE);
  1413. if (phh->m_pCIExpContainer)
  1414. phh->m_pCIExpContainer->SizeIt(RECT_WIDTH(phh->rcHTML), RECT_HEIGHT(phh->rcHTML));
  1415. }
  1416. if (phh->GetNavigationHwnd() && // Have to have the navigation window to have any of the other stuff.
  1417. phh->IsExpandedNavPane()) // Should be expanded.
  1418. {
  1419. // Move the nav pane.
  1420. MoveWindow( phh->hwndNavigation, phh->rcNav.left,
  1421. phh->rcNav.top, RECT_WIDTH(phh->rcNav),
  1422. RECT_HEIGHT(phh->rcNav), TRUE);
  1423. if ( phh->m_hWndSSCB )
  1424. {
  1425. RECT rcST, rcTB, rcCB;
  1426. int iTop;
  1427. GetClientRect(phh->m_hWndST, &rcST);
  1428. GetClientRect(phh->GetToolBarHwnd(), &rcTB);
  1429. GetClientRect(phh->m_hWndSSCB, &rcCB);
  1430. iTop = rcTB.bottom + 5;
  1431. SetWindowPos(phh->m_hWndST, NULL, phh->rcNav.left+6, iTop, RECT_WIDTH(phh->rcNav)-8, RECT_HEIGHT(rcST), SWP_NOZORDER);
  1432. iTop += RECT_HEIGHT(rcST) + 2;
  1433. SetWindowPos(phh->m_hWndSSCB, NULL, phh->rcNav.left+6, iTop, RECT_WIDTH(phh->rcNav)-8, RECT_HEIGHT(rcCB), SWP_NOZORDER);
  1434. InvalidateRect(phh->m_hWndST, NULL, FALSE);
  1435. InvalidateRect(phh->m_hWndSSCB, NULL, FALSE);
  1436. }
  1437. // If we have a tab control let's make sure to resize those as well.
  1438. if (phh->m_pTabCtrl)
  1439. {
  1440. phh->m_pTabCtrl->ResizeWindow() ;
  1441. }
  1442. // Now resize the controls on the pane.
  1443. ASSERT(phh->curNavType >=0 && phh->curNavType < c_NUMNAVPANES);
  1444. if (phh->m_aNavPane[phh->curNavType])
  1445. {
  1446. phh->m_aNavPane[phh->curNavType]->ResizeWindow();
  1447. }
  1448. // Finally, resize the sizebar if we have one of them.
  1449. if (phh->m_pSizeBar)
  1450. {
  1451. phh->m_pSizeBar->ResizeWindow() ;
  1452. }
  1453. }
  1454. }
  1455. }
  1456. BOOL CHHWinType::OnTrackNotifyCaller(int idAction)
  1457. {
  1458. if (idNotify && m_pCIExpContainer && m_pCIExpContainer->m_pWebBrowserApp)
  1459. {
  1460. HHNTRACK hhtrack;
  1461. ZeroMemory(&hhtrack, sizeof(HHNTRACK));
  1462. hhtrack.hdr.hwndFrom = hwndHelp;
  1463. hhtrack.hdr.idFrom = idNotify;
  1464. hhtrack.hdr.code = HHN_TRACK;
  1465. CStr cszUrl;
  1466. m_pCIExpContainer->m_pWebBrowserApp->GetLocationURL(&cszUrl);
  1467. hhtrack.pszCurUrl = cszUrl.psz;
  1468. hhtrack.idAction = idAction;
  1469. hhtrack.phhWinType = (HH_WINTYPE*) this;
  1470. if (IsWindow(hwndCaller))
  1471. {
  1472. return SendMessage(hwndCaller, WM_NOTIFY, idNotify, (LPARAM) &hhtrack)!=0;
  1473. }
  1474. }
  1475. return FALSE;
  1476. }
  1477. //////////////////////////////////////////////////////////////////////////
  1478. //
  1479. // WM_APPCOMMAND
  1480. //
  1481. LRESULT OnAppCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
  1482. {
  1483. switch (GET_APPCOMMAND_LPARAM(lParam))
  1484. {
  1485. case APPCOMMAND_BROWSER_BACKWARD:
  1486. SendMessage(hwnd, WM_COMMAND, MAKELONG(IDTB_BACK, 0), NULL);
  1487. return 1;
  1488. case APPCOMMAND_BROWSER_FORWARD:
  1489. SendMessage(hwnd, WM_COMMAND, MAKELONG(IDTB_FORWARD, 0), NULL);
  1490. return 1;
  1491. case APPCOMMAND_BROWSER_REFRESH:
  1492. SendMessage(hwnd, WM_COMMAND, MAKELONG(IDTB_REFRESH, 0), NULL);
  1493. return 1;
  1494. case APPCOMMAND_BROWSER_STOP:
  1495. SendMessage(hwnd, WM_COMMAND, MAKELONG(IDTB_STOP, 0), NULL);
  1496. return 1;
  1497. case APPCOMMAND_BROWSER_HOME:
  1498. SendMessage(hwnd, WM_COMMAND, MAKELONG(IDTB_HOME, 0), NULL);
  1499. return 1;
  1500. case APPCOMMAND_BROWSER_SEARCH:
  1501. SendMessage(hwnd, WM_COMMAND, MAKELONG(HHM_SEARCH, 0), NULL);
  1502. return 1;
  1503. case APPCOMMAND_BROWSER_FAVORITES:
  1504. SendMessage(hwnd, WM_COMMAND, MAKELONG(HHM_FAVORITES, 0), NULL);
  1505. return 1;
  1506. }
  1507. return 0;
  1508. }
  1509. //////////////////////////////////////////////////////////////////////////
  1510. //
  1511. // WM_KEYDOWN Handler
  1512. //
  1513. LRESULT OnKeyDown(HWND hwnd, WPARAM wParam, LPARAM lParam)
  1514. {
  1515. switch(wParam)
  1516. {
  1517. case VK_ESCAPE:
  1518. /*
  1519. * We only want to process VK_ESCAPE on the down-key, because when
  1520. * you press ESCAPE in a dialog box, the down key cancels the dialog
  1521. * box, and then the Up key gets passed through to the app.
  1522. */
  1523. {
  1524. CHHWinType* phh = FindWindowIndex(hwnd);
  1525. if (phh && (phh->dwStyles & WS_CHILD))
  1526. {
  1527. // Don't process the ESC key if we are a child/embedded window.
  1528. return 0 ;
  1529. }
  1530. PostMessage(hwnd, WM_CLOSE, 0, 0);
  1531. return 0;
  1532. }
  1533. /*
  1534. case VK_NEXT:
  1535. // Never reached
  1536. return 0 ;
  1537. */
  1538. default:
  1539. return DefWindowProc(hwnd, WM_KEYDOWN, wParam, lParam);
  1540. }
  1541. }
  1542. //////////////////////////////////////////////////////////////////////////
  1543. //
  1544. // Draws the edge to the upper part of the navigation frame window.
  1545. //
  1546. void DrawNavWnd(HWND hWnd)
  1547. {
  1548. // Get a dc to draw in.
  1549. HDC hdc = GetDC(hWnd) ;
  1550. // get the rectangle to draw on.
  1551. RECT rc ;
  1552. GetClientRect(hWnd, &rc) ;
  1553. // Draw the edge.
  1554. DrawEdge(hdc, &rc, EDGE_ETCHED, BF_TOP) ;
  1555. // Clean up.
  1556. ReleaseDC(hWnd, hdc) ;
  1557. }