static LRESULT CALLBACK PopupChild_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_NOTIFY: { NMHDR *nmhdr = (NMHDR*)lParam; switch(nmhdr->code) { case NM_DBLCLK: { HHInfo *info = (HHInfo*)GetWindowLongPtrW(hWnd, GWLP_USERDATA); IndexSubItem *iter; if(info == 0 || lParam == 0) return 0; iter = (IndexSubItem*) ((NMITEMACTIVATE *)lParam)->lParam; if(iter == 0) return 0; NavigateToChm(info, info->index->merge.chm_file, iter->local); ShowWindow(info->popup.hwndPopup, SW_HIDE); return 0; } case NM_RETURN: { HHInfo *info = (HHInfo*)GetWindowLongPtrW(hWnd, GWLP_USERDATA); IndexSubItem *iter; LVITEMW lvItem; if(info == 0) return 0; lvItem.iItem = (int) SendMessageW(info->popup.hwndList, LVM_GETSELECTIONMARK, 0, 0); lvItem.mask = TVIF_PARAM; SendMessageW(info->popup.hwndList, LVM_GETITEMW, 0, (LPARAM)&lvItem); iter = (IndexSubItem*) lvItem.lParam; NavigateToChm(info, info->index->merge.chm_file, iter->local); ShowWindow(info->popup.hwndPopup, SW_HIDE); return 0; } } break; } default: return DefWindowProcW(hWnd, message, wParam, lParam); } return 0; }
static void TB_OnClick(HWND hWnd, DWORD dwID) { HHInfo *info = (HHInfo *)GetWindowLongPtrW(hWnd, GWLP_USERDATA); switch (dwID) { case IDTB_STOP: DoPageAction(info, WB_STOP); break; case IDTB_REFRESH: DoPageAction(info, WB_REFRESH); break; case IDTB_BACK: DoPageAction(info, WB_GOBACK); break; case IDTB_HOME: NavigateToChm(info, info->pCHMInfo->szFile, info->WinType.pszHome); break; case IDTB_FORWARD: DoPageAction(info, WB_GOFORWARD); break; case IDTB_PRINT: DoPageAction(info, WB_PRINT); break; case IDTB_EXPAND: case IDTB_CONTRACT: ExpandContract(info); break; case IDTB_SYNC: DoSync(info); break; case IDTB_OPTIONS: DisplayPopupMenu(info); break; case IDTB_NOTES: case IDTB_CONTENTS: case IDTB_INDEX: case IDTB_SEARCH: case IDTB_HISTORY: case IDTB_FAVORITES: /* These are officially unimplemented as of the Windows 7 SDK */ break; 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; } }
static void TB_OnClick(HWND hWnd, DWORD dwID) { HHInfo *info = (HHInfo *)GetWindowLongPtrW(hWnd, GWLP_USERDATA); switch (dwID) { case IDTB_STOP: DoPageAction(info, WB_STOP); break; case IDTB_REFRESH: DoPageAction(info, WB_REFRESH); break; case IDTB_BACK: DoPageAction(info, WB_GOBACK); break; case IDTB_HOME: NavigateToChm(info, info->pCHMInfo->szFile, info->WinType.pszHome); break; case IDTB_FORWARD: DoPageAction(info, WB_GOFORWARD); 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; } }
BOOL NavigateToUrl(HHInfo *info, LPCWSTR surl) { ChmPath chm_path; BOOL ret; HRESULT hres; static const WCHAR url_indicator[] = {':', '/', '/', 0}; 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 */ SetChmPath(&chm_path, info->pCHMInfo->szFile, surl); ret = NavigateToChm(info, chm_path.chm_file, chm_path.chm_index); heap_free(chm_path.chm_file); heap_free(chm_path.chm_index); return ret; }
static LRESULT OnTopicChange(HHInfo *info, void *user_data) { LPCWSTR chmfile = NULL, name = NULL, local = NULL; ContentItem *citer; SearchItem *siter; IndexItem *iiter; if(!user_data || !info) return 0; switch (info->current_tab) { case TAB_CONTENTS: citer = (ContentItem *) user_data; name = citer->name; local = citer->local; while(citer) { if(citer->merge.chm_file) { chmfile = citer->merge.chm_file; break; } citer = citer->parent; } break; case TAB_INDEX: iiter = (IndexItem *) user_data; if(iiter->nItems == 0) { FIXME("No entries for this item!\n"); return 0; } if(iiter->nItems > 1) { int i = 0; LVITEMW lvi; SendMessageW(info->popup.hwndList, LVM_DELETEALLITEMS, 0, 0); for(i=0;i<iiter->nItems;i++) { IndexSubItem *item = &iiter->items[i]; WCHAR *name = iiter->keyword; if(item->name) name = item->name; memset(&lvi, 0, sizeof(lvi)); lvi.iItem = i; lvi.mask = LVIF_TEXT|LVIF_PARAM; lvi.cchTextMax = strlenW(name)+1; lvi.pszText = name; lvi.lParam = (LPARAM) item; SendMessageW(info->popup.hwndList, LVM_INSERTITEMW, 0, (LPARAM)&lvi); } ShowWindow(info->popup.hwndPopup, SW_SHOW); return 0; } name = iiter->items[0].name; local = iiter->items[0].local; chmfile = iiter->merge.chm_file; break; case TAB_SEARCH: siter = (SearchItem *) user_data; name = siter->filename; local = siter->filename; chmfile = info->pCHMInfo->szFile; break; default: FIXME("Unhandled operation for this tab!\n"); return 0; } if(!chmfile) { FIXME("No help file found for this item!\n"); return 0; } TRACE("name %s loal %s\n", debugstr_w(name), debugstr_w(local)); NavigateToChm(info, chmfile, local); return 0; }
/****************************************************************** * HtmlHelpW (HHCTRL.OCX.15) */ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR data) { WCHAR fullname[MAX_PATH]; TRACE("(%p, %s, command=%s, data=%lx)\n", caller, debugstr_w( filename ), command_to_string( command ), data); switch (command) { case HH_DISPLAY_TOPIC: case HH_DISPLAY_TOC: case HH_DISPLAY_SEARCH:{ static const WCHAR delimW[] = {':',':',0}; HHInfo *info; BOOL res; WCHAR chm_file[MAX_PATH]; const WCHAR *index; FIXME("Not all HH cases handled correctly\n"); if (!filename) return NULL; index = strstrW(filename, delimW); if (index) { memcpy(chm_file, filename, (index-filename)*sizeof(WCHAR)); chm_file[index-filename] = 0; filename = chm_file; index += 2; /* advance beyond "::" for calling NavigateToChm() later */ } if (!resolve_filename(filename, fullname, MAX_PATH)) { WARN("can't find %s\n", debugstr_w(filename)); return 0; } info = CreateHelpViewer(fullname); if(!info) return NULL; if(!index) index = info->WinType.pszFile; res = NavigateToChm(info, info->pCHMInfo->szFile, index); if(!res) { ReleaseHelpViewer(info); return NULL; } return info->WinType.hwndHelp; } case HH_HELP_CONTEXT: { HHInfo *info; LPWSTR url; if (!filename) return NULL; if (!resolve_filename(filename, fullname, MAX_PATH)) { WARN("can't find %s\n", debugstr_w(filename)); return 0; } info = CreateHelpViewer(fullname); if(!info) return NULL; url = FindContextAlias(info->pCHMInfo, data); if(!url) { ReleaseHelpViewer(info); return NULL; } NavigateToUrl(info, url); heap_free(url); return info->WinType.hwndHelp; } case HH_PRETRANSLATEMESSAGE: { static BOOL warned = FALSE; if (!warned) { FIXME("HH_PRETRANSLATEMESSAGE unimplemented\n"); warned = TRUE; } return 0; } default: FIXME("HH case %s not handled.\n", command_to_string( command )); } return 0; }