static void DisplayPopupMenu(HHInfo *info) { HMENU menu, submenu; TBBUTTONINFOW button; MENUITEMINFOW item; POINT coords; RECT rect; DWORD index; menu = LoadMenuW(hhctrl_hinstance, MAKEINTRESOURCEW(MENU_POPUP)); if (!menu) return; submenu = GetSubMenu(menu, 0); /* Update the Show/Hide menu item */ item.cbSize = sizeof(MENUITEMINFOW); item.fMask = MIIM_FTYPE | MIIM_STATE | MIIM_STRING; item.fType = MFT_STRING; item.fState = MF_ENABLED; if (info->WinType.fNotExpanded) item.dwTypeData = HH_LoadString(IDS_SHOWTABS); else item.dwTypeData = HH_LoadString(IDS_HIDETABS); SetMenuItemInfoW(submenu, IDTB_EXPAND, FALSE, &item); heap_free(item.dwTypeData); /* Find the index toolbar button */ button.cbSize = sizeof(TBBUTTONINFOW); button.dwMask = TBIF_COMMAND; index = SendMessageW(info->WinType.hwndToolBar, TB_GETBUTTONINFOW, IDTB_OPTIONS, (LPARAM) &button); if (index == -1) return; /* Get position */ SendMessageW(info->WinType.hwndToolBar, TB_GETITEMRECT, index, (LPARAM) &rect); coords.x = rect.left; coords.y = rect.bottom; ClientToScreen(info->WinType.hwndToolBar, &coords); TrackPopupMenu(submenu, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_LEFTBUTTON | TPM_NOANIMATION, coords.x, coords.y, 0, info->WinType.hwndHelp, NULL); }
static BOOL HH_AddToolbar(HHInfo *pHHInfo) { HWND hToolbar; HWND hwndParent = pHHInfo->WinType.hwndHelp; DWORD toolbarFlags; TBBUTTON buttons[IDTB_TOC_PREV - IDTB_EXPAND]; TBADDBITMAP tbAB; DWORD dwStyles, dwExStyles; DWORD dwNumButtons, dwIndex; if (pHHInfo->WinType.fsWinProperties & HHWIN_PARAM_TB_FLAGS) toolbarFlags = pHHInfo->WinType.fsToolBarFlags; else toolbarFlags = HHWIN_DEF_BUTTONS; 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, hhctrl_hinstance, NULL); 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); szBuf[dwLen + 1] = 0; /* Double-null terminate */ buttons[dwIndex].iString = (DWORD)SendMessageW(hToolbar, TB_ADDSTRINGW, 0, (LPARAM)szBuf); heap_free(szBuf); } SendMessageW(hToolbar, TB_ADDBUTTONSW, dwNumButtons, (LPARAM)buttons); SendMessageW(hToolbar, TB_AUTOSIZE, 0, 0); ShowWindow(hToolbar, SW_SHOW); pHHInfo->WinType.hwndToolBar = hToolbar; return TRUE; }
static DWORD NP_CreateTab(HINSTANCE hInstance, HWND hwndTabCtrl, DWORD index) { TCITEMW tie; LPWSTR tabText = HH_LoadString(index); DWORD ret; tie.mask = TCIF_TEXT; tie.pszText = tabText; ret = SendMessageW( hwndTabCtrl, TCM_INSERTITEMW, index, (LPARAM)&tie ); heap_free(tabText); return ret; }