afx_msg void CIec101sDlg::OnRClickGrid(NMHDR *pNMHDR, LRESULT *pResult) { NM_GRIDVIEW* pItem = (NM_GRIDVIEW*) pNMHDR; CMenu MenuRButton; MenuRButton.CreatePopupMenu(); MenuRButton.AppendMenu(MF_STRING, IDM_PRINT1, "Печать..."); POINT point; GetCursorPos(&point); MenuRButton.TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, this, NULL); MenuRButton.DestroyMenu(); }
void CGameManageDlg::OnNMRclickList1(NMHDR *pNMHDR, LRESULT *pResult) { // TODO: 在此添加控件通知处理程序代码 CMenu PopMenu; CString strMenu; PopMenu.CreatePopupMenu(); CPoint Point; GetCursorPos(&Point); m_GameDiskListCtrl.ScreenToClient(&Point); m_ListIndex1 = m_GameDiskListCtrl.HitTest(Point); if (0 <= m_ListIndex1 && m_ListIndex1 < m_wSocket.m_pRoomInfo->uDeskCount) { int flag = -1; int uesecount = 0; for (int j = 0; j < m_wSocket.m_UserManage.GetOnLineUserCount(); j++) { if (m_wSocket.m_UserManage.FindOnLineUserByIndex(j)->GameUserInfo.bDeskNO == m_ListIndex1) { uesecount++; } } if (uesecount == 0) flag = 0; for (int i = 0; i < m_wSocket.m_DeskStation.vVirtuals.size(); i++) { if (m_ListIndex1 == m_wSocket.m_DeskStation.vVirtuals[i]) { flag = 1; break; } } if (flag != -1) { if (flag == 0) PopMenu.AppendMenu(0, MSG_CMD_GM_LOCK, TEXT("封桌")); else if (flag == 1) PopMenu.AppendMenu(0, MSG_CMD_GM_UNLOCK, TEXT("解封")); PopMenu.AppendMenu(0, MSG_CMD_GM_ALLLOCK, TEXT("批量封桌")); PopMenu.AppendMenu(0, MSG_CMD_GM_ALLUNLOCK, TEXT("批量解封")); //显示菜单 GetCursorPos(&Point); //m_GameUeserListCtrl.ClientToScreen(&Point); PopMenu.TrackPopupMenu(TPM_RIGHTBUTTON, Point.x, Point.y, this); PopMenu.DestroyMenu(); } } *pResult = 0; }
/** * タスクトレイメッセージハンドラ */ LRESULT CInspectUsefulToolsDlg::OnNotifyTaskBarIcon(WPARAM,LPARAM lParam) { CMenu cMenu; POINT point; switch (lParam) { case WM_RBUTTONUP: // TrackPopupMenu か TrackPopupMenuEx を呼び出す前に、ウィンドウを // フォアグラウンドウィンドウにしなければならない // (see the MSDN Article ID: Q135788 ) SetForegroundWindow(); if( cMenu.LoadMenu(IDR_POPUPMENU)) { CMenu* pSubMenu = cMenu.GetSubMenu(0); if (pSubMenu != NULL) { pSubMenu->SetDefaultItem( 0, TRUE); GetCursorPos( &point ); pSubMenu->TrackPopupMenu( TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); pSubMenu->DestroyMenu(); } cMenu.DestroyMenu(); } // BUGFIX: 最後に次のクリックに反応できるようにメッセージをポスト // (see the MSDN Article ID: Q135788 ) PostMessage( WM_NULL, 0, 0); break; case WM_LBUTTONDBLCLK: this->ShowWindow(SW_SHOW); this->PostMessage(WM_SYSCOMMAND, SC_RESTORE); break; } return NULL; }
void fsODMenu::RemoveMenu(int iWhere, int iCount, CMenu *pMenuWhere) { if (pMenuWhere == NULL) pMenuWhere = CMenu::FromHandle (m_hMenu); while (iCount--) { CMenu *pSubMenu = pMenuWhere->GetSubMenu (iWhere); DetachMenu (pSubMenu); DetachMenuItem (pMenuWhere, iWhere); pMenuWhere->RemoveMenu (iWhere, MF_BYPOSITION); pSubMenu->DestroyMenu (); iWhere--; } }
void CFileTreeCtrl::OnContextMenu(CWnd* pWnd, CPoint point) { if (point.x == -1) { HTREEITEM ht = GetSelectedItem(); RECT rect; GetItemRect( ht, &rect, true ); ClientToScreen( &rect ); /* Offset the popup menu origin so * we can read some of the text */ point.x = rect.left + 15; point.y = rect.top + 8; } CMenu menu; menu.LoadMenu(IDR_MENU_TREEVIEW); CMenu * pop; pop = menu.GetSubMenu(0); UINT uCmd = pop->TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this, NULL ); /* Menu item chosen ? */ if (uCmd != 0) { switch(uCmd) { case ID_TREEVIEW_REFRESH: OnFileRefresh(); break; case ID_TREEVIEW_COPYPATH: OnFileCopyPathToClipboard(); break; case ID_TREEVIEW_OPENPATH: OnOpenPathInExplorer(); break; } } menu.DestroyMenu(); }
afx_msg void CGranitDlg::OnRClickGrid1(NMHDR *pNMHDR, LRESULT *pResult) { CMenu MenuRButton; MenuRButton.CreatePopupMenu(); MenuRButton.AppendMenu(MF_STRING, IDM_ADD, "Добавить набор инф.объектов"); //MenuRButton.AppendMenu(MF_STRING, IDM_ADDDIAP, "Добавить диапазон наборов инф.объектов"); MenuRButton.AppendMenu(MF_STRING, IDM_DEL, "Удалить набор инф.объектов"); MenuRButton.AppendMenu(MF_SEPARATOR); MenuRButton.AppendMenu(MF_STRING, IDM_PRINT2, "Печать..."); POINT point; GetCursorPos(&point); MenuRButton.TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, this, NULL); MenuRButton.DestroyMenu(); }
LRESULT CMainDlg::OnTrayNotification(WPARAM wParam, LPARAM lParam) { UINT uID = (UINT)wParam; UINT uMsg = (UINT)lParam; // Make sure its for us if(uID != IDR_TRAY_MENU) return 0; if(uMsg == WM_LBUTTONDBLCLK) { // Execute the default command ShowWindow(SW_RESTORE); return 1; } if(uMsg == WM_RBUTTONUP) { // Display the tray menu CMenu TrayMenu; CMenu* pSubMenu; if(!TrayMenu.LoadMenu(IDR_TRAY_MENU)) return 0; if(!(pSubMenu = TrayMenu.GetSubMenu(0))) return 0; // Set default menu item pSubMenu->SetDefaultItem(ID_SHOW); // Display and track the popup menu CPoint pos; GetCursorPos(&pos); SetForegroundWindow(); ::TrackPopupMenu(pSubMenu->m_hMenu, 0, pos.x, pos.y, 0, m_hWnd, NULL); // BUGFIX: See "PRB: Menus for Notification Icons Do Not Work Correctly" PostMessage(WM_NULL, 0, 0); // Clean up TrayMenu.DestroyMenu(); return 1; } return 0; }
void CWebInterfaceDlg::ShowTrayMenu() { CMenu menu; menu.LoadMenu (IDM_TRAY); CMenu *pPopup = menu.GetSubMenu (0); SetForegroundWindow (); pPopup->SetDefaultItem (ID_CONFIGURE); CPoint pt; GetCursorPos (&pt); pPopup->TrackPopupMenu (TPM_RIGHTBUTTON | TPM_BOTTOMALIGN | TPM_RIGHTALIGN, pt.x, pt.y, this); menu.DestroyMenu (); }
void CNetTrafficMonitorDlg::OnRButtonUp(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 //if (m_pSlider->IsWindowVisible()) //{ // m_pSlider->ShowWindow(SW_HIDE); //} CMenu menu; menu.CreatePopupMenu(); // 声明一个弹出式菜单 menu.AppendMenu(MF_STRING, IDC_SELFSTARTING, _T("开机启动")); //menu.AppendMenu(MF_STRING, IDC_TOPMOST, _T("置顶")); //CString strText; //strText.Format(_T("透明度: %d%%"), m_iTransparency); //menu.AppendMenu(MF_STRING, IDC_TRANSPARENCY, strText); menu.AppendMenu(MF_STRING, IDC_EXIT, _T("退出")); // 增加菜单项“退出”,点击则发送消息给主窗口将程序结束 if (m_bSelfStarting) { menu.SetMenuItemBitmaps(IDC_SELFSTARTING, MF_BYCOMMAND | MF_STRING | MF_ENABLED, &m_cCheckYes, &m_cCheckYes); } else { menu.SetMenuItemBitmaps(IDC_SELFSTARTING, MF_BYCOMMAND | MF_STRING | MF_ENABLED, &m_cCheckNo, &m_cCheckNo); } //if (m_bTopMost) //{ // menu.SetMenuItemBitmaps(IDC_TOPMOST, MF_BYCOMMAND | MF_STRING | MF_ENABLED, &m_cCheckYes, &m_cCheckYes); //} //else //{ // menu.SetMenuItemBitmaps(IDC_TOPMOST, MF_BYCOMMAND | MF_STRING | MF_ENABLED, &m_cCheckNo, &m_cCheckNo); //} menu.SetMenuItemBitmaps(IDC_EXIT, MF_BYCOMMAND | MF_STRING | MF_ENABLED, &m_cExit, &m_cExit); //SetForegroundWindow(); LPPOINT lpPoint = new tagPOINT(); GetCursorPos(lpPoint); menu.TrackPopupMenu(TPM_LEFTALIGN, lpPoint->x, lpPoint->y, this); // 确定弹出式菜单的位置 menu.Detach(); // 资源回收 menu.DestroyMenu(); delete lpPoint; //CWnd::OnRButtonUp(nFlags, point); // 屏蔽任务栏自己的右键菜单 }
afx_msg void CTuConfigTUDlg::OnRClickGrid(NMHDR *pNMHDR, LRESULT *pResult) { NM_GRIDVIEW* pItem = (NM_GRIDVIEW*) pNMHDR; CMenu MenuRButton; MenuRButton.CreatePopupMenu(); MenuRButton.AppendMenu(MF_STRING, IDM_ADD, "Добавить"); MenuRButton.AppendMenu(MF_STRING, IDM_ADDDIAPASON, "Добавить диапазон"); MenuRButton.AppendMenu(MF_STRING, IDM_DEL, "Удалить"); MenuRButton.AppendMenu(MF_SEPARATOR); MenuRButton.AppendMenu(MF_STRING, IDM_PRINT1, "Печать..."); POINT point; GetCursorPos(&point); MenuRButton.TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, this, NULL); MenuRButton.DestroyMenu(); }
void ControlEvent::ShowCMenu(CWnd *pcwnd) { LPPOINT lpoint=new tagPOINT; ::GetCursorPos(lpoint);//得到鼠标位置 CMenu menu; menu.CreatePopupMenu();//声明一个弹出式菜单 //增加菜单项“关闭”,点击则发送消息WM_DESTROY给主窗口(已 //隐藏),将程序结束。 menu.AppendMenu(MF_STRING,IDR_MYSETTING_MESSAGE,CString("软件设置")); menu.AppendMenu(MF_STRING,IDR_MYWEBSITE_MESSAGE,CString("官方网站")); menu.AppendMenu(MF_STRING,IDR_MYCLOSE_MESSAGE,CString("关闭退出")); //确定弹出式菜单的位置 menu.TrackPopupMenu(TPM_LEFTALIGN,lpoint->x,lpoint->y,pcwnd); //资源回收 HMENU hmenu=menu.Detach(); menu.DestroyMenu(); delete lpoint; }
//##ModelId=4095FA7D00FA void look::OnRclick(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here CMenu menu; // top-level menu CMenu *pMenu=NULL; // pop-up menu menu.LoadMenu(IDR_MENU2); pMenu = menu.GetSubMenu(0); if (!pMenu) return ; POINT pt; GetCursorPos(&pt); pMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, this, NULL); menu.DestroyMenu(); *pResult = 0; }
afx_msg void CModbusMDlg::OnRClickGrid(NMHDR *pNMHDR, LRESULT *pResult) { NM_GRIDVIEW* pItem = (NM_GRIDVIEW*) pNMHDR; CMenu MenuRButton; MenuRButton.CreatePopupMenu(); MenuRButton.AppendMenu(MF_STRING, IDM_ADD, "Добавить набор инф.объектов"); MenuRButton.AppendMenu(MF_STRING, IDM_ADDDIAP, "Добавить диапазон наборов инф.объектов"); MenuRButton.AppendMenu(MF_STRING, IDM_DEL, "Удалить набор инф.объектов"); MenuRButton.AppendMenu(MF_SEPARATOR); MenuRButton.AppendMenu(MF_STRING, IDM_PRINT2, "Печать..."); MenuRButton.AppendMenu(MF_STRING, IDM_COPY2, "Скопировать в буфер обмена..."); POINT point; GetCursorPos(&point); MenuRButton.TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, this, NULL); MenuRButton.DestroyMenu(); }
void CMainWnd::MenuSwitch() { m_wndMenu.DestroyMenu(); switch (blMenu) { case TRUE: m_wndMenu.LoadMenuW(IDR_MENU); break; case FALSE: m_wndMenu.LoadMenuW(IDR_MENU_RUS); break; } // Меняем переменную на противоположную, так как мы выбрали другое меню blMenu = !blMenu; // Устанавливаем меню во фрейм SetMenu(&m_wndMenu); }
/****************************************************************************** Function Name : OnRButtonDown Description : The framework calls this member function when the user right clicks on the list box Input(s) : nFlags - point - Output : - Functionality : Shows a popup menu to clear the contents of the listbox Member of : CNotificListbox Author(s) : Ravikumar Patil Date Created : 27-03-2003 ******************************************************************************/ void CNotificListbox::OnRButtonDown(UINT nFlags, CPoint point) { if (GetCount() > 0) { CMenu* pomContextMenu = new CMenu; if (pomContextMenu != NULL) { // Load the Menu from the resource pomContextMenu->DestroyMenu(); pomContextMenu->LoadMenu(IDM_OPERATION_LIST); CMenu* pomSubMenu = pomContextMenu->GetSubMenu(0); if (pomSubMenu != NULL) { CPoint omSrcPt = point; ClientToScreen(&omSrcPt); UINT unEnable; /* If no item is selected, make "Clear" and "Delete" menu items disabled */ if (GetCurSel() == -1) { unEnable = MF_BYCOMMAND | MF_DISABLED | MF_GRAYED; } else { unEnable = MF_BYCOMMAND | MF_ENABLED; } pomSubMenu->EnableMenuItem(IDM_OPRTN_CLEAR, unEnable); pomSubMenu->EnableMenuItem(IDM_OPRTN_DELETE, unEnable); pomSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, omSrcPt.x, omSrcPt.y, this, NULL); } delete pomContextMenu; pomContextMenu = NULL; } } CListBox::OnRButtonDown(nFlags, point); }
void CWnd_FDMGetCustVer_Btn::OnRButtonUp(UINT nFlags, CPoint point) { CMenu menu; menu.LoadMenu (IDM_GCV_BUTTON); CMenu *pPopup = menu.GetSubMenu (0); CPoint pt; GetCursorPos (&pt); m_odmenu.Attach (&menu, FALSE); pPopup->ModifyMenu (ID_HIDE, MF_BYCOMMAND|MF_STRING, ID_HIDE, LS (L_HIDE)); pPopup->TrackPopupMenu (TPM_RIGHTBUTTON | TPM_TOPALIGN | TPM_LEFTALIGN, pt.x, pt.y, this); m_odmenu.Detach (); menu.DestroyMenu (); CWnd::OnRButtonUp(nFlags, point); }
// 处理列表框右键消息 弹出浮动菜单 void CKillerDlg::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; if(pNMListView->iItem != -1) { DWORD dwPos = GetMessagePos();// 得到鼠标坐标 CPoint point( LOWORD(dwPos), HIWORD(dwPos) ); CMenu menu; VERIFY( menu.LoadMenu(IDR_MENU1)); CMenu* popup = menu.GetSubMenu(0); ASSERT( popup != NULL ); //确定弹出式菜单的位置 popup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); //资源回收 HMENU hmenu=menu.Detach(); menu.DestroyMenu(); } *pResult = 0; *pResult = 0; }
void CDownloads_Deleted::OnRClick() { CMenu menu; menu.LoadMenu (IDM_DELETEDITEMS); ApplyLanguageToMenu (&menu); CMenu *pPopup = menu.GetSubMenu (0); if (GetSelectedCount () == 0) { pPopup->EnableMenuItem (ID_DELETED_RESTORE, MF_BYCOMMAND | MF_GRAYED); pPopup->EnableMenuItem (ID_DELETED_DELETE, MF_BYCOMMAND | MF_GRAYED); } m_odmenu.Attach (&menu, FALSE); CPoint pt (0,0); GetCursorPos (&pt); pPopup->TrackPopupMenu (TPM_RIGHTBUTTON | TPM_TOPALIGN | TPM_LEFTALIGN, pt.x, pt.y, this); m_odmenu.Detach (); menu.DestroyMenu (); }
BOOL CCompileEditView::CreateSaveMenu() { if(g_pSaveMenu.m_hMenu != NULL) g_pSaveMenu.DestroyMenu(); if( !g_pSaveMenu.LoadMenu(IDR_SAVEMENU) ) return FALSE; CTreeCtrlFormula* pTree = NULL; if( pTree == NULL ) return FALSE; CMenu& popup = *g_pSaveMenu.GetSubMenu(0); if( popup.m_hMenu == NULL ) return FALSE; popup.RemoveMenu(0,MF_BYPOSITION); pTree->AddTreeGroupToMenu(SAVEMENU_BEGIN,popup); return TRUE; }
void CTWScriptEdit::OnRButtonDown(UINT nFlags, CPoint point) { //设置为焦点 SetFocus(); //创建一个弹出式菜单 CMenu popmenu; popmenu.CreatePopupMenu(); //添加菜单项目 popmenu.AppendMenu(0, ID_RICH_UNDO, "&Undo"); popmenu.AppendMenu(0, MF_SEPARATOR); popmenu.AppendMenu(0, ID_RICH_CUT, "&Cut"); popmenu.AppendMenu(0, ID_RICH_COPY, "C&opy"); popmenu.AppendMenu(0, ID_RICH_PASTE, "&Paste"); popmenu.AppendMenu(0, ID_RICH_CLEAR, "C&lear"); popmenu.AppendMenu(0, MF_SEPARATOR); popmenu.AppendMenu(0, ID_RICH_SELECTALL, "Select &All"); popmenu.AppendMenu(0, MF_SEPARATOR); popmenu.AppendMenu(0, ID_RICH_SETFONT, "Select &Font"); //初始化菜单项 UINT nUndo=(CanUndo() ? 0 : MF_GRAYED ); popmenu.EnableMenuItem(ID_RICH_UNDO, MF_BYCOMMAND|nUndo); UINT nSel=((GetSelectionType()!=SEL_EMPTY) ? 0 : MF_GRAYED) ; popmenu.EnableMenuItem(ID_RICH_CUT, MF_BYCOMMAND|nSel); popmenu.EnableMenuItem(ID_RICH_COPY, MF_BYCOMMAND|nSel); popmenu.EnableMenuItem(ID_RICH_CLEAR, MF_BYCOMMAND|nSel); UINT nPaste=(CanPaste() ? 0 : MF_GRAYED) ; popmenu.EnableMenuItem(ID_RICH_PASTE, MF_BYCOMMAND|nPaste); //显示菜单 CPoint pt; GetCursorPos(&pt); popmenu.TrackPopupMenu(TPM_RIGHTBUTTON, pt.x, pt.y, this); popmenu.DestroyMenu(); CRichEditCtrl::OnRButtonDown(nFlags, point); }
void CDlgFiles::OnLocalName( ) { if ( !m_pCurrentLocal->GetParent( ) ) return; CLocalFolder* pFolder = m_pCurrentLocal; CMenu menu; menu.CreatePopupMenu( ); int iLevel = 0; CString sTemp; while ( pFolder ) { CLocalFileBase::CreatePath( pFolder, sTemp ); if ( sTemp.IsEmpty( ) ) sTemp = LOCAL_ROOT; FixNameForDisplay( sTemp ); menu.AppendMenu( MF_STRING, FIRST_ITEM + iLevel++, sTemp ); pFolder = pFolder->GetParent( ); } POINT pp; GetCursorPos( &pp ); UINT uiCommand = menu.TrackPopupMenu( TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, pp.x, pp.y, this ); menu.DestroyMenu( ); if ( !uiCommand ) return; uiCommand = uiCommand - FIRST_ITEM; while ( uiCommand ) { m_pCurrentLocal = m_pCurrentLocal->GetParent( ); ASSERT( m_pCurrentRemote ); uiCommand--; } RefreshLocal( ); }
void CMyRichEdit::OnRButtonDown(UINT nFlags, CPoint point) { //设置为焦点 SetFocus(); //创建一个弹出式菜单 CMenu popmenu; popmenu.CreatePopupMenu(); //添加菜单项目 popmenu.AppendMenu(0, ID_RICH_UNDO, _T("撤消(&U)")); popmenu.AppendMenu(0, MF_SEPARATOR); popmenu.AppendMenu(0, ID_RICH_CUT, _T("剪切(&T)")); popmenu.AppendMenu(0, ID_RICH_COPY, _T("复制(&T)")); popmenu.AppendMenu(0, ID_RICH_PASTE, _T("粘贴(&P)")); popmenu.AppendMenu(0, ID_RICH_CLEAR, _T("删除(&D)")); popmenu.AppendMenu(0, MF_SEPARATOR); popmenu.AppendMenu(0, ID_RICH_SELECTALL, _T("全选(&A)")); popmenu.AppendMenu(0, MF_SEPARATOR); popmenu.AppendMenu(0, ID_RICH_SETFONT, _T("设置字体(&F)")); //初始化菜单项 UINT nUndo=(CanUndo() ? 0 : MF_GRAYED ); popmenu.EnableMenuItem(ID_RICH_UNDO, MF_BYCOMMAND|nUndo); UINT nSel=((GetSelectionType()!=SEL_EMPTY) ? 0 : MF_GRAYED) ; popmenu.EnableMenuItem(ID_RICH_CUT, MF_BYCOMMAND|nSel); popmenu.EnableMenuItem(ID_RICH_COPY, MF_BYCOMMAND|nSel); popmenu.EnableMenuItem(ID_RICH_CLEAR, MF_BYCOMMAND|nSel); UINT nPaste=(CanPaste() ? 0 : MF_GRAYED) ; popmenu.EnableMenuItem(ID_RICH_PASTE, MF_BYCOMMAND|nPaste); //显示菜单 CPoint pt; GetCursorPos(&pt); popmenu.TrackPopupMenu(TPM_RIGHTBUTTON, pt.x, pt.y, this); popmenu.DestroyMenu(); CRichEditCtrl::OnRButtonDown(nFlags, point); }
void COutputWindowView::OnContextMenu( CWnd* pWnd, CPoint point ) { CMenu menu; CMenu* pPopupMenu; int iStart; int iEnd; if( pWnd->m_hWnd != m_hWnd ) { return; } menu.LoadMenu( IDR_OUTPUTLOGEDIT_CONTEXT ); pPopupMenu = menu.GetSubMenu( 0 ); GetEditCtrl().GetSel( iStart, iEnd ); if( iEnd == iStart ) { pPopupMenu->EnableMenuItem( ID_OUTPUTLOGEDIT_COPY, MF_GRAYED ); } pPopupMenu->TrackPopupMenu( TPM_LEFTALIGN|TPM_RIGHTBUTTON, point.x, point.y, this, NULL ); menu.DestroyMenu(); }
int CDrawQuoteTabCtrl::OpenSettingMenu( CPoint point ) { CMenu menu; menu.CreatePopupMenu(); menu.InsertMenu(0,MF_BYCOMMAND|MF_STRING, CDRAWTAB_QUOTETAB_SETTING,_T("设置")); menu.InsertMenu(1,MF_SEPARATOR); m_ayTempGroups.RemoveAll(); m_iTab->GetAllTabGroups(m_ayTempGroups); for (int i=0; i<m_ayTempGroups.GetCount(); i++) { menu.AppendMenu(MF_BYCOMMAND|MF_STRING, CDRAWTAB_QUOTETAB_TABGROUPS_BEGIN+i,m_ayTempGroups.GetAt(i)); if (m_strCurGroupName == m_ayTempGroups.GetAt(i)) { menu.CheckMenuItem(CDRAWTAB_QUOTETAB_TABGROUPS_BEGIN+i,MF_BYCOMMAND|MF_CHECKED); } } CWnd* pWnd = m_pDrawTabNotify->TabGetCWnd(); int nMenuID = menu.TrackPopupMenu(TPM_VERPOSANIMATION | TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD,point.x,point.y,pWnd); menu.DestroyMenu(); return nMenuID; }
void CRTListCtrl::OnContextMenu(CWnd *, CPoint point) { CMenu menu; CMainFrame *m_pMainWnd; m_pMainWnd = (CMainFrame *) AfxGetMainWnd (); if (point.x == -1 && point.y == -1){ CRect rect; GetClientRect(rect); ClientToScreen(rect); point = rect.TopLeft(); point.Offset(5,5); } else { ClientToScreen(&point);//.Offset(50, 146); } menu.DestroyMenu(); VERIFY(menu.LoadMenu(IDR_POPUP_RT_SET)); // InitMenu(0 ,type, del_flag); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); //pPopup->EnableMenuItem(AFX_ID_BLOWUP,MF_GRAYED); pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x,point.y,pWndPopupOwner); }
/****************************************************************************** Function Name : OnRButtonDown Description : The framework calls this member function when the user right clicks on the list box Input(s) : nFlags - point - Output : - Functionality : Shows a popup menu to remove an entry or to clear entries Member of : CSignalWatchListBox Author(s) : Ratnadip Choudhury, Amarnath Shastri Date Created : 03-04-2002 Modified by : Ratnadip Choudhury Modified on : 26-04-2002 Modified by : Raja N Modified on : 22.07.2004, Modified the function call to refer ListCtrl ******************************************************************************/ void CSignalWatchListBox::OnRButtonDown(UINT nFlags, CPoint omPoint) { if (GetItemCount() > 0) { CMenu* pomContextMenu = new CMenu; if (pomContextMenu != NULL) { // Load the Menu from the resource pomContextMenu->DestroyMenu(); pomContextMenu->LoadMenu(IDM_MENU_SIGNAL_WATCH); CMenu* pomSubMenu = pomContextMenu->GetSubMenu(1); if (pomSubMenu != NULL) { CPoint omSrcPt = omPoint; ClientToScreen(&omSrcPt); UINT unEnable; // If no item is selected, make "Delete" menu item disabled if (GetSelectedCount() == -1) { unEnable = MF_BYCOMMAND | MF_DISABLED | MF_GRAYED; } else { unEnable = MF_BYCOMMAND | MF_ENABLED; } pomSubMenu->EnableMenuItem(IDM_SG_WATCH_CLEAR, unEnable); pomSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, omSrcPt.x, omSrcPt.y, this, NULL); } delete pomContextMenu; pomContextMenu = NULL; } } CFFListCtrl::OnRButtonDown(nFlags, omPoint); }
void CRuler::OnRButtonDown(UINT nFlags, CPoint point) { //These things all feed back to the view port, so don't //even bother unless a view port exists if (m_View!=NULL) { CMenu Menu; ClientToScreen(&point); if (theApp.GetSettings()->IsMetric()) { VERIFY(Menu.LoadMenu(IDR_RULERMENU)); } else { VERIFY(Menu.LoadMenu(IDR_RULERMENUINCHES)); } CMenu* pPopup = Menu.GetSubMenu(0); if (pPopup!=NULL) { pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x,point.y,this); } Menu.DestroyMenu(); } }
void CDlgFiles::OnRemoteName( ) { if ( !m_pCurrentRemote->GetParent( ) ) return; CHotlineFolder* pFolder = m_pCurrentRemote; CMenu menu; menu.CreatePopupMenu( ); int iLevel = 0; CString sTemp; while ( pFolder ) { GetRemotePathName( pFolder, sTemp ); FixNameForDisplay( sTemp ); menu.AppendMenu( MF_STRING, FIRST_ITEM + iLevel++, sTemp ); pFolder = pFolder->GetParent( ); } POINT pp; GetCursorPos( &pp ); UINT uiCommand = menu.TrackPopupMenu( TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, pp.x, pp.y, this ); menu.DestroyMenu( ); if ( !uiCommand ) return; uiCommand = uiCommand - FIRST_ITEM; while ( uiCommand ) { m_pCurrentRemote = m_pCurrentRemote->GetParent( ); ASSERT( m_pCurrentRemote ); uiCommand--; } RefreshRemoteFolder( m_pCurrentRemote ); }
void CSitesWnd::OnRClick() { CMenu menu; menu.LoadMenu (IDM_SITES); ApplyLanguageToMenu (&menu); CMenu *pPopup = menu.GetSubMenu (0); UpdateMenu (pPopup); ClientToScreen (&m_rbPt); m_odmenu.Attach (&menu, FALSE); m_odmenu.SetImageList (&((CMainFrame*)AfxGetApp ()->m_pMainWnd)->m_imgsMenu, &((CMainFrame*)AfxGetApp ()->m_pMainWnd)->m_dimgsMenu); fsSetImage *pImages; int cImages; CSitesWnd::Plugin_GetMenuImages (&pImages, &cImages); m_odmenu.SetImages (pImages, cImages); pPopup->TrackPopupMenu (TPM_RIGHTBUTTON | TPM_TOPALIGN | TPM_LEFTALIGN, m_rbPt.x, m_rbPt.y, this); m_odmenu.Detach (); menu.DestroyMenu (); }
void CWndLog::OnRClick() { CMenu menu; menu.LoadMenu (IDM_LOG); CMenu *pPopup = menu.GetSubMenu (0); ApplyLanguageToMenu (pPopup); if (m_bAutoScroll) pPopup->CheckMenuItem (ID_AUTOSCROLL, MF_CHECKED | MF_BYCOMMAND); if (GetItemCount () == 0) { pPopup->EnableMenuItem (ID_CLEAR, MF_BYCOMMAND | MF_GRAYED); pPopup->EnableMenuItem (ID_COPY_TO_CB, MF_BYCOMMAND | MF_GRAYED); } ClientToScreen (&m_rbPt); m_odmenu.Attach (&menu, FALSE); pPopup->TrackPopupMenu (TPM_RIGHTBUTTON | TPM_TOPALIGN | TPM_LEFTALIGN, m_rbPt.x, m_rbPt.y, this); m_odmenu.Detach (); menu.DestroyMenu (); }