void CPage6::OnNMRclickList4(NMHDR *pNMHDR, LRESULT *pResult) { iSelected = m_FileList.GetNextItem(-1, LVNI_SELECTED); POINT point; ::GetCursorPos(&point); CMenu menu; menu.LoadMenu(IDR_MENU3); menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, this); *pResult = 0; }
void CNifConvertDlg::OnContextMenu(CWnd *pWnd, CPoint point) { CMenu* pPopUp(NULL); CMenu menuBar; menuBar.LoadMenu(IDR_MENU_POPUP); pPopUp = menuBar.GetSubMenu(0); pPopUp->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); }
void CSyncGameInfoView::OnNMRClick(NMHDR *pNMHDR, LRESULT *pResult) { LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR); CMenu menu; menu.LoadMenu(IDR_MENU1); POINT pt; GetCursorPos(&pt); menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN ,pt.x,pt.y,this); *pResult = 0; }
void CFileOptDlg::OnRclickListFileopt(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here CMenu popMenu; popMenu.LoadMenu(IDR_POPMENU_FILE); CPoint point; GetCursorPos(&point); popMenu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN,point.x,point.y,this); *pResult = 0; }
// // Generic handler for press on any BResultType button. // Records which button was pressed, then pops up the result type menu. // void CPageDisplay::OnBResultType( int which_button ) { CMenu menu; CRect button_rect; RECT screen_rect; int menu_height, menu_x, menu_y; // Record which button was pressed, for later use by OnMDisplay(). selected_button = which_button; // This prevents the menu from popping up if the user is "unchecking" the button. if ( ( (CButton*)GetDlgItem( BResultType1 + selected_button ) )->GetCheck() ) { ( (CButton*)GetDlgItem( BResultType1 + selected_button ) )-> SetCheck( FALSE ); return; } // Create the popup menu from the resource. VERIFY(menu.LoadMenu(IDR_POPUP_DISPLAY_LIST)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); // Find the first non-child window to be the popup's parent. CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); // Get the screen coordinates of the button that was pressed. GetDlgItem( BResultType1 + selected_button )->GetWindowRect( &button_rect ); // Position the menu with its upper left corner at the lower left corner of the button. menu_x = button_rect.TopLeft().x; menu_y = button_rect.BottomRight().y; // If the menu would go off the bottom of the screen, make it go *up* from the button instead. menu_height = GetSystemMetrics(SM_CYMENUSIZE) * MDisplayNumSubmenus; if ( SystemParametersInfo( SPI_GETWORKAREA, 0, &screen_rect, 0) && (menu_y + menu_height > screen_rect.bottom) ) { menu_y = button_rect.TopLeft().y - menu_height + 1; } // Set the button's visual state to "pressed" as long as the menu is popped up. ( (CButton*)GetDlgItem( BResultType1 + selected_button ) )->SetCheck( TRUE ); // Pop up the menu. pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, menu_x, menu_y, pWndPopupOwner); // The user's selection (if any) from the pop-up menu will result in a call to one of the // CGalileoView::OnMDisplay...() functions, which will in turn call CPageDisplay::OnMDisplay(). // Set the button's visual state to "not pressed" after the menu is dismissed. ( (CButton*)GetDlgItem( BResultType1 + selected_button ) )->SetState( FALSE ); }
void ProcessShellMessage( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { UINT cmdId = 0; switch (lParam) { case WM_LBUTTONUP: cmdId = ID_SHELL_ACTIVATE; break; case WM_RBUTTONUP: { CMenu menu; menu.LoadMenu(MAKEINTRESOURCE(IDR_SHELLTRAY)); // HMENU hMenu = AfxGetApp()->LoadMenu(MAKEINTRESOURCE(IDR_SHELLTRAY)); // HWND hWndMain = AfxGetMainWnd()->GetSafeHwnd(); HMENU hMenuTrackPopup = *menu.GetSubMenu (0); // convert to a HMENU POINT pt; GetCursorPos(&pt); // This is required when using a notify icon -- see KB article // PRB: Menus for Notification Icons Don't Work Correctly SetForegroundWindow (hWnd); SetMenuDefaultItem(hMenuTrackPopup, 0, MF_BYPOSITION); cmdId = TrackPopupMenu(hMenuTrackPopup, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RETURNCMD | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hWnd, NULL); // This is required when using a notify icon -- see KB article // PRB: Menus for Notification Icons Don't Work Correctly ::PostMessage (hWnd, WM_USER, 0, 0); break; } break; } switch (cmdId) { case ID_SHELL_ACTIVATE: { HWND hwndMain = AfxGetMainWnd()->GetSafeHwnd(); BOOL ok = (hwndMain != NULL); if (ok) ::SetForegroundWindow(hwndMain); if (ok) { WINDOWPLACEMENT wp; wp.length = sizeof(wp); ok = ::GetWindowPlacement(hwndMain, &wp); if (ok && wp.showCmd==SW_SHOWMINIMIZED) ::ShowWindow(hwndMain, SW_RESTORE); } break; } case ID_SHELL_BREAK: // set a flag to tell the process to break; PyErr_SetInterrupt(); break; default: break; } }
void CHallQueFrontView::OnLButtonDblClk(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 CPoint pt; GetCursorPos(&pt); int result = m_pTrackCtrl->Track( point,nFlags); if(result == TRACK_CTR_MIDORHANDLE) { OnEditctr(); } else { int nFullWidth=GetSystemMetrics(SM_CXSCREEN); int nFullHeight=GetSystemMetrics(SM_CYSCREEN); CRect inRect; inRect.left = nFullWidth - 300; inRect.top = nFullHeight - 200; inRect.right = nFullWidth; inRect.bottom = nFullHeight; if(inRect.PtInRect(pt)) { if(!m_isManage) { CMenu menu; menu.LoadMenu(IDR_MENU_NOMANAGE); CMenu *pContentMenu=menu.GetSubMenu(0); pContentMenu->TrackPopupMenu(TPM_LEFTALIGN,pt.x,pt.y,this); //在指定位置显示弹出菜单 pContentMenu->DestroyMenu(); } else { CMenu menu; menu.LoadMenu(IDR_MENU_MANAGE); CMenu *pContentMenu=menu.GetSubMenu(0); pContentMenu->TrackPopupMenu(TPM_LEFTALIGN,pt.x,pt.y,this); //在指定位置显示弹出菜单 pContentMenu->DestroyMenu(); } } } CView::OnLButtonDblClk(nFlags, point); }
void CXMLTreeView::OnRButtonDown(UINT nFlags, CPoint point) { CMenu menu; menu.LoadMenu(IDR_MENU_FIND); CMenu* pPopup = menu.GetSubMenu(0); ClientToScreen(&point); //客户坐标转换成屏幕坐标 pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); CView::OnRButtonDown(nFlags, point); }
void CPreferencesPrint::OnFooterButton() { CMenu menu; CMenu* pPopup; RECT rc; int i = SendDlgItemMessage (IDC_PRNDLG_HEADERBTN, BM_GETSTATE, 0, 0); ::GetWindowRect(::GetDlgItem(m_hWnd, (i & BST_FOCUS) ? IDC_PRNDLG_HEADERBTN : IDC_PRNDLG_FOOTERBTN), &rc); menu.LoadMenu(IDR_POPUPS); pPopup = menu.GetSubMenu(3); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, rc.right, rc.top, this); }
LRESULT CH3CDlg::OnTray(WPARAM wParam,LPARAM lParam) { UINT uID=(UINT) wParam; UINT uMouseMsg=(UINT) lParam; CMenu menu; CMenu *pMenu; POINT pt; if(uMouseMsg==WM_LBUTTONDBLCLK)//如果是左键双击 { switch(uID) { case IDR_MAINFRAME: case IDI_DISCON: if(isShown==false) { //显示主窗口 //ModifyStyle(WS_POPUP,WS_OVERLAPPEDWINDOW); //ModifyStyleEx(WS_EX_TOOLWINDOW,WS_EX_TOPMOST); ShowDialog(); } else { HideDialog(); } return 0; break; default: break; } } if(uMouseMsg==WM_RBUTTONDOWN || uMouseMsg==WM_LBUTTONDOWN)//如果是单击左右键 { switch(uID) { case IDR_MAINFRAME://如果是我们的图标 case IDI_DISCON: GetCursorPos(&pt);//取得鼠标位置 //执行相应操作 menu.LoadMenu(IDR_MENU1); pMenu=menu.GetSubMenu(0); ASSERT(pMenu!=0); ::SetForegroundWindow(this->m_hWnd); pMenu->TrackPopupMenu (0,pt.x,pt.y,this); break; default: break; } } return 0; }
// コンテキストメニュー表示 void TimelineEditorView::OnContextMenu(CWnd* pWnd, CPoint point) { // TODO: ここにメッセージ ハンドラー コードを追加します。 CPoint poClientPoint = point; ScreenToClient(&poClientPoint); CMenu mContextMenu; if (m_pTimelineDataOperator->OnContextMenu(poClientPoint, mContextMenu)) { mContextMenu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, point.x, point.y, this); } }
void CCaseTreeCtrl::OnContextMenu(CPoint point) { HTREEITEM hTreeItem = NULL; if (point != CPoint(-1, -1)) { // 选择已单击的项: CPoint ptTree = point; ScreenToClient(&ptTree); UINT flags = 0; hTreeItem = HitTest(ptTree, &flags); if (hTreeItem != NULL) { SelectItem(hTreeItem); } } SetFocus(); if(hTreeItem) { IpmiCmdItem* pItem = (IpmiCmdItem*)GetItemData(hTreeItem); CMenu menu; /* if(wcscmp(pItem->m_pName, L"Emmc") == 0) { if (menu.LoadMenu(IDR_MENU2)) { CMenu* pPopup = menu.GetSubMenu(0); ENSURE(pPopup != NULL); pPopup->TrackPopupMenu(TPM_RIGHTBUTTON | TPM_LEFTALIGN, point.x, point.y, this); // route commands through main window,AfxGetMainWnd() } } else*/ { if (menu.LoadMenu(IDR_MENU1)) { CMenu* pPopup = menu.GetSubMenu(0); ENSURE(pPopup != NULL); pPopup->EnableMenuItem(ID_STOP, 0); pPopup->TrackPopupMenu(TPM_RIGHTBUTTON | TPM_LEFTALIGN, point.x, point.y, this); // route commands through main window,AfxGetMainWnd() } } } }
void CPropertiesCtrl::OnContextMenu(CWnd* pWnd, CPoint point) { CMenu Popup; Popup.LoadMenu(IDR_POPUP_MENUS); CMenu* pPopup = Popup.GetSubMenu(5); ASSERT(pPopup); CRect rc; pPopup->TrackPopupMenu( TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_VERTICAL, point.x, point.y, GetParentFrame(), NULL/*&rc*/); }
BOOL CMonitorWnd::ApplyMenu(UINT nMenuId) { CMenu pMenu; pMenu.LoadMenu( nMenuId ); CString str; pMenu.GetMenuString( 0, str, MF_BYPOSITION ); CMenu* pSubMenu = pMenu.GetSubMenu( 0 ); m_hSubMenu = pMenu.GetSubMenu(0)->m_hMenu; CMenu* pMainMenu = AfxGetMainWnd()->GetMenu(); pMainMenu->AppendMenu( MF_POPUP|MF_STRING, (UINT)m_hSubMenu, str ); pMainMenu->Detach(); pMenu.Detach(); AfxGetMainWnd()->DrawMenuBar(); return TRUE; }
void CLogViewDlg::OnNMRClickListLog(NMHDR *pNMHDR, LRESULT *pResult) { LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR); *pResult = 0; POINT Pt; GetCursorPos(&Pt); CMenu menu; menu.LoadMenu(IDR_MAIN_MENU); menu.GetSubMenu(1)->TrackPopupMenu(TPM_LEFTBUTTON | TPM_RIGHTBUTTON, Pt.x, Pt.y, this); }
///////////////////////////////////////////////////////////////////////////// // CDuiVisionDesignerView message handlers void CDuiVisionDesignerView::OnContextMenu(CWnd* pWnd, CPoint point) { get_dll_resource(); CMenu* pMenu = new CMenu(); pMenu->LoadMenu(IDR_OWM); reset_dll_resource(); CMenu* pmenu = (CMenu*)pMenu->GetSubMenu(0); pmenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); delete pMenu; }
void CThingTreeCtrl::OnContextMenu(CWnd* pWnd, CPoint point) { // find out where we clicked (on a thing, a module, or what) CMenu menu; CPoint temppoint; HTREEITEM hParent, hNextParent; HTREEITEM hItem = NULL; UINT uFlags = 0; // save the point for later temppoint = point; // tree uses client points m_treeCtrl.ScreenToClient(&temppoint); // now do a hittest on the tree hItem = m_treeCtrl.HitTest(temppoint, &uFlags); if (!hItem) return; // only select if we clicked on the icon or the label // if(!(uFlags & TVHT_ONITEM)) // we arent right clicking on anything so return // return; m_treeCtrl.SelectItem(hItem); hParent = hItem; hNextParent = m_treeCtrl.GetParentItem( hItem ); while (hNextParent != NULL) { hParent = hNextParent; hNextParent = m_treeCtrl.GetParentItem( hParent ); } if (hParent == m_hRoom) { VERIFY(menu.LoadMenu(IDR_ROOM_MENU)); } else if (hParent == m_hModules) { VERIFY(menu.LoadMenu(IDR_MODULE_MENU)); } else return; CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); }
//右键菜单 void CGuiderView::OnContextMenu(CWnd* pWnd, CPoint point) { // TODO: 在此处添加消息处理程序代码 //CMainFrame::m_bAutoMenuEnable=false;//不应该在这里,应该在它的构造里初始化 ////cstring ss_test; ////cstring ss_test1(""); /////*ss_test.format("%d",point.x); ////ss_test1+=ss_test; ////ss_test.format("%d",point.y); ////ss_test1+="+"; ////ss_test1+=ss_test; ////afxmessagebox(ss_test1); */ //坐标转换 CPoint p=point; this->ScreenToClient(&p); App_Veriable::RelativeContextMenuPos=p;//初始化菜单相对位置 //转换后的坐标在p中 if(App_Veriable::IsAddingRoute==false&&App_Veriable::ShortestRouteBeginID==0)//添加路径,寻找最短路径时候不再有菜单 { CMenu popMenu; popMenu.LoadMenuW(IDR_MENU1); CMenu*pSubMenu=popMenu.GetSubMenu(0); if(sitelist.OnSite(p.x,p.y)==0&&routelist.OnRoute(p.x,p.y)==NULL)//点击空白 { pSubMenu->EnableMenuItem(ID_ADD_SITE,MF_ENABLED); pSubMenu->EnableMenuItem(ID_ADD_ROUTE,MF_GRAYED); pSubMenu->EnableMenuItem(ID_DELETE,MF_GRAYED); pSubMenu->EnableMenuItem(ID_SHORTEST_ROUTE,MF_GRAYED); pSubMenu->EnableMenuItem(ID_ATTRIBUTE,MF_GRAYED); //首先修改属性,再显示 } else if(sitelist.OnSite(p.x,p.y)!=0)//点上 { pSubMenu->EnableMenuItem(ID_ADD_SITE,MF_GRAYED); pSubMenu->EnableMenuItem(ID_ADD_ROUTE,MF_ENABLED); pSubMenu->EnableMenuItem(ID_DELETE,MF_ENABLED); pSubMenu->EnableMenuItem(ID_SHORTEST_ROUTE,MF_ENABLED); pSubMenu->EnableMenuItem(ID_ATTRIBUTE,MF_ENABLED); } else//线上 { pSubMenu->EnableMenuItem(ID_ADD_SITE,MF_GRAYED); pSubMenu->EnableMenuItem(ID_ADD_ROUTE,MF_GRAYED); pSubMenu->EnableMenuItem(ID_DELETE,MF_ENABLED); pSubMenu->EnableMenuItem(ID_SHORTEST_ROUTE,MF_GRAYED); pSubMenu->EnableMenuItem(ID_ATTRIBUTE,MF_ENABLED); } pSubMenu->TrackPopupMenu (TPM_LEFTALIGN,point.x,point.y,pWnd); } }
void CDlgObjectManager::OnNMRclickTree(NMHDR *pNMHDR, LRESULT *pResult) { if( m_pDoc == NULL) return; CMyObject* pObj; HTREEITEM hI; CPoint pt, ptMenu; UINT uFlags; CRect rc; GetCursorPos(&pt); ptMenu=pt; m_tree.GetWindowRect(&rc); pt.x -= rc.left; pt.y -= rc.top; hI = m_tree.HitTest( pt, &uFlags); pObj = FindObj(hI); if(pObj && (uFlags==TVHT_ONITEMLABEL) ){ m_hI = hI; CMenu menu; CRect wndRect; this->GetWindowRect(wndRect); menu.LoadMenu(IDR_MENU_OBJMNG); CMenu* subMenu = menu.GetSubMenu(0); subMenu->TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON , ptMenu.x, ptMenu.y, this); } CBody* pBd; pBd = (CBody*) FindBody(hI); if(pBd && (uFlags==TVHT_ONITEMLABEL) ) { m_hI = hI; CMenu menu; CRect wndRect; this->GetWindowRect(wndRect); menu.LoadMenu(IDR_MENU_OBJMNG); CMenu* subMenu = menu.GetSubMenu(0); subMenu->TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON , ptMenu.x, ptMenu.y, this); } *pResult = 0; }
void CScriptEdit::OnContextMenu(CWnd* pWnd, CPoint point) { if(pWnd->GetDlgCtrlID()==IDC_TEXT) { CMenu *menu; CMenu *popupmenu; menu=GetMenu(); popupmenu=menu->GetSubMenu(EDITMENU); //this should be better defined popupmenu->TrackPopupMenu(TPM_CENTERALIGN,point.x,point.y,this); } }
LRESULT CChildFrame::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { uMsg, wParam, lParam, bHandled; bHandled = FALSE; POINT ptScr = { 0 }; ptScr.x = GET_X_LPARAM(lParam); ptScr.y = GET_Y_LPARAM(lParam); { POINT ptLoc = ptScr; DWORD dwStyle = m_wndCatalog.GetStyle(); if(WS_VISIBLE != (dwStyle & WS_VISIBLE)) return S_OK; RECT rc; m_wndCatalog.GetClientRect(&rc); // 将屏幕坐标转换成指定窗口的相对坐标 m_wndCatalog.ScreenToClient(&ptLoc); // 鼠标指针是否在 TreeView 窗口内 if (::PtInRect(&rc, ptLoc)) { UINT flags = 0; m_pData = m_wndCatalog.HitTest(ptLoc, &flags); if (FALSE == m_pData.IsNull()) { TREE_ITEM_DATA * pTmp = (TREE_ITEM_DATA *)m_pData.GetData(); CMenuHandle mnuPopUp; CMenu mnuTemp; mnuTemp.LoadMenu(IDR_MENU_EXPORT); mnuPopUp = mnuTemp.GetSubMenu(0); if (pTmp->dwStgType == STGTY_STORAGE) { mnuPopUp.EnableMenuItem(ID_FILE_ADD_STG, MF_BYCOMMAND|MF_ENABLED); mnuPopUp.EnableMenuItem(ID_FILE_ADD_STM, MF_BYCOMMAND|MF_ENABLED); } mnuPopUp.TrackPopupMenu(0, ptScr.x, ptScr.y, *this); return 0; } } } return 0; }
LRESULT CResendDlg::OnListRClick(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) { CPoint pt; GetCursorPos(&pt); CMenu menu = LoadMenu(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_POPUPMENU)); CMenu submenu = menu.GetSubMenu(5); strconv_t strconv; CString sSelectAll = Utility::GetINIString(g_CrashInfo.m_sLangFileName, _T("ResendDlg"), _T("SelectAll")); CString sDeselectAll = Utility::GetINIString(g_CrashInfo.m_sLangFileName, _T("ResendDlg"), _T("DeselectAll")); CString sDeleteSelected = Utility::GetINIString(g_CrashInfo.m_sLangFileName, _T("ResendDlg"), _T("DeleteSelected")); CString sDeleteAll = Utility::GetINIString(g_CrashInfo.m_sLangFileName, _T("ResendDlg"), _T("DeleteAll")); MENUITEMINFO mii; memset(&mii, 0, sizeof(MENUITEMINFO)); mii.cbSize = sizeof(MENUITEMINFO); mii.fMask = MIIM_STRING; mii.dwTypeData = sSelectAll.GetBuffer(0); submenu.SetMenuItemInfo(ID_MENU6_SELECTALL, FALSE, &mii); mii.dwTypeData = sDeselectAll.GetBuffer(0); submenu.SetMenuItemInfo(ID_MENU6_DESELECTALL, FALSE, &mii); mii.dwTypeData = sDeleteSelected.GetBuffer(0); submenu.SetMenuItemInfo(ID_MENU6_DELETESELECTED, FALSE, &mii); mii.dwTypeData = sDeleteAll.GetBuffer(0); submenu.SetMenuItemInfo(ID_MENU6_DELETEALL, FALSE, &mii); // Get count of checked list items int nItems = 0; int nChecked = 0; int i; for(i=0; i<m_listReports.GetItemCount(); i++) { nItems++; // If list item checked if(m_listReports.GetCheckState(i)) nChecked++; } submenu.EnableMenuItem(ID_MENU6_SELECTALL, nItems>0?MF_ENABLED:MF_DISABLED); submenu.EnableMenuItem(ID_MENU6_DESELECTALL, nItems>0?MF_ENABLED:MF_DISABLED); submenu.EnableMenuItem(ID_MENU6_DELETESELECTED, nChecked>0?MF_ENABLED:MF_DISABLED); submenu.EnableMenuItem(ID_MENU6_DELETEALL, nItems>0?MF_ENABLED:MF_DISABLED); submenu.TrackPopupMenu(0, pt.x, pt.y, m_hWnd); return 0; return 0; }
void CLogView::OnRclick(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here *pResult = 0; CMenu popup; popup.LoadMenu(IDR_LOG); CMenu* pM = popup.GetSubMenu(0); CPoint p; GetCursorPos(&p); pM->TrackPopupMenu(TPM_LEFTALIGN, p.x, p.y, this); }
//右键单击,弹出菜单 LRESULT CDlgTempFavorite::OnRightClickChannel(WPARAM wParam, LPARAM lParam) { int iServerID = (int)wParam; //窗口标识 int iWinID = lParam / 0x100; int ich = lParam & 0xff; int iYTID = wParam % 0x1000; wParam = wParam / 0x1000; if (iServerID >= 4 || iServerID < 0) return 1; if (m_CurrentCh != (int)iServerID) { CRect rc; if (m_CurrentCh >= 0 && m_CurrentCh < 4) { DrawRect(m_CurrentCh, 0); } if ((iServerID >= 0) && (iServerID < 4)) m_CurrentCh = iServerID; else m_CurrentCh = 0; DrawRect(m_CurrentCh, 1); } CMenu popMenu; popMenu.LoadMenu(IDR_MENU_TEMPFAVORITE); CMenu *pMenu = popMenu.GetSubMenu(0); CPoint posMouse; GetCursorPos(&posMouse); popMenu.GetSubMenu(0)->TrackPopupMenu(TPM_RIGHTBUTTON | TPM_RIGHTALIGN, posMouse.x, posMouse.y, this); return 1; }
LRESULT CVGMFileListView::OnContextMenu(HWND hwndCtrl, CPoint ptClick ) { //bHandled = TRUE; //CTreeViewCtrlEx* treeview = (CTreeViewCtrlEx*)hwndCtrl; // if Shift-F10 if (ptClick.x == -1 && ptClick.y == -1) ptClick = (CPoint) GetMessagePos(); ScreenToClient(&ptClick); UINT uFlags; //HTREEITEM htItem = GetTreeCtrl().HitTest( ptMousePos, &uFlags ); int iItem = HitTest( ptClick, &uFlags ); if( iItem == -1 ) return 0; vector<VGMFile*> vgmfiles; UINT selectedCount = GetSelectedCount(); if (selectedCount > 1) { iItem = -1; for (UINT i = 0; i < selectedCount; i++) { iItem = GetNextItem(iItem, LVNI_SELECTED); ATLASSERT(iItem != -1); vgmfiles.push_back((VGMFile*)GetItemData(iItem)); } } else { vgmfiles.push_back((VGMFile*)GetItemData(iItem)); } if (vgmfiles.size() > 1) { CMenu mnuContext; mnuContext.LoadMenu(IDR_RAWFILE); CMenuHandle pPopup = mnuContext.GetSubMenu(0); ClientToScreen(&ptClick); pPopup.TrackPopupMenu( TPM_LEFTALIGN, ptClick.x, ptClick.y, hwndCtrl ); } else { VGMFile* pvgmfile = vgmfiles[0]; ClientToScreen(&ptClick); ItemContextMenu(hwndCtrl, ptClick, pvgmfile); } return NULL; }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { LOG(INFO) << "CMainFrame::OnCreate()"; if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; // create a view to occupy the client area of the frame if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL)) { TRACE0("Failed to create view window\n"); return -1; } CMenu* pMenu = GetMenu(); CMenu* pSubMenu = pMenu->GetSubMenu(1); // Init Video Device int nVideo = XIS_GetVideoCaptureCount(); LOG(INFO) << "XIS_GetVideoCaptureCount(): " << nVideo; for (int i = 0; i < nVideo; i++) { VIDEO_CAPTURE_INFO vci; if (XIS_GetVideoCaptureInfo(i, &vci)) { pSubMenu->InsertMenu(i + 1, MF_BYPOSITION, ID_DEVICE_BEGIN + 1 + i, vci.szName); } } // Init Audio Device int nAudio = XIS_GetAudioCaptureCount(); LOG(INFO) << "XIS_GetAudioCaptureCount(): " << nAudio; if (nAudio > 0) { pSubMenu->InsertMenu(nVideo + 1, MF_BYPOSITION, MF_SEPARATOR); for (int i = 0; i < nAudio; i++) { AUDIO_CAPTURE_INFO_EX aci; if (XIS_GetAudioCaptureInfoEx(i, &aci)) { pSubMenu->InsertMenu(nVideo + i + 2, MF_BYPOSITION, ID_DEVICE_BEGIN + nVideo + 1 + i, aci.szName); } } } pSubMenu->DeleteMenu(0, MF_BYPOSITION); #if defined(USE_FOR_BARCODE) SetWindowText(_T("ÖÐÔÆÖǻ۶þάÂë½ØÆÁ³ÌÐò")); LOG(INFO) << "SetWindowText: ÖÐÔÆÖǻ۶þάÂë½ØÆÁ³ÌÐò"; #else SetWindowText(_T("ÖÐÔÆÖÇ»ÛX¹â»ú½ØÆÁ³ÌÐò")); LOG(INFO) << "SetWindowText: ÖÐÔÆÖÇ»ÛX¹â»ú½ØÆÁ³ÌÐò"; #endif return 0; }
void CEditButton::OnClicked() { switch (m_eType) { case SEARCH_DIRECTORY: { CSHFileInfo sfi; sfi.m_strTitle = _T("Select Folder Location:"); if (sfi.BrowseForFolder(GetParent()) == IDOK) { m_pWnd->SetWindowText(sfi.m_strPath); } } break; case SEARCH_FILE: { static char BASED_CODE szFilter[] = _T("All Files (*.*)|*.*||"); CFileDialog dlg(TRUE, _T("*.*"), NULL, OFN_HIDEREADONLY, szFilter, GetParent()); if (dlg.DoModal() == IDOK) { m_pWnd->SetWindowText(dlg.GetPathName()); } } break; case SEARCH_POPUP: { ASSERT(m_nMenu!=-1); SetState(TRUE); CRect rc; GetWindowRect(&rc); CWnd* pParentWnd = m_pWnd->GetParent(); CMenu menu; VERIFY(menu.LoadMenu(m_nMenu)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_VERTICAL, rc.right, rc.top, pParentWnd, &rc); // Return the button state to normal. SetState(FALSE); } break; } }
void CToolBarEx::OnDropDown(NMHDR* pNMHDR, LRESULT* pResult) { LPNMTOOLBAR pNMTB = reinterpret_cast<LPNMTOOLBAR>(pNMHDR); CMenu menu; if (!menu.LoadMenu(menuID)) return; RECT rc; SendMessage(TB_GETRECT, (WPARAM)pNMTB->iItem, (LPARAM)&rc); ClientToScreen(&rc); menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, rc.left, rc.bottom, this, 0); }
void fsContextHelpMgr::ShowMenu() { if (m_iLastCtrl == -1) return; CMenu menu; menu.LoadMenu (IDM_WT); CMenu *popup = menu.GetSubMenu (0); popup->ModifyMenu (ID_WHATISTHIS, MF_BYCOMMAND|MF_STRING, ID_WHATISTHIS, LS (L_WHATISTHIS)); popup->TrackPopupMenu (TPM_RIGHTBUTTON | TPM_TOPALIGN | TPM_LEFTALIGN, m_ptLast.x, m_ptLast.y, m_pLastDlg); }
void CActionCtrl::OnContextMenu(CWnd* pWnd, CPoint point) { // TODO: Add your message handler code here CMenu menu; menu.LoadMenu(IDR_OUTPUT_POPUP); CMenu* pSumMenu = menu.GetSubMenu(0); ((CWinAppEx*)AfxGetApp())->GetContextMenuManager()->ShowPopupMenu(pSumMenu->GetSafeHmenu(),point.x, point.y, this, TRUE); SetFocus(); }