void CCWArrangePage::OnRclickListTracks(NMHDR* pNMHDR, LRESULT* pResult) { POSITION pos = m_List.GetFirstSelectedItemPosition (); if (pos == NULL) return; int idx = m_List.GetNextSelectedItem (pos); BCMenu menu; if (m_List.GetItemText (idx, 0) == STR_SEPARATOR) menu.LoadMenu (IDR_MENU_SEP); else { menu.LoadMenu (IDR_MENU_TRACK); if (!m_pTracks->IsManuallyEditable ()) ((BCMenu*) menu.GetSubMenu (0))->RemoveMenu (ID_DELETETRACK, MF_BYCOMMAND); } menu.LoadToolbar (IDR_TOOLBAR_GRP); CPoint pt; GetCursorPos (&pt); menu.GetSubMenu (0)->TrackPopupMenu (TPM_RIGHTALIGN, pt.x, pt.y, this); menu.DestroyMenu (); *pResult = 0; }
/** * @brief Offer a context menu */ void CMergeDiffDetailView::OnContextMenu(CWnd* pWnd, CPoint point) { // Create the menu and populate it with the available functions BCMenu menu; VERIFY(menu.LoadMenu(IDR_POPUP_MERGEDETAILVIEW)); VERIFY(menu.LoadToolbar(IDR_MAINFRAME)); theApp.TranslateMenu(menu.m_hMenu); BCMenu *pSub = (BCMenu *)menu.GetSubMenu(0); ASSERT(pSub != NULL); // Context menu opened using keyboard has no coordinates if (point.x == -1 && point.y == -1) { CRect rect; GetClientRect(rect); ClientToScreen(rect); point = rect.TopLeft(); point.Offset(5, 5); } pSub->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, AfxGetMainWnd()); }
void CDemoView::OnContextMenu(CWnd* /*pWnd*/, CPoint point) { CDemoDoc* pDoc = GetDocument(); if (pDoc && pDoc->m_tool==2) return; #ifdef VATI_EXTENSIONS // suppress context menu if right-click function was called just now if ( m_suppressContextMenu == true ) return; #endif static UINT toolbars[]={ IDR_MAINFRAME, IDR_TOOLBAR1, }; BCMenu menu; menu.LoadMenu(IDM_CXIMAGE1); menu.LoadToolbars(toolbars,2); CMenu *pContextMenu=menu.GetSubMenu(0); pContextMenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON,point.x,point.y,AfxGetMainWnd()); }
void FileScrapDropDlg::OnContextMenu(CWnd* pWnd, CPoint pt) { BCMenu sMenu; if (sMenu.LoadMenu(IDR_FILE_SCRAP_DROP) == XPR_TRUE) { if (pt.x == -1 || pt.y == -1) { CRect sRect; GetClientRect(&sRect); ClientToScreen(&sRect); pt = sRect.TopLeft(); } BCMenu *sPopupMenu = (BCMenu *)sMenu.GetSubMenu(0); if (XPR_IS_NOT_NULL(sPopupMenu)) { sPopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt, this); } } }
LRESULT CKeyborDlg::OnNotifyIcon(WPARAM wParam,LPARAM lParam) { //单击鼠标左键 if((lParam==WM_LBUTTONDOWN)&&(!ShowWindow(SW_HIDE))) { OnSet(); } //鼠标单击右键 if(lParam==WM_RBUTTONDOWN) { // 弹出菜单 POINT rpoint; GetCursorPos(&rpoint); BCMenu mu; mu.LoadMenu(IDR_MENU1); SetForegroundWindow(); mu.GetSubMenu(0)->SetDefaultItem(ID_32779); mu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,rpoint.x,rpoint.y,this); } return 0; }
void BookmarkToolBar::OnContextMenu(CWnd* pWnd, CPoint aPoint) { CToolBarCtrl &sToolBarCtrl = GetToolBarCtrl(); CPoint sClientPoint(aPoint); ScreenToClient(&sClientPoint); xpr_bool_t sSucceeded = XPR_FALSE; xpr_sint_t sIndex = sToolBarCtrl.HitTest(&sClientPoint); if (GetKeyState(VK_CONTROL) < 0 && sIndex >= 0) { BookmarkItem *sBookmarkItem = BookmarkMgr::instance().getBookmark(sIndex); if (sBookmarkItem != XPR_NULL) { LPITEMIDLIST sFullPidl = sBookmarkItem->getPidl(); if (sFullPidl != XPR_NULL) { xpr_bool_t sResult; LPSHELLFOLDER sShellFolder = XPR_NULL; LPCITEMIDLIST sPidl = XPR_NULL; sResult = fxfile::base::Pidl::getSimplePidl(sFullPidl, sShellFolder, sPidl); if (SUCCEEDED(sResult) && sShellFolder != XPR_NULL && sPidl != XPR_NULL) { ContextMenu sContextMenu(GetSafeHwnd()); if (sContextMenu.init(sShellFolder, &sPidl, 1)) { TBBUTTON sTbButton = {0}; sToolBarCtrl.GetButton(sIndex, &sTbButton); sToolBarCtrl.SetState(sTbButton.idCommand, TBSTATE_MARKED | TBSTATE_ENABLED); xpr_uint_t sId = sContextMenu.trackPopupMenu(TPM_LEFTALIGN | TPM_RETURNCMD | TPM_RIGHTBUTTON, &aPoint, CMF_EXPLORE); if (sId != -1) { sId -= sContextMenu.getFirstId(); xpr_tchar_t sVerb[0xff] = {0}; sContextMenu.getCommandVerb(sId, sVerb, 0xfe); xpr_bool_t sSelfInvoke = XPR_FALSE; if (_tcsicmp(sVerb, CMID_VERB_OPEN) == 0) { gFrame->gotoBookmark(sIndex); sSelfInvoke = XPR_TRUE; } if (sSelfInvoke == XPR_FALSE) sContextMenu.invokeCommand(sId); } sToolBarCtrl.GetButton(sIndex, &sTbButton); sToolBarCtrl.SetState(sTbButton.idCommand, TBSTATE_ENABLED); } sContextMenu.destroy(); sSucceeded = XPR_TRUE; } COM_RELEASE(sShellFolder); COM_FREE(sFullPidl); } } } if (sSucceeded == XPR_FALSE) { BCMenu sMenu; if (sMenu.LoadMenu(IDR_COOLBAR_BOOKMARKBAR) == XPR_TRUE) { BCMenu *sPopupMenu = (BCMenu *)sMenu.GetSubMenu(0); if (XPR_IS_NOT_NULL(sPopupMenu)) sPopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, aPoint, AfxGetMainWnd()); } } }
/** * Show context menu and handle user selection. */ void CLocationView::OnContextMenu(CWnd* pWnd, CPoint point) { if (point.x == -1 && point.y == -1) { //keystroke invocation CRect rect; GetClientRect(rect); ClientToScreen(rect); point = rect.TopLeft(); point.Offset(5, 5); } CRect rc; CPoint pt = point; GetClientRect(rc); ScreenToClient(&pt); BCMenu menu; VERIFY(menu.LoadMenu(IDR_POPUP_LOCATIONBAR)); theApp.TranslateMenu(menu.m_hMenu); BCMenu* pPopup = (BCMenu *) menu.GetSubMenu(0); ASSERT(pPopup != NULL); CCmdUI cmdUI; cmdUI.m_pMenu = pPopup; cmdUI.m_nIndexMax = cmdUI.m_pMenu->GetMenuItemCount(); for (cmdUI.m_nIndex = 0 ; cmdUI.m_nIndex < cmdUI.m_nIndexMax ; ++cmdUI.m_nIndex) { cmdUI.m_nID = cmdUI.m_pMenu->GetMenuItemID(cmdUI.m_nIndex); switch (cmdUI.m_nID) { case ID_DISPLAY_MOVED_NONE: cmdUI.SetRadio(m_displayMovedBlocks == DISPLAY_MOVED_NONE); break; case ID_DISPLAY_MOVED_ALL: cmdUI.SetRadio(m_displayMovedBlocks == DISPLAY_MOVED_ALL); break; case ID_DISPLAY_MOVED_FOLLOW_DIFF: cmdUI.SetRadio(m_displayMovedBlocks == DISPLAY_MOVED_FOLLOW_DIFF); break; } } CString strItem; CString strNum; int nLine = -1; int bar = IsInsideBar(rc, pt); // If cursor over bar, format string with linenumber, else disable item if (bar != BAR_NONE) { // If outside bar area use left bar if (bar == BAR_YAREA) bar = BAR_LEFT; nLine = GetLineFromYPos(pt.y, bar); strNum.Format(_T("%d"), nLine + 1); // Show linenumber not lineindex } else pPopup->EnableMenuItem(ID_LOCBAR_GOTODIFF, MF_GRAYED); LangFormatString1(strItem, ID_LOCBAR_GOTOLINE_FMT, strNum); pPopup->SetMenuText(ID_LOCBAR_GOTODIFF, strItem, MF_BYCOMMAND); // invoke context menu // we don't want to use the main application handlers, so we use flags TPM_NONOTIFY | TPM_RETURNCMD // and handle the command after TrackPopupMenu int command = pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, point.x, point.y, AfxGetMainWnd()); CMergeDoc* pDoc = GetDocument(); switch (command) { case ID_LOCBAR_GOTODIFF: m_view[MERGE_VIEW_LEFT]->GotoLine(nLine, true, bar); if (bar == BAR_LEFT || bar == BAR_RIGHT) m_view[bar]->SetFocus(); break; case ID_EDIT_WMGOTO: m_view[MERGE_VIEW_LEFT]->WMGoto(); break; case ID_DISPLAY_MOVED_NONE: SetConnectMovedBlocks(DISPLAY_MOVED_NONE); pDoc->SetDetectMovedBlocks(FALSE); break; case ID_DISPLAY_MOVED_ALL: SetConnectMovedBlocks(DISPLAY_MOVED_ALL); pDoc->SetDetectMovedBlocks(TRUE); break; case ID_DISPLAY_MOVED_FOLLOW_DIFF: SetConnectMovedBlocks(DISPLAY_MOVED_FOLLOW_DIFF); pDoc->SetDetectMovedBlocks(TRUE); break; } }