bool CUpgradrToolbar::OnDisableDropdown(LPNMTOOLBAR data) { RECT rect; m_kToolbar.SendMessage(TB_GETRECT, data->iItem, reinterpret_cast<LPARAM>(&rect)); m_kToolbar.MapWindowPoints(HWND_DESKTOP, reinterpret_cast<LPPOINT>(&rect), 2); TPMPARAMS tpm; tpm.cbSize = sizeof(tpm); tpm.rcExclude = rect; CMenu menu; menu.LoadMenu(MAKEINTRESOURCE(IDR_DISABLEMENU)); if (menu.IsNull()) throw CUpgradrWindowsError(GetLastError()); ScriptManagerLock scriptManager; MENUITEMINFO mii = { sizeof(MENUITEMINFO) }; UINT pos = 0; UINT uID = 1000; CMenuHandle popupMenu = menu.GetSubMenu(0); if (popupMenu.IsNull()) throw CUpgradrWindowsError(GetLastError()); CScriptManager::iterator i = scriptManager->begin(); while (i!=scriptManager->end()) { CScript* script = i->second; memset(&mii, 0, sizeof(MENUITEMINFO)); mii.cbSize = sizeof(MENUITEMINFO); mii.fMask = MIIM_STATE | MIIM_STRING | MIIM_ID | MIIM_DATA; mii.wID = uID++; mii.fState = MFS_CHECKED; mii.dwItemData = i->first; TCHAR buf[1024]; _tcscpy_s(buf, 1024, script->Name()); mii.dwTypeData = buf; InsertMenuItem(popupMenu, pos++, TRUE, &mii); ++i; } TrackPopupMenuEx(popupMenu, TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_VERTICAL, rect.left, rect.bottom, m_kToolbar, &tpm); return true; }
bool CXRefreshToolbar::OnGeneralDropdown(LPNMTOOLBAR data) { RECT rect; m_Toolbar.SendMessage(TB_GETRECT, data->iItem, reinterpret_cast<LPARAM>(&rect)); m_Toolbar.MapWindowPoints(HWND_DESKTOP, reinterpret_cast<LPPOINT>(&rect), 2); TPMPARAMS tpm; tpm.cbSize = sizeof(tpm); tpm.rcExclude = rect; CMenu menu; menu.LoadMenu(MAKEINTRESOURCE(IDR_TOOLMENU)); if (menu.IsNull()) throw CXRefreshWindowsError(GetLastError()); CMenuHandle popupMenu = menu.GetSubMenu(0); if (popupMenu.IsNull()) throw CXRefreshWindowsError(GetLastError()); TrackPopupMenuEx(popupMenu, TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_VERTICAL, rect.left, rect.bottom, m_Toolbar, &tpm); return true; }