本文整理汇总了C++中TrackPopupMenuEx函数的典型用法代码示例。如果您正苦于以下问题:C++ TrackPopupMenuEx函数的具体用法?C++ TrackPopupMenuEx怎么用?C++ TrackPopupMenuEx使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TrackPopupMenuEx函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: screenPt
void CtrlBreakpointList::showBreakpointMenu(int itemIndex, const POINT &pt)
{
POINT screenPt(pt);
ClientToScreen(wnd, &screenPt);
bool isMemory;
int index = getBreakpointIndex(itemIndex, isMemory);
if (index == -1)
{
HMENU subMenu = GetSubMenu(g_hPopupMenus, POPUP_SUBMENU_ID_NEWBREAKPOINT);
switch (TrackPopupMenuEx(subMenu, TPM_RIGHTBUTTON | TPM_RETURNCMD, screenPt.x, screenPt.y, wnd, 0))
{
case ID_DISASM_ADDNEWBREAKPOINT:
{
BreakpointWindow bpw(wnd,cpu);
if (bpw.exec()) bpw.addBreakpoint();
}
break;
}
} else {
MemCheck mcPrev;
BreakPoint bpPrev;
if (isMemory) {
mcPrev = displayedMemChecks_[index];
} else {
bpPrev = displayedBreakPoints_[index];
}
HMENU subMenu = GetSubMenu(g_hPopupMenus, POPUP_SUBMENU_ID_BREAKPOINTLIST);
if (isMemory) {
CheckMenuItem(subMenu, ID_DISASM_DISABLEBREAKPOINT, MF_BYCOMMAND | (mcPrev.result & MEMCHECK_BREAK ? MF_CHECKED : MF_UNCHECKED));
} else {
CheckMenuItem(subMenu, ID_DISASM_DISABLEBREAKPOINT, MF_BYCOMMAND | (bpPrev.enabled ? MF_CHECKED : MF_UNCHECKED));
}
switch (TrackPopupMenuEx(subMenu, TPM_RIGHTBUTTON | TPM_RETURNCMD, screenPt.x, screenPt.y, wnd, 0))
{
case ID_DISASM_DISABLEBREAKPOINT:
if (isMemory) {
CBreakPoints::ChangeMemCheck(mcPrev.start, mcPrev.end, mcPrev.cond, MemCheckResult(mcPrev.result ^ MEMCHECK_BREAK));
} else {
CBreakPoints::ChangeBreakPoint(bpPrev.addr, !bpPrev.enabled);
}
break;
case ID_DISASM_EDITBREAKPOINT:
editBreakpoint(index);
break;
case ID_DISASM_ADDNEWBREAKPOINT:
{
BreakpointWindow bpw(wnd,cpu);
if (bpw.exec()) bpw.addBreakpoint();
}
break;
}
}
}
示例2: PopUpMenu
int PopUpMenu(const MenuVec &menu_items, int selected_index, const void *hwnd)
{
HMENU menu = CreatePopupMenu();
if(menu)
{
for(int i=0; i < menu_items.size(); i++)
{
std::string label = menu_items[i];
UINT flags = (i == selected_index ? (MF_STRING | MF_CHECKED) : MF_STRING);
if(label == "(-")
{
flags |= MF_SEPARATOR;
}
else if(label == "$OCIO")
{
char *file = std::getenv("OCIO");
if(file == NULL)
flags |= MF_GRAYED;
}
else if(label == "(nada)")
{
flags |= MF_GRAYED;
char appdata_path[MAX_PATH];
HRESULT result = SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL,
SHGFP_TYPE_CURRENT, appdata_path);
if(result == S_OK)
{
label = "No configs in " + std::string(appdata_path) + "\\OpenColorIO\\";
}
}
AppendMenu(menu, flags, i + 1, label.c_str());
}
POINT pos;
GetCursorPos(&pos);
int result = TrackPopupMenuEx(menu,
(TPM_NONOTIFY | TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RETURNCMD),
pos.x, pos.y, (HWND)hwnd, NULL);
DestroyMenu(menu);
if(result == 0)
{
// means the user clicked off the menu
return selected_index;
}
else
return result - 1;
}
else
return selected_index;
}
示例3: GetCursorPos
void CtrlMemView::onMouseUp(WPARAM wParam, LPARAM lParam, int button)
{
if (button==2)
{
//popup menu?
POINT pt;
GetCursorPos(&pt);
switch (TrackPopupMenuEx(GetSubMenu(g_hPopupMenus,0),TPM_RIGHTBUTTON|TPM_RETURNCMD,pt.x,pt.y,wnd,0))
{
case ID_MEMVIEW_DUMP:
MessageBox(wnd,"This feature has not been implemented.","Sorry",0);
break;
case ID_MEMVIEW_COPYVALUE:
{
char temp[24];
sprintf(temp,"%08x",Memory::ReadUnchecked_U32(selection));
W32Util::CopyTextToClipboard(wnd,temp);
}
break;
}
return;
}
int x = LOWORD(lParam);
int y = HIWORD(lParam);
if (x>16)
{
curAddress=yToAddress(y);
selecting=false;
ReleaseCapture();
redraw();
}
}
示例4: ShowTrayMenu
void ShowTrayMenu(HWND hwnd)
{
POINT pt;
GetCursorPos(&pt);
HMENU hMenu;
hMenu = CreatePopupMenu();
if(hMenu)
{
if( IsWindowVisible(hwnd) )
InsertMenu(hMenu, -1, MF_BYPOSITION, SWM_HIDE, TEXT("Hide"));
else
InsertMenu(hMenu, -1, MF_BYPOSITION, SWM_SHOW, TEXT("Show"));
if (state == READY)
InsertMenu(hMenu, -1, MF_BYPOSITION, SWM_CONN, TEXT("Connect"));
else
InsertMenu(hMenu, -1, MF_BYPOSITION, SWM_LOGOFF, TEXT("Log Off"));
InsertMenu(hMenu, -1, MF_BYPOSITION, SWM_EXIT, TEXT("Exit"));
// note: must set window to the foreground or the
// menu won't disappear when it should
SetForegroundWindow(hwnd);
TrackPopupMenuEx(hMenu, TPM_BOTTOMALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
pt.x, pt.y, hwnd, NULL );
DestroyMenu(hMenu);
}
}
示例5: switch
// Windows procedure override.
LRESULT Brainchild::WindowProc( UINT uMsg, WPARAM wParam, LPARAM lParam )
{
// Evaluate the message...
switch ( uMsg )
{
case WM_KEYDOWN:
/*if (wParam == 13) // Return key
m_pOwner->m_pFrame->SendMessage(WM_COMMAND, IDM_OPEN_SELECTED_PATH);*/
// Pass on all keys except the Context menu key.
if ( wParam != 0x5D )
break;
case WM_RBUTTONUP:
{
// Open the context menu at the cursor position.
ClsPoint pt;
GetCursorPos( pt );
TrackPopupMenuEx( m_pOwner->m_pFrame->m_ContextMenu, TPM_LEFTBUTTON | TPM_RIGHTBUTTON, pt.X(), pt.Y(), *m_pOwner->m_pFrame, NULL );
// If we got here because of a Context menu key
// we return so that the brainchild control does
// not get a chance to process it.
if ( uMsg == WM_KEYDOWN && wParam == 0x5D ) return 0;
break;
}
}
return ClsBrainchild::WindowProc( uMsg, wParam, lParam );
}
示例6: ShowContextMenu
void ShowContextMenu(HWND hwnd, POINT pt)
{
HMENU hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDC_CONTEXTMENU));
if (hMenu)
{
HMENU hSubMenu = GetSubMenu(hMenu, 0);
if (hSubMenu)
{
// our window must be foreground before calling TrackPopupMenu or the menu will not disappear when the user clicks away
SetForegroundWindow(hwnd);
// respect menu drop alignment
UINT uFlags = TPM_RIGHTBUTTON;
if (GetSystemMetrics(SM_MENUDROPALIGNMENT) != 0)
{
uFlags |= TPM_RIGHTALIGN;
}
else
{
uFlags |= TPM_LEFTALIGN;
}
TrackPopupMenuEx(hSubMenu, uFlags, pt.x, pt.y, hwnd, NULL);
}
DestroyMenu(hMenu);
}
}
示例7: LoadMenu
//----------------------------------------------------------------------------------------------
// ShowRightPopupMenu
//----------------------------------------------------------------------------------------------
VOID CStatusAreaIcon::ShowRightPopupMenu()
{
// プロパティ シートの状態を取得する
BOOL PropertySheetOpened = PropertySheet->IsOpened();
// ポップアップ メニューを作成する
HMENU Menu = LoadMenu( Instance, MAKEINTRESOURCE( IDR_MENU ) );
HMENU PopupMenu = GetSubMenu( Menu, 0 );
// 「プロパティ」をデフォルトにする
MENUITEMINFO ItemInfo;
ZeroMemory( &ItemInfo, sizeof( ItemInfo ) );
ItemInfo.cbSize = sizeof( ItemInfo );
GetMenuItemInfo( PopupMenu, IDM_PROPERTY, FALSE, &ItemInfo );
ItemInfo.fMask = MIIM_STATE;
ItemInfo.fState = MFS_ENABLED | MFS_DEFAULT;
if( PropertySheetOpened == TRUE )
{
ItemInfo.fState |= MFS_DISABLED;
}
SetMenuItemInfo( PopupMenu, IDM_PROPERTY, FALSE, &ItemInfo );
// 「設定の自動切換え」のチェックを設定する
GetMenuItemInfo( PopupMenu, IDM_AUTO_SETTING_CHANGE, FALSE, &ItemInfo );
ItemInfo.fMask = MIIM_STATE;
ItemInfo.fState = MFS_ENABLED;
if( Setting->AutoSettingChange == TRUE )
{
ItemInfo.fState |= MFS_CHECKED;
}
if( PropertySheetOpened == TRUE )
{
ItemInfo.fState |= MFS_DISABLED;
}
SetMenuItemInfo( PopupMenu, IDM_AUTO_SETTING_CHANGE, FALSE, &ItemInfo );
// 「終了」の有効・無効を設定する
GetMenuItemInfo( PopupMenu, IDM_EXIT, FALSE, &ItemInfo );
ItemInfo.fMask = MIIM_STATE;
ItemInfo.fState = MFS_ENABLED;
if( PropertySheetOpened == TRUE )
{
ItemInfo.fState |= MFS_DISABLED;
}
SetMenuItemInfo( PopupMenu, IDM_EXIT, FALSE, &ItemInfo );
// ポップアップ メニューを表示する
SetForegroundWindow( Wnd );
POINT CursorPos;
GetCursorPos( &CursorPos );
TrackPopupMenuEx(
PopupMenu
,TPM_LEFTALIGN | TPM_RIGHTBUTTON
,CursorPos.x
,CursorPos.y
,Wnd
,NULL );
DestroyMenu( Menu );
PostMessage( Wnd, WM_NULL, 0, 0 );
}
示例8: SetFocus
/**
* name: OnMenuPopup
* class: CAnnivEditCtrl
* desc: is called to show a popup menu for all anniversaries of a contact
* param: none
* return: nothing
**/
void CAnnivEditCtrl::OnMenuPopup()
{
POINT pt = { 0, 0 };
RECT rc;
HMENU hMenu;
WORD i;
if (hMenu = CreatePopupMenu()) {
SetFocus(_hBtnMenu);
MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_ID|MIIM_STRING|MIIM_STATE;
// insert the items
for (i = 0; i < _numDates; i++) {
mii.fState = _pDates[i]->IsValid() ? MFS_CHECKED : MFS_UNCHECKED;
mii.dwTypeData = (LPTSTR)_pDates[i]->Description();
mii.wID = WM_USER + i;
if (!InsertMenuItem(hMenu, i, TRUE, &mii)) {
DestroyMenu(hMenu);
return;
}
}
ClientToScreen(_hBtnMenu, &pt);
GetClientRect(_hBtnMenu, &rc);
i = TrackPopupMenuEx(hMenu, TPM_RIGHTALIGN|TPM_RETURNCMD, pt.x + rc.right, pt.y + rc.bottom, _hwndDlg, NULL);
DestroyMenu(hMenu);
SendMessage(_hBtnMenu, BM_SETCHECK, NULL, NULL);
if (i >= WM_USER) SetCurSel(i - WM_USER);
}
}
示例9: notify_handler_rclick
bool notify_handler_rclick(const std::map<int, std::string>& menu, HWND hwnd, int id, LPNMHDR lpNMHdr, is_enable_cb fn)
{
if (id != listview_id) {
return false;
}
LVITEM lvi;
LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE)lpNMHdr;
POINT point = {lpnmitem->ptAction.x, lpnmitem->ptAction.y};
MapWindowPoints(lpNMHdr->hwndFrom, NULL, &point, 1);
lvi.iItem = lpnmitem->iItem;
lvi.mask = LVIF_PARAM;
lvi.iSubItem = 0;
ListView_GetItem(lpNMHdr->hwndFrom, &lvi);
HMENU hpopup_candidate = CreatePopupMenu();
for (std::map<int, std::string>::const_iterator it = menu.begin(); it != menu.end(); ++ it) {
AppendMenu(hpopup_candidate, MF_STRING, it->first, utf8_2_ansi(it->second.c_str()));
if (lpnmitem->iItem < 0 || (fn && !fn(hwnd, it->first, lvi.lParam))) {
EnableMenuItem(hpopup_candidate, it->first, MF_BYCOMMAND | MF_GRAYED);
}
}
TrackPopupMenuEx(hpopup_candidate, 0,
point.x,
point.y,
hwnd,
NULL);
DestroyMenu(hpopup_candidate);
lParam = lvi.lParam;
return true;
}
示例10: OnRightButtonUp
//-----------------------------------------------------------------------------
// Name: OnRightButtonUp()
// Desc: Pop up a context menu.
//-----------------------------------------------------------------------------
VOID OnRightButtonUp( HWND hWnd )
{
// Place a popup menu where the mouse curent is
POINT pt;
pt.x = g_x;
pt.y = g_y;
ClientToScreen( hWnd, &pt );
HMENU hMenuPopup = GetSystemMenu( hWnd, FALSE );
// Hide the cursor while moving it so you don't get annoying flicker.
ShowCursor( FALSE );
InvalidateCursorRect( hWnd );
// Unacquire the devices so the user can interact with the menu.
g_bActive = FALSE;
SetAcquire();
// Put the Windows cursor at the same location as our virtual cursor.
SetCursorPos( pt.x, pt.y );
// Show the cursor now that it is moved
ShowCursor( TRUE );
InvalidateCursorRect( hWnd );
// Track the popup menu and return the menu item selected
UINT iMenuID = TrackPopupMenuEx( hMenuPopup, TPM_RIGHTBUTTON|TPM_RETURNCMD,
pt.x, pt.y, hWnd, 0 );
if( 0 != iMenuID ) // If a menu item was selected
PostMessage( hWnd, WM_SYSCOMMAND, iMenuID, 0L );
}
示例11: CreatePopupMenu
void TrayIcon::showMenu(POINT pos) {
// Create the pop-up menu for the icon.
HMENU menu = CreatePopupMenu();
if (!menu) {
return;
}
// Populate the pop-up menu.
AppendMenu(menu, (isEnabled() ? MF_CHECKED : 0) | MF_ENABLED | MF_STRING, IDM_ENABLE, _T("En&able Taekwindow"));
AppendMenu(menu, MF_ENABLED | MF_STRING, IDM_CONFIGURE, _T("&Preferences..."));
AppendMenu(menu, MF_SEPARATOR, 0, NULL);
AppendMenu(menu, MF_ENABLED | MF_STRING, IDM_EXIT, _T("&Exit"));
// Show the pop-up menu.
// Set the foreground window, so that the menu will be closed when the user clicks elsewhere.
// Post a dummy message to get it to show up the next time (I don't see this problem myself, but the KB says it).
// See Microsoft KB article 135788: "PRB: Menus for Notification Icons Do Not Work Correctly".
SetForegroundWindow(d_window.handle());
TrackPopupMenuEx(menu,
TPM_RIGHTBUTTON | (GetSystemMetrics(SM_MENUDROPALIGNMENT) ? TPM_RIGHTALIGN : TPM_LEFTALIGN),
pos.x, pos.y, d_window.handle(), NULL);
PostMessage(d_window.handle(), WM_NULL, 0, 0);
DestroyMenu(menu);
}
示例12: FileBrowseMenu
void FileBrowseMenu(int x, int y, HWND hwndToolbar)
{
if (fileBrowseInfo)
{
FILEBROWSE *p = fileBrowseInfo;
HMENU popup = CreatePopupMenu();
int i = 0, j;
memset(ordered, 0, sizeof(ordered));
while (p && i < MAX_BROWSE)
{
ordered[i++] = p;
p = p->next;
}
qsort(ordered, i, sizeof(FILEBROWSE *), fbcomp);
for (j=0; j < i;)
{
FILEBROWSE *cur = ordered[j];
HMENU internalPop = CreatePopupMenu();
for ( ;j < i && cur->info == ordered[j]->info; j++)
{
InsertMenu(internalPop, -1, MF_BYPOSITION | MF_STRING, j + ID_FILEBROWSE_LIST, GetName(j));
}
InsertMenu(popup, -1, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)internalPop, cur->info->dwTitle);
}
InsertBitmapsInMenu(popup);
TrackPopupMenuEx(popup, TPM_TOPALIGN | TPM_LEFTBUTTON, x, y, hwndFrame, NULL);
DestroyMenu(popup);
}
}
示例13: menuReleaser
bool OsShell::openShellContextMenuForObjects(const std::vector<std::wstring>& objects, int xPos, int yPos, void * parentWindow)
{
ComInitializer comInitializer;
IContextMenu * imenu = 0;
HMENU hMenu = NULL;
if (!prepareContextMenuForObjects(objects, parentWindow, hMenu, imenu) || !hMenu || !imenu)
return false;
CComInterfaceReleaser menuReleaser(imenu);
const int iCmd = TrackPopupMenuEx(hMenu, TPM_RETURNCMD, xPos, yPos, (HWND)parentWindow, NULL);
if (iCmd > 0)
{
CMINVOKECOMMANDINFO info = { 0 };
info.cbSize = sizeof(info);
info.hwnd = (HWND)parentWindow;
info.lpVerb = MAKEINTRESOURCEA(iCmd - 1);
info.nShow = SW_SHOWNORMAL;
imenu->InvokeCommand((LPCMINVOKECOMMANDINFO)&info);
}
DestroyMenu(hMenu);
return true;
}
示例14: OnContext
static VOID
OnContext(PMAIN_WND_INFO Info,
LPARAM lParam)
{
HTREEITEM hSelected;
POINT pt;
RECT rc;
INT xPos = GET_X_LPARAM(lParam);
INT yPos = GET_Y_LPARAM(lParam);
hSelected = TreeView_GetSelection(Info->hTreeView);
if (TreeView_GetItemRect(Info->hTreeView,
hSelected,
&rc,
TRUE))
{
if (GetCursorPos(&pt) &&
ScreenToClient(Info->hTreeView, &pt) &&
PtInRect(&rc, pt))
{
TrackPopupMenuEx(Info->hShortcutMenu,
TPM_RIGHTBUTTON,
xPos,
yPos,
Info->hMainWnd,
NULL);
}
}
}
示例15: OnContextMenu
/*------------------------------------------------
when the clock is right-clicked
show pop-up menu
--------------------------------------------------*/
void OnContextMenu(HWND hwnd, HWND hwndClicked, int xPos, int yPos)
{
WIN32_FIND_DATA fd;
HANDLE hfind;
TPMPARAMS tpmp;
LPTPMPARAMS lptpmp = NULL;
SendOnContextMenu();
if(m_tcmenutxt[0] == 0 || !IsFile(m_tcmenutxt))
{
// common/tclang.c
FindFileWithLangCode(m_tcmenutxt, GetUserDefaultLangID(), TCMENUTXT);
}
hfind = FindFirstFile(m_tcmenutxt, &fd);
if(hfind != INVALID_HANDLE_VALUE)
{
FindClose(hfind);
if(m_lasttime != fd.ftLastWriteTime.dwLowDateTime)
{
EndContextMenu();
m_lasttime = fd.ftLastWriteTime.dwLowDateTime;
}
}
else m_lasttime = 0;
// create popup menu and append items from tcmenu.txt
if(!m_hMenu)
{
m_hMenu = CreatePopupMenu();
if(hfind != INVALID_HANDLE_VALUE)
LoadMenuFromText(m_hMenu, m_tcmenutxt, &fd);
else
LoadMenuFromText(m_hMenu, NULL, NULL);
}
CheckMenu(m_hMenu);
// get keyboard input
SetFocusTClockMain(hwnd);
// APP key
if((xPos == -1) && (yPos == -1))
{
tpmp.cbSize = sizeof(tpmp);
lptpmp = &tpmp;
GetWindowRect(g_hwndClock, &tpmp.rcExclude);
xPos = tpmp.rcExclude.right;
yPos = tpmp.rcExclude.top;
}
// open popup menu
TrackPopupMenuEx(m_hMenu, TPM_LEFTALIGN|TPM_RIGHTBUTTON,
xPos, yPos, hwnd, lptpmp);
PostMessage(hwnd, WM_NULL, 0, 0);
}