//************************************************************************************* BOOL CFavorit::CreateMenu (CMenu& menu) { ASSERT (menu.GetSafeHmenu () == NULL); ASSERT (m_uiCommand == 0); if (!menu.CreatePopupMenu ()) { ASSERT (FALSE); return FALSE; } for (POSITION pos = m_lstSubItems.GetHeadPosition (); pos != NULL;) { CFavorit* pFavorit = (CFavorit*) m_lstSubItems.GetNext (pos); ASSERT_VALID (pFavorit); if (pFavorit->m_uiCommand != 0) { menu.InsertMenu ((UINT)-1, MF_BYPOSITION | MF_STRING, pFavorit->m_uiCommand, pFavorit->m_strName); } else { CMenu subMenu; if (pFavorit->CreateMenu (subMenu)) { menu.InsertMenu ((UINT) -1, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR) subMenu.Detach (), pFavorit->m_strName); } } } return TRUE; }
void CRemoteFileDialog::OnViewMenu() { // build the view menu manually (because we're a non-resource dependent file) CMenu menu; if (menu.CreatePopupMenu()) { menu.InsertMenu(0, MF_STRING | MF_BYPOSITION, ID_VIEW_LARGEICON, _T("Lar&ge Icons")); menu.InsertMenu(1, MF_STRING | MF_BYPOSITION, ID_VIEW_SMALLICON, _T("S&mall Icons")); menu.InsertMenu(2, MF_STRING | MF_BYPOSITION, ID_VIEW_LIST, _T("&List")); menu.InsertMenu(3, MF_STRING | MF_BYPOSITION, ID_VIEW_DETAILS, _T("&Details")); // check the appropriate one int nView = (m_lcFiles.GetStyle() & LVS_TYPEMASK); menu.CheckMenuRadioItem(ID_VIEW_LARGEICON, ID_VIEW_DETAILS, VIEWIDS[nView], MF_BYCOMMAND); // get the button rect in screen coords CRect rButton; m_toolbar.GetItemRect(1, rButton); m_toolbar.ClientToScreen(rButton); m_toolbar.GetToolBarCtrl().PressButton(ID_VIEWMENU); menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, rButton.left, rButton.bottom, this); m_toolbar.GetToolBarCtrl().PressButton(ID_VIEWMENU, FALSE); } }
void CClipboardListBox::OnRButtonUp(UINT nFlags, CPoint point) { const UINT_PTR IDM_SELECTALL = 0x80fb; const UINT_PTR IDM_COPY = 0x80fc; const UINT_PTR IDM_CLEAR = 0x80fd; CMenu menu; menu.CreatePopupMenu(); menu.InsertMenu(0, MF_BYPOSITION|MF_STRING, IDM_SELECTALL, "Select All"); menu.InsertMenu(1, MF_BYPOSITION|MF_STRING, IDM_COPY, "Copy"); menu.InsertMenu(2, MF_BYPOSITION|MF_STRING, IDM_CLEAR, "Clear"); this->ClientToScreen(&point); UINT_PTR cmd = menu.TrackPopupMenu(TPM_LEFTALIGN|TPM_TOPALIGN|TPM_RETURNCMD, point.x, point.y, this); if(IDM_COPY==cmd) { DoCopy(); } else if(IDM_CLEAR==cmd) { ResetContent(); } else if(IDM_SELECTALL==cmd) { SelectAll(); } return; //CListBox::OnRButtonUp(nFlags, point); }
void CMainWindow::createCustomMenu() { CMenu menu; CMenu sub; CMenu popup; if (!m_pBrowserEng->GetHTMLWND()) return; VERIFY(menu.CreateMenu()); VERIFY(popup.CreatePopupMenu()); menu.AppendMenu(MF_POPUP, (UINT) popup.m_hMenu, _T("")); RHODESAPP().getAppMenu().copyMenuItems(m_arAppMenuItems); #ifdef ENABLE_DYNAMIC_RHOBUNDLE String strIndexPage = CFilePath::join(RHODESAPP().getStartUrl(),"index"RHO_ERB_EXT); if ( RHODESAPP().getCurrentUrl().compare(RHODESAPP().getStartUrl()) == 0 || RHODESAPP().getCurrentUrl().compare(strIndexPage) == 0 ) m_arAppMenuItems.addElement(CAppMenuItem("Reload RhoBundle","reload_rhobundle")); #endif //ENABLE_DYNAMIC_RHOBUNDLE //update UI with custom menu items USES_CONVERSION; for ( int i = m_arAppMenuItems.size() - 1; i >= 0; i--) { CAppMenuItem& oItem = m_arAppMenuItems.elementAt(i); if (oItem.m_eType == CAppMenuItem::emtSeparator) popup.InsertMenu(0, MF_BYPOSITION | MF_SEPARATOR, (UINT_PTR)0, (LPCTSTR)0); else { StringW strLabelW = convertToStringW(oItem.m_strLabel); popup.InsertMenu(0, MF_BYPOSITION, ID_CUSTOM_MENU_ITEM_FIRST + i, oItem.m_eType == CAppMenuItem::emtClose ? _T("Exit") : strLabelW.c_str() ); } } RECT rect; GetWindowRect(&rect); #if defined( OS_PLATFORM_MOTCE ) rect.right = 1; rect.bottom = m_menuBarHeight+1; #else rect.bottom -= m_menuBarHeight; #endif sub.Attach(menu.GetSubMenu(0)); sub.TrackPopupMenu( #if defined( OS_PLATFORM_MOTCE ) TPM_LEFTALIGN, #else TPM_RIGHTALIGN | TPM_BOTTOMALIGN | TPM_LEFTBUTTON | TPM_VERNEGANIMATION, #endif rect.right-1, rect.bottom-1, m_hWnd); sub.Detach(); }
DWORD CMainFrame::SysTrayMenu() { CMenu cmenu; CPoint mouse; CString cstr; DWORD nMenuItem = -1; int rc = -1; MENUITEMINFO mi = {0}; ULONG iData[200] = {0}; WCHAR tData[200] = {0}; BOOL bChecked = FALSE; int bSilentSelect = GetSilentSelectFlag(); cmenu.CreatePopupMenu(); // Menu Item 0 -- Exit App cstr.LoadString(IDS_EXIT_APP_NOW); cmenu.InsertMenu(0, MF_BYPOSITION | MF_STRING | MF_ENABLED, IDS_EXIT_APP_MSG, cstr.GetBuffer(64)); cstr.ReleaseBuffer(); // Menu Item 1 -- Silent Cert Select (first check if IE supports this) if (bSilentSelect == -1) { // IE doesn't support Silent Select (version prior to 5.5) cstr.LoadString(IDS_NO_IE_SILENT_SELECT); cmenu.InsertMenu(-1, MF_BYPOSITION | MF_STRING | MF_ENABLED, IDS_SILENT_SELECT, cstr.GetBuffer(64)); cstr.ReleaseBuffer(); } else { // IE does support -- use check to indicate if it's currently enabled cstr.LoadString(IDS_HAVE_SILENT_SELECT); bChecked = (bSilentSelect == TRUE) ? MF_CHECKED : MF_UNCHECKED; cmenu.InsertMenu(-1, MF_BYPOSITION | MF_STRING | MF_ENABLED | bChecked, IDS_SILENT_SELECT, cstr.GetBuffer(64)); cstr.ReleaseBuffer(); } // Default to "Exit App" ::SetMenuDefaultItem(cmenu.m_hMenu, 0, TRUE); GetCursorPos(&mouse); this->SetForegroundWindow(); nMenuItem = cmenu.TrackPopupMenu(TPM_RETURNCMD | TPM_RIGHTALIGN | TPM_RIGHTBUTTON, mouse.x, mouse.y, this); cmenu.DestroyMenu(); return nMenuItem; }
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 CGroupDlg::OnMacroses() { CMenu menu; menu.CreatePopupMenu (); CString str; str.Format ("%%server%% - %s", LS (L_SERVER_MACROS_DESC)); menu.InsertMenu (0, MF_BYPOSITION | MF_STRING, ID_FOLDER_MACROS_0, str); str.Format ("%%path_on_server%% - %s", LS (L_PATHONSERVER_MACROS_DESC)); menu.InsertMenu (1, MF_BYPOSITION | MF_STRING, ID_FOLDER_MACROS_0 + 1, str); str.Format ("%%year%% - %s", LS (L_YEAR_MACROS_DESC)); menu.InsertMenu (2, MF_BYPOSITION | MF_STRING, ID_FOLDER_MACROS_0 + 2, str); str.Format ("%%month%% - %s", LS (L_MONTH_MACROS_DESC)); menu.InsertMenu (3, MF_BYPOSITION | MF_STRING, ID_FOLDER_MACROS_0 + 3, str); str.Format ("%%day%% - %s", LS (L_DAY_MACROS_DESC)); menu.InsertMenu (4, MF_BYPOSITION | MF_STRING, ID_FOLDER_MACROS_0 + 4, str); str.Format ("%%date%% - %s", LS (L_DATE_MACROS_DESC)); menu.InsertMenu (5, MF_BYPOSITION | MF_STRING, ID_FOLDER_MACROS_0 + 5, str); str.Format ("%%sdrive%% - %s", LS (L_STARTDRIVELETTER)); menu.InsertMenu (6, MF_BYPOSITION | MF_STRING, ID_FOLDER_MACROS_0 + 6, str); str.Format ("%%userprofile%% - %s", LS (L_PATHTOPROFILE)); menu.InsertMenu (7, MF_BYPOSITION | MF_STRING, ID_FOLDER_MACROS_0 + 7, str); CPoint pt; GetCursorPos (&pt); menu.TrackPopupMenu (TPM_RIGHTBUTTON | TPM_TOPALIGN | TPM_RIGHTALIGN, pt.x, pt.y, this); }
void DisplayView::PrepareCompatibleFiltersMenu(CMenu &menu, Pin *pin) { /* Enumerate output mediatypes and look for compatible filters. */ compatible_filters.filters.RemoveAll(); // ignore invalid and connected pins if (!pin || !(pin->pin) || (pin->dir == PINDIR_INPUT)) return ; if (pin->connected) return ; // enumerate media types DSUtil::MediaTypes mtypes; DSUtil::EnumMediaTypes(pin->pin, mtypes); if (mtypes.GetCount() <= 0) return ; // now try to enumerate compatible filters int ret = compatible_filters.EnumerateCompatible(mtypes, MERIT_UNLIKELY, false, render_params.exact_match_mode); if ((ret == 0) && (compatible_filters.filters.GetCount() > 0)) { CMenu submenu; submenu.CreatePopupMenu(); CMenu &active_menu = submenu; for (int i=0; i<compatible_filters.filters.GetCount(); i++) { DSUtil::FilterTemplate &filt = compatible_filters.filters[i]; CString merit; merit.Format(_T("%08x)"), filt.merit); merit = merit.MakeUpper(); int idx = active_menu.GetMenuItemCount(); CString name = filt.name + _T("\t(0x") + merit; active_menu.InsertMenu(idx, MF_BYPOSITION | MF_STRING, ID_COMPATIBLE_FILTER + i, name); } // do insert the menu int count = menu.GetMenuItemCount(); menu.InsertMenu(count++, MF_BYPOSITION | MF_SEPARATOR); menu.InsertMenu(count, MF_BYPOSITION | MF_STRING, 0, _T("Compatible filters")); menu.ModifyMenu(count, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)submenu.m_hMenu, _T("Compatible filters")); submenu.Detach(); } }
void CChildFrame::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd) { CMDIChildWnd::OnMDIActivate(bActivate, pActivateWnd, pDeactivateWnd); if (bActivate) { CMenu* pTopMenu = AfxGetMainWnd()->GetMenu(); for(unsigned int i = 0; i < pTopMenu->GetMenuItemCount(); i++) { CMenu *pSubMenu = pTopMenu->GetSubMenu(i); if (pSubMenu) for(unsigned int j=0; j < pSubMenu->GetMenuItemCount(); j++) { if (pSubMenu->GetMenuItemID(j) == ID_PORTS_CREATE) { CMenu ResourceMenu; ResourceMenu.CreatePopupMenu(); for(int k=0;k < Port::portCount() ; k++) ResourceMenu.AppendMenu(MF_STRING,ID_RESOURCE_PORT_BEGIN + k, Port::portName( k ) ); pSubMenu->DeleteMenu(j,MF_BYPOSITION); pSubMenu->InsertMenu(j,MF_POPUP|MF_BYPOSITION,(unsigned int)ResourceMenu.Detach(),_T("Create")); return; } } } } }
void CAbstractVstEditor::UpdateOutputMenu() { CMenu* pInfoMenu = m_pMenu->GetSubMenu(2); pInfoMenu->DeleteMenu(1, MF_BYPOSITION); if (m_pOutputMenu->m_hMenu) { m_pOutputMenu->DestroyMenu(); } if (!m_pOutputMenu->m_hMenu) { m_pOutputMenu->CreatePopupMenu(); } CArray<CVstPlugin*, CVstPlugin*> outputPlugs; m_pVstPlugin->GetOutputPlugList(outputPlugs); CString name; for (int nPlug=0; nPlug<outputPlugs.GetSize(); nPlug++) { if (outputPlugs[nPlug] != NULL) { name.Format("FX%02d: %s", outputPlugs[nPlug]->m_nSlot+1, outputPlugs[nPlug]->m_pMixStruct->Info.szName); m_pOutputMenu->AppendMenu(MF_STRING, ID_PLUGSELECT+outputPlugs[nPlug]->m_nSlot, name); } else { name = "Master Output"; m_pOutputMenu->AppendMenu(MF_STRING|MF_GRAYED, NULL, name); } } pInfoMenu->InsertMenu(1, MF_BYPOSITION|MF_POPUP, (UINT)m_pOutputMenu->m_hMenu, "Ou&tputs"); }
//右键弹出处理 void CComputerListView::OnContextMenu(CWnd*, CPoint point) { m_SelectRows.RemoveAll(); CMenu menu; CBCGPGridRow* pRow = GetGridCtrl()->GetCurSel(); if (pRow != NULL)//存在选中的子行 { CList<CBCGPGridItem*, CBCGPGridItem*> lstSelected; GetGridCtrl()->GetSelectedItems(lstSelected);//多重选择队列 POSITION pos = lstSelected.GetHeadPosition();//第一个 while (pos != NULL) { CBCGPGridItem* pItem = lstSelected.GetNext(pos);//下一个 m_SelectRows.Add((UINT)pItem->GetParentRow()->GetData());//保存选中的序号 } SendMessage(WM_LBUTTONUP);//弹起 VERIFY(menu.LoadMenu(IDR_COMPUTER_MENU));//载入 CMenu* pPopup = menu.GetSubMenu(0);//第一个子菜单 ASSERT(pPopup != NULL); #ifndef __USING_INTER_RESOURCE HMENU hTmp = pPopup->GetSubMenu(6)->GetSafeHmenu(); pPopup->ModifyMenu((UINT_PTR)hTmp,MF_POPUP,(UINT_PTR)hTmp,LOAD_STRING(IDS_REMOTE_OPERATION)); #endif //弹出菜单 theApp.GetContextMenuManager()->ShowPopupMenu(pPopup->Detach(), point.x, point.y, this, TRUE); } else { //扫描鼠标位置,点击在列栏上,才弹出此菜单 CRect rect; m_pWndGridCtrl->GetClientRect(rect); rect.bottom = 21; //栏高度大概为21个像素 ClientToScreen(rect); if (rect.PtInRect(point))//点击在栏上 { VERIFY(menu.LoadMenu(IDR_MENU_COLUMN));//载入列菜单 CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); for (INT i = 0; i < GetGridCtrl()->GetColumnCount(); i++)//列枚举 {//动态插入与列项有关的菜单 pPopup->InsertMenu(i, MF_BYPOSITION, IDM_MINCOLUMNCMD + i, GetGridCtrl()->GetColumnName(i)); pPopup->CheckMenuItem(i, MF_BYPOSITION | (GetGridCtrl()->GetColumnVisible(i) ? MF_CHECKED : MF_UNCHECKED)); } theApp.GetContextMenuManager()->ShowPopupMenu(pPopup->Detach(), point.x, point.y, this, TRUE); } } }
//---------------------------------------------------------------------------- // Function CreateSubMenu // @func adds submenu to menu // @rdesc pointer to created menu (CMenu*) // @parm CFrameWnd | *pWnd | frame window to use // @parm UINT | mainMenuItem | main menu item in which's menu submenu is to be added // @parm UINT | itemIndex | index of submenu in menu // @parm const char | *string | item caption (next to > sign) // @parm MenuItemData | *data | pointer to null terminated list of menu items (default NULL) //---------------------------------------------------------------------------- // @prog // Anneke Sicherer-Roetman // @revs // 13-03-2000 - First implementation //---------------------------------------------------------------------------- // @todo //---------------------------------------------------------------------------- CMenu *AddSubMenu(CMenu *pMenuBar, UINT mainMenuItem, UINT itemIndex, const char *string, MenuItemData *data /* = NULL */) { ASSERT(string); ASSERT_VALID(pMenuBar); CMenu *pSubMenu = pMenuBar->GetSubMenu(mainMenuItem); ASSERT_VALID(pSubMenu); CMenu *pMenu = new CMenu; VERIFY(pMenu->CreatePopupMenu()); VERIFY(pSubMenu->InsertMenu(itemIndex, MF_BYPOSITION | MF_POPUP, (UINT)pMenu->m_hMenu, string)); if (data) { for (int i = 0; data[i].string; i++) { AddSubMenuItem(pMenu, data[i].cmdID, data[i].string); } } return pMenu; }
/******************************************************************************* Function Name : OnContextMenu Input(s) : pWnd, point Output : - Functionality : Show the context menu with a list of column names as menu items. Member of : CRxMsgList Author(s) : Arunkumar K Date Created : 20-05-2010 Modifications : *******************************************************************************/ void CRxMsgList::OnContextMenu(CWnd* /*pWnd*/, CPoint point) { if (point.x==-1 && point.y==-1) { // OBS! point is initialized to (-1,-1) if using SHIFT+F10 or VK_APPS } else { CPoint pt = point; ScreenToClient(&pt); CRect headerRect; GetHeaderCtrl()->GetClientRect(&headerRect); if (headerRect.PtInRect(pt)) { // Show context-menu with the option to show hide columns CMenu menu; if (menu.CreatePopupMenu()) { for( int i = GetColumnStateCount()-1 ; i >= 0; --i) { UINT uFlags = MF_BYPOSITION | MF_STRING; // Put check-box on context-menu if (IsColumnVisible(i)) { uFlags |= MF_CHECKED; } else { uFlags |= MF_UNCHECKED; } if(i == 0) //Disable 'Time' column { break; } // Retrieve column-title LVCOLUMN lvc = {0}; lvc.mask = LVCF_TEXT; char sColText[256]; lvc.pszText = sColText; lvc.cchTextMax = 30; //Set the Width of Menu Items here //lvc.cchTextMax = sizeof(sColText)-1; VERIFY( GetColumn(i, &lvc) ); menu.InsertMenu(0, uFlags, i, lvc.pszText); } menu.TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, this, 0); } } } }
BOOL CDownloadMonitorDlg::OnInitDialog() { CSkinDialog::OnInitDialog(); SkinMe( _T("CDownloadMonitorDlg"), IDI_DOWNLOAD_MONITOR ); CMenu* pMenu = GetSystemMenu( FALSE ); pMenu->InsertMenu( 0, MF_BYPOSITION|MF_SEPARATOR, ID_SEPARATOR ); pMenu->InsertMenu( 0, MF_BYPOSITION|MF_STRING, SC_NEXTWINDOW, _T("&Always on Top") ); CSingleLock pLock( &Transfers.m_pSection, TRUE ); if ( Downloads.Check( m_pDownload ) ) { m_sName = m_pDownload->m_sName; m_wndIcon.SetIcon( ShellIcons.ExtractIcon( ShellIcons.Get( m_sName, 32 ), 32 ) ); m_wndFile.SetWindowText( m_sName ); } pLock.Unlock(); m_pGraph = new CLineGraph(); m_pItem = new CGraphItem( 0, 1.0f, RGB( 0xFF, 0, 0 ) ); m_pGraph->m_bShowLegend = FALSE; m_pGraph->m_bShowAxis = FALSE; m_pGraph->m_crBack = RGB( 255, 255, 240 ); m_pGraph->m_crGrid = RGB( 220, 220, 170 ); m_pGraph->m_nMinGridVert = 16; m_pGraph->AddItem( m_pItem ); OnTimer( 1 ); CenterWindow(); ShowWindow( SW_SHOW ); SetTimer( 1, 100, NULL ); EnableToolTips(); return TRUE; }
void CAbstractVstEditor::UpdateInputMenu() { CMenu* pInfoMenu = m_pMenu->GetSubMenu(2); pInfoMenu->DeleteMenu(0, MF_BYPOSITION); CModDoc* pModDoc = m_pVstPlugin->GetModDoc(); module_renderer* pSndFile = pModDoc->GetSoundFile(); if (m_pInputMenu->m_hMenu) { m_pInputMenu->DestroyMenu(); } if (!m_pInputMenu->m_hMenu) { m_pInputMenu->CreatePopupMenu(); } CString name; CArray<CVstPlugin*, CVstPlugin*> inputPlugs; m_pVstPlugin->GetInputPlugList(inputPlugs); for (int nPlug=0; nPlug<inputPlugs.GetSize(); nPlug++) { name.Format("FX%02d: %s", inputPlugs[nPlug]->m_nSlot+1, inputPlugs[nPlug]->m_pMixStruct->Info.szName); m_pInputMenu->AppendMenu(MF_STRING, ID_PLUGSELECT+inputPlugs[nPlug]->m_nSlot, name); } CArray<UINT, UINT> inputChannels; m_pVstPlugin->GetInputChannelList(inputChannels); for (int nChn=0; nChn<inputChannels.GetSize(); nChn++) { if (nChn==0 && inputPlugs.GetSize()) { m_pInputMenu->AppendMenu(MF_SEPARATOR); } name.Format("Chn%02d: %s", inputChannels[nChn]+1, pSndFile->ChnSettings[inputChannels[nChn]].szName); m_pInputMenu->AppendMenu(MF_STRING, NULL, name); } CArray<UINT, UINT> inputInstruments; m_pVstPlugin->GetInputInstrumentList(inputInstruments); bool checked; for (int nIns=0; nIns<inputInstruments.GetSize(); nIns++) { checked=false; if (nIns==0 && (inputPlugs.GetSize() || inputChannels.GetSize())) { m_pInputMenu->AppendMenu(MF_SEPARATOR); } name.Format("Ins%02d: %s", inputInstruments[nIns], (LPCTSTR)pSndFile->GetInstrumentName(inputInstruments[nIns])); if (inputInstruments[nIns] == (UINT)m_nInstrument) checked=true; m_pInputMenu->AppendMenu(MF_STRING|(checked?MF_CHECKED:0), ID_SELECTINST+inputInstruments[nIns], name); } if ((inputPlugs.GetSize() == 0) && (inputChannels.GetSize() == 0) && (inputInstruments.GetSize() == 0)) { m_pInputMenu->AppendMenu(MF_STRING|MF_GRAYED, NULL, "None"); } pInfoMenu->InsertMenu(0, MF_BYPOSITION|MF_POPUP, (UINT)m_pInputMenu->m_hMenu, "I&nputs"); }
//------------------------------------------------------------------------ //! Override this method to change the context menu when activating context //! menu for the group headers //! //! @param pWnd Handle to the window in which the user right clicked the mouse //! @param point Position of the cursor, in screen coordinates, at the time of the mouse click. //! @param nGroupId ID of the group //------------------------------------------------------------------------ void CGridListCtrlGroups::OnContextMenuGroup(CWnd* pWnd, CPoint point, int nGroupId) { CMenu menu; UINT uFlags = MF_BYPOSITION | MF_STRING; VERIFY( menu.CreatePopupMenu() ); const CString& groupHeader = GetGroupHeader(nGroupId); // Provide menu-options for collapsing groups, if the collapsible state is not available #ifndef LVGS_COLLAPSIBLE if (IsGroupStateEnabled()) { if (HasGroupState(nGroupId,LVGS_COLLAPSED)) { CString menuText = CString(_T("Expand group: ")) + groupHeader; menu.InsertMenu(0, uFlags, 1, menuText); } else { CString menuText = CString(_T("Collapse group: ")) + groupHeader; menu.InsertMenu(0, uFlags, 2, menuText); } } #endif if (GetExtendedStyle() & LVS_EX_CHECKBOXES) { CString menuText = CString(_T("Check group: ")) + groupHeader; menu.InsertMenu(1, uFlags, 3, menuText); menuText = CString(_T("Uncheck group: ")) + groupHeader; menu.InsertMenu(2, uFlags, 4, menuText); } int nResult = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RETURNCMD, point.x, point.y, this, 0); switch(nResult) { case 1: SetGroupState(nGroupId, LVGS_NORMAL); break; case 2: SetGroupState(nGroupId, LVGS_COLLAPSED); break; case 3: CheckEntireGroup(nGroupId, true); break; case 4: CheckEntireGroup(nGroupId, false); break; } }
//------------------------------------------------------------------------ //! Override this method to change the context menu when activating context //! menu in client area with no rows //! //! @param pWnd Handle to the window in which the user right clicked the mouse //! @param point Position of the cursor, in screen coordinates, at the time of the mouse click. //------------------------------------------------------------------------ void CGridListCtrlGroups::OnContextMenuGrid(CWnd* pWnd, CPoint point) { if (IsGroupStateEnabled()) { CMenu menu; UINT uFlags = MF_BYPOSITION | MF_STRING; VERIFY( menu.CreatePopupMenu() ); menu.InsertMenu(0, uFlags, 1, _T("Expand all groups")); menu.InsertMenu(1, uFlags, 2, _T("Collapse all groups")); menu.InsertMenu(2, uFlags, 3, _T("Disable grouping")); int nResult = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RETURNCMD, point.x, point.y, this, 0); switch(nResult) { case 1: ExpandAllGroups(); break; case 2: CollapseAllGroups(); break; case 3: RemoveAllGroups(); EnableGroupView(FALSE); break; } } }
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 CMainFrame::OnInitMenu(CMenu* pMenu) { CMDIFrameWnd::OnInitMenu(pMenu); //find the help submenu CMenu* pSubMenu = NULL; CString strHelp; strHelp.LoadString(IDS_TIPOFTHEDAYHELP); CString strMenu; int nMenuCount = pMenu->GetMenuItemCount(); BOOL bFound = FALSE; for (int i=0; i < nMenuCount; i++) { pMenu->GetMenuString(i, strMenu, MF_BYPOSITION); if (strMenu == strHelp) { pSubMenu = pMenu->GetSubMenu(i); bFound = TRUE; ASSERT(pSubMenu != NULL); } } CString strTipMenu; strTipMenu.LoadString(IDS_TIPOFTHEDAYMENU); if(bFound) { //check to see if the menu has already been added. pSubMenu->GetMenuString(0, strMenu, MF_BYPOSITION); //only add it if the tips were loaded OK if( strMenu != strTipMenu && m_wndMDIClientArea.m_fTipsLoadedOK ) { pSubMenu->InsertMenu(0, MF_BYPOSITION); pSubMenu->InsertMenu(0, MF_STRING|MF_BYPOSITION, IDS_TIPOFTHEDAY, strTipMenu); } } }
// CMainFrame::OnChangeFileMenu() is a menu command handler for // CMainFrame class, which in turn is a CFrameWnd-derived class. // It modifies the File menu by inserting, removing and renaming // some menu items. Other operations include associating a context // help id and setting default menu item to the File menu. // CMainFrame is a CFrameWnd-derived class. void CMainFrame::OnChangeFileMenu() { // Get the menu from the application window. CMenu* mmenu = GetMenu(); // Look for "File" menu. int pos = FindMenuItem(mmenu, _T("&File")); if (pos == -1) return; // Remove "New" menu item from the File menu. CMenu* submenu = mmenu->GetSubMenu(pos); pos = FindMenuItem(submenu, _T("&New\tCtrl+N")); if (pos > -1) submenu->RemoveMenu(pos, MF_BYPOSITION); // Look for "Open" menu item from the File menu. Insert a new // menu item called "Close" right after the "Open" menu item. // ID_CLOSEFILE is the command id for the "Close" menu item. pos = FindMenuItem(submenu, _T("&Open...\tCtrl+O")); if (pos > -1) submenu->InsertMenu(pos + 1, MF_BYPOSITION, ID_CLOSEFILE, _T("&Close")); // Rename menu item "Exit" to "Exit Application". pos = FindMenuItem(submenu, _T("E&xit")); if (pos > -1) { UINT id = submenu->GetMenuItemID(pos); submenu->ModifyMenu(id, MF_BYCOMMAND, id, _T("E&xit Application")); } // Associate a context help ID with File menu, if one is not found. // ID_FILE_CONTEXT_HELPID is the context help ID for the File menu // that is defined in resource file. if (submenu->GetMenuContextHelpId() == 0) submenu->SetMenuContextHelpId(ID_FILE_CONTEXT_HELPID); // Set "Open" menu item as the default menu item for the File menu, // if one is not found. So, when a user double-clicks the File // menu, the system sends a command message to the menu's owner // window and closes the menu as if the File\Open command item had // been chosen. if (submenu->GetDefaultItem(GMDI_GOINTOPOPUPS, TRUE) == -1) { pos = FindMenuItem(submenu, _T("&Open...\tCtrl+O")); submenu->SetDefaultItem(pos, TRUE); } }
BOOL CMainFrame::OnShowPopupMenu (CBCGPPopupMenu* pMenuPopup) { CBCGPMDIFrameWnd::OnShowPopupMenu (pMenuPopup); if (pMenuPopup == NULL) { return TRUE; } CBCGPPopupMenuBar* pMenuBar = pMenuPopup->GetMenuBar (); ASSERT_VALID (pMenuBar); for (int i = 0; i < pMenuBar->GetCount (); i ++) { CBCGPToolbarButton* pButton = pMenuBar->GetButton (i); ASSERT_VALID (pButton); if (pButton->m_nID == ID_FAVORITES_DUMMY) { pMenuBar->ImportFromMenu (m_menuFavotites); pMenuPopup->SetMaxWidth (300); return TRUE; } if (pButton->m_nID == ID_VIEW_HISTORY) { CMenu menuHistory; menuHistory.LoadMenu (IDR_HISTORY_POPUP); CMenu* subMenu = menuHistory.GetSubMenu (0); ASSERT_VALID (subMenu); CBCGPIE7DemoView* pView = DYNAMIC_DOWNCAST(CBCGPIE7DemoView, GetActiveHTML ()); if (pView != NULL) { CBCGPIE7DemoDoc* pDoc = pView->GetDocument (); if (pDoc != NULL) { _T_HistotyList lst; int index = 0; POSITION pos = NULL; pDoc->GetBackList (lst); for (pos = lst.GetHeadPosition (); pos != NULL;) { CHistoryObj* pObj = lst.GetNext (pos); ASSERT (pObj != NULL); subMenu->InsertMenu (index, MF_STRING | MF_BYPOSITION, pObj->GetCommand (), pObj->GetTitle ()); index++; } pDoc->GetFrwdList (lst); for (pos = lst.GetHeadPosition (); pos != NULL;) { CHistoryObj* pObj = lst.GetNext (pos); ASSERT (pObj != NULL); subMenu->InsertMenu (index, MF_STRING | MF_BYPOSITION, pObj->GetCommand (), pObj->GetTitle ()); index++; } if (index > 0) { subMenu->InsertMenu (index, MF_SEPARATOR | MF_BYPOSITION, 0, (LPCTSTR)NULL); } } } pMenuBar->ImportFromMenu (subMenu->GetSafeHmenu ()); return TRUE; } } return TRUE; }
LRESULT CFloatingWindow::OnContextMenu(WORD wNotifyCode, WORD wID, HWND hWndCtl) { if (!IsWindowEnabled()) return 0; CMenu TrayMenu; TrayMenu.CreatePopupMenu(); if (!m_bIsUploading) { // Inserting menu items int i = 0; MyInsertMenu(TrayMenu, i++, IDM_UPLOADFILES, TR("Загрузить файлы") + CString(_T("..."))); MyInsertMenu(TrayMenu, i++, IDM_ADDFOLDERS, TR("Загрузить папку") + CString(_T("..."))); MyInsertMenu(TrayMenu, i++, 0, 0); bool IsClipboard = false; if (OpenClipboard()) { IsClipboard = IsClipboardFormatAvailable(CF_BITMAP) != 0; CloseClipboard(); } if (IsClipboard) { MyInsertMenu(TrayMenu, i++, IDM_PASTEFROMCLIPBOARD, TR("Вставить из буфера")); MyInsertMenu(TrayMenu, i++, 0, 0); } MyInsertMenu(TrayMenu, i++, IDM_IMPORTVIDEO, TR("Импорт видео")); MyInsertMenu(TrayMenu, i++, 0, 0); MyInsertMenu(TrayMenu, i++, IDM_SCREENSHOTDLG, TR("Скриншот") + CString(_T("..."))); MyInsertMenu(TrayMenu, i++, IDM_REGIONSCREENSHOT, TR("Снимок выделенной области")); MyInsertMenu(TrayMenu, i++, IDM_FULLSCREENSHOT, TR("Снимок всего экрана")); MyInsertMenu(TrayMenu, i++, IDM_WINDOWSCREENSHOT, TR("Снимок активного окна")); MyInsertMenu(TrayMenu, i++, IDM_WINDOWHANDLESCREENSHOT, TR("Снимок выбранного элемента")); MyInsertMenu(TrayMenu, i++, IDM_FREEFORMSCREENSHOT, TR("Снимок произвольной формы")); CMenu SubMenu; SubMenu.CreatePopupMenu(); SubMenu.InsertMenu( 0, MFT_STRING | MFT_RADIOCHECK | (Settings.TrayIconSettings.TrayScreenshotAction == TRAY_SCREENSHOT_OPENINEDITOR ? MFS_CHECKED : 0), IDM_SCREENTSHOTACTION_OPENINEDITOR, TR("Открыть в редакторе")); SubMenu.InsertMenu( 0, MFT_STRING | MFT_RADIOCHECK | (Settings.TrayIconSettings.TrayScreenshotAction == TRAY_SCREENSHOT_UPLOAD ? MFS_CHECKED : 0), IDM_SCREENTSHOTACTION_UPLOAD, TR("Загрузить на сервер")); SubMenu.InsertMenu( 1, MFT_STRING | MFT_RADIOCHECK | (Settings.TrayIconSettings.TrayScreenshotAction == TRAY_SCREENSHOT_CLIPBOARD ? MFS_CHECKED : 0), IDM_SCREENTSHOTACTION_TOCLIPBOARD, TR("Копировать в буфер обмена")); SubMenu.InsertMenu( 2, MFT_STRING | MFT_RADIOCHECK | (Settings.TrayIconSettings.TrayScreenshotAction == TRAY_SCREENSHOT_SHOWWIZARD ? MFS_CHECKED : 0), IDM_SCREENTSHOTACTION_SHOWWIZARD, TR("Открыть в окне мастера")); SubMenu.InsertMenu( 3, MFT_STRING | MFT_RADIOCHECK | (Settings.TrayIconSettings.TrayScreenshotAction == TRAY_SCREENSHOT_ADDTOWIZARD ? MFS_CHECKED : 0), IDM_SCREENTSHOTACTION_ADDTOWIZARD, TR("Добавить в мастер")); MENUITEMINFO mi; mi.cbSize = sizeof(mi); mi.fMask = MIIM_TYPE | MIIM_ID | MIIM_SUBMENU; mi.fType = MFT_STRING; mi.hSubMenu = SubMenu; mi.wID = 10000; mi.dwTypeData = TR("Действие со снимком"); TrayMenu.InsertMenuItem(i++, true, &mi); SubMenu.Detach(); MyInsertMenu(TrayMenu, i++, 0, 0); MyInsertMenu(TrayMenu, i++, IDM_SHORTENURL, TR("Сократить ссылку")); MyInsertMenu(TrayMenu, i++, 0, 0); MyInsertMenu(TrayMenu, i++, IDM_SHOWAPPWINDOW, TR("Показать окно программы")); MyInsertMenu(TrayMenu, i++, 0, 0); MyInsertMenu(TrayMenu, i++, IDM_SETTINGS, TR("Настройки") + CString(_T("..."))); MyInsertMenu(TrayMenu, i++, 0, 0); MyInsertMenu(TrayMenu, i++, IDM_EXIT, TR("Выход")); if (Settings.Hotkeys[Settings.TrayIconSettings.LeftDoubleClickCommand].commandId) { SetMenuDefaultItem(TrayMenu, Settings.Hotkeys[Settings.TrayIconSettings.LeftDoubleClickCommand].commandId, FALSE); } } else MyInsertMenu(TrayMenu, 0, IDM_STOPUPLOAD, TR("Прервать загрузку")); m_hTrayIconMenu = TrayMenu; CMenuHandle oPopup(m_hTrayIconMenu); PrepareMenu(oPopup); CPoint pos; GetCursorPos(&pos); SetForegroundWindow(m_hWnd); oPopup.TrackPopupMenu(TPM_LEFTALIGN, pos.x, pos.y, m_hWnd); // BUGFIX: See "PRB: Menus for Notification Icons Don't Work Correctly" PostMessage(WM_NULL); return 0; }
// 右クリック LRESULT CDownloadedListView::OnListRClick(LPNMHDR pnmh) { LPNMITEMACTIVATE lp = (LPNMITEMACTIVATE)pnmh; if (lp->iItem != -1) { int nCount = GetItemCount(); for (int i = 0; i < nCount; ++i) { SetItemState(i, 0, LVIS_SELECTED); } SetItemState(lp->iItem, LVIS_SELECTED, LVIS_SELECTED); DLItem* pItem = ((DLItem*)GetItemData(lp->iItem)); const CString& path = pItem->strFilePath; const CString& strReferer = pItem->strReferer; CPoint pt; ::GetCursorPos(&pt); CMenu menu; menu.CreatePopupMenu(); enum { ID_OPEN_ITEMSAVEFOLDER = 1, ID_OPEN_REFERER_ = 2, ID_LAST }; menu.InsertMenu( 0, MF_BYPOSITION | MF_ENABLED, ID_OPEN_ITEMSAVEFOLDER, _T("保存先フォルダを開く") ); menu.InsertMenu( 1, MF_BYPOSITION | MF_ENABLED, ID_OPEN_REFERER_ , _T("ダウンロードしたページを表示する") ); auto funcExeCommand = [=](int commandID) -> bool { if (commandID == ID_OPEN_ITEMSAVEFOLDER) { OpenFolderAndSelectItem(path); } else if(commandID == ID_OPEN_REFERER_) { if (strReferer.IsEmpty()) return true; DonutOpenFile(g_pMainWnd->m_hWnd, strReferer, D_OPENFILE_ACTIVATE); } else { return false; } return true; }; if (pItem->bAbort || ::PathFileExists(path) == FALSE) { int nCmd = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, m_hWnd); funcExeCommand(nCmd); return 0; } LPITEMIDLIST pidl = ILCreateFromPath(path); if (pidl) { CComPtr<IShellItem> spShellItem; ::SHCreateShellItem(NULL, NULL, pidl, &spShellItem); if (spShellItem) { CComPtr<IContextMenu> spContextMenu; spShellItem->BindToHandler(NULL, BHID_SFUIObject, IID_IContextMenu, (void**)&spContextMenu); if (spContextMenu) { menu.AppendMenu(MF_BYPOSITION | MF_SEPARATOR, UINT_PTR(0), _T("\0")); HRESULT hr = spContextMenu->QueryContextMenu(menu, menu.GetMenuItemCount(), ID_LAST, 0xFFFF, CMF_NORMAL); if (SUCCEEDED(hr)) { int nCmd = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, m_hWnd); if (nCmd) { if (funcExeCommand(nCmd) == false) { CMINVOKECOMMANDINFO InvokeInfo= { sizeof (CMINVOKECOMMANDINFO) }; InvokeInfo.hwnd = m_hWnd; InvokeInfo.lpVerb = (LPCSTR) MAKEINTRESOURCE(nCmd - ID_LAST); InvokeInfo.nShow = SW_SHOWNORMAL; hr = spContextMenu->InvokeCommand(&InvokeInfo); } } } } } } } return 0; }
void DisplayView::OnRButtonDown(UINT nFlags, CPoint point) { point += GetScrollPosition(); CMenu menu; // find out if there is any filter being selected current_filter = graph.FindFilterByPos(point); if (!current_filter) return ; if (!menu.CreatePopupMenu()) return ; FILTER_STATE state = State_Running; if (graph.GetState(state, 0) != 0) { state = State_Running; } // check for a pin - will have different menu current_pin = current_filter->FindPinByPos(point, false); if (current_pin) { // make rendering inactive for connected pins UINT flags = 0; if (current_pin->connected) flags |= MF_GRAYED; if (current_pin->dir != PINDIR_OUTPUT) flags |= MF_GRAYED; if (state != State_Stopped) flags |= MF_GRAYED; /* If the pin is not connected we might try to check it for MEDIATYPE_Stream so we can offer to connect the File Writer filter. */ bool offer_writer = false; if (current_pin->connected == false) { DSUtil::MediaTypes mtypes; HRESULT hr; // we will ignore the async file source filter if (current_filter->clsid != CLSID_AsyncReader) { hr = DSUtil::EnumMediaTypes(current_pin->pin, mtypes); if (SUCCEEDED(hr)) { for (int i=0; i<mtypes.GetCount(); i++) { if (mtypes[i].majortype == MEDIATYPE_Stream) { offer_writer = true; break; } } } } } int p = 0; menu.InsertMenu(p++, MF_BYPOSITION | MF_STRING | flags, ID_PIN_RENDER, _T("Render Pin")); menu.InsertMenu(p++, MF_BYPOSITION | MF_SEPARATOR); menu.InsertMenu(p++, MF_BYPOSITION | MF_STRING | flags, ID_PIN_NULL_STREAM, _T("Insert Null Renderer")); menu.InsertMenu(p++, MF_BYPOSITION | MF_STRING | flags, ID_PIN_DUMP_STREAM, _T("Insert Dump Filter")); if (offer_writer) { menu.InsertMenu(p++, MF_BYPOSITION | MF_STRING | flags, ID_PIN_FILE_WRITER, _T("Insert File Writer")); } // check for compatible filters PrepareCompatibleFiltersMenu(menu, current_pin); p = menu.GetMenuItemCount(); menu.InsertMenu(p++, MF_BYPOSITION | MF_SEPARATOR); menu.InsertMenu(p++, MF_BYPOSITION | MF_STRING, ID_PROPERTYPAGE, _T("Properties")); // check for IAMStreamSelect interface PrepareStreamSelectMenu(menu, current_pin->pin); } else { menu.InsertMenu(0, MF_STRING, ID_PROPERTYPAGE, _T("Properties")); int p = menu.GetMenuItemCount(); menu.InsertMenu(p++, MF_BYPOSITION | MF_SEPARATOR); menu.InsertMenu(p++, MF_BYPOSITION | MF_STRING, ID_DELETE_FILTER, _T("Delete Selection")); // check for IAMStreamSelect interface PrepareStreamSelectMenu(menu, current_filter->filter); } CPoint pt; GetCursorPos(&pt); // display menu menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, this); }
void DisplayView::PrepareStreamSelectMenu(CMenu &menu, IUnknown *obj) { // support for IAMStreamSelect CComPtr<IAMStreamSelect> stream_select; HRESULT hr = obj->QueryInterface(IID_IAMStreamSelect, (void**)&stream_select); if (FAILED(hr) || !stream_select) return ; // now scan through the streams DWORD last_group = (DWORD)-1; DWORD stream_count = 0; hr = stream_select->Count(&stream_count); if (FAILED(hr)) { stream_select = NULL; return ; } // nothing to add - we're done here if (stream_count <= 0) { stream_select = NULL; return ; } CMenu submenu; submenu.CreatePopupMenu(); CMenu &active_menu = submenu; menu.InsertMenu(menu.GetMenuItemCount(), MF_BYPOSITION | MF_SEPARATOR); for (int i=0; i<stream_count; i++) { AM_MEDIA_TYPE *mt = NULL; DWORD flags; LCID language; DWORD group; LPWSTR name; hr = stream_select->Info(i, &mt, &flags, &language, &group, &name, NULL, NULL); if (SUCCEEDED(hr)) { // add separators between stream groups if (i == 0) { last_group = group; } else { if (group != last_group) { active_menu.InsertMenu(active_menu.GetMenuItemCount(), MF_BYPOSITION | MF_SEPARATOR); last_group = group; } } int idx = active_menu.GetMenuItemCount(); UINT mflags = MF_BYPOSITION | MF_STRING; if (flags > 0) mflags |= MF_CHECKED; active_menu.InsertMenu(idx, mflags | MF_STRING, ID_STREAM_SELECT+i, name); } // get rid of the buffers if (mt) { DeleteMediaType(mt); } } // do insert the menu int count = menu.GetMenuItemCount(); menu.InsertMenu(count, MF_BYPOSITION | MF_STRING, 0, _T("Stream selection")); menu.ModifyMenu(count, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)submenu.m_hMenu, _T("Stream selection")); submenu.Detach(); stream_select = NULL; }
void CRichEditExtn::OnContextMenu(CWnd* pWnd, CPoint point) { if (m_vmenu_items.empty()) { CRichEditExtn::OnContextMenu(pWnd, point); return; } SetFocus(); CMenu menu; menu.CreatePopupMenu(); BOOL bReadOnly = GetStyle() & ES_READONLY; DWORD flags = CanUndo() && !bReadOnly ? 0 : MF_GRAYED; int iPos(0); menu.InsertMenu(iPos++, MF_BYPOSITION | flags, EM_UNDO, CString(MAKEINTRESOURCE(IDS_MENUSTRING_UNDO))); menu.InsertMenu(iPos++, MF_BYPOSITION | MF_SEPARATOR); long lStart, lEnd; GetSel(lStart, lEnd); flags = lStart == lEnd ? MF_GRAYED : 0; menu.InsertMenu(iPos++, MF_BYPOSITION | flags, WM_COPY, CString(MAKEINTRESOURCE(IDS_MENUSTRING_COPY))); flags = (flags == MF_GRAYED || bReadOnly) ? MF_GRAYED : 0; menu.InsertMenu(iPos++, MF_BYPOSITION | flags, WM_CUT, CString(MAKEINTRESOURCE(IDS_MENUSTRING_CUT))); flags = (flags == MF_GRAYED || bReadOnly) ? MF_GRAYED : 0; menu.InsertMenu(iPos++, MF_BYPOSITION | flags, WM_CLEAR, CString(MAKEINTRESOURCE(IDS_MENUSTRING_DELETE))); flags = IsClipboardFormatAvailable(EDIT_CLIPBOARD_TEXT_FORMAT) && !bReadOnly ? 0 : MF_GRAYED; menu.InsertMenu(iPos++, MF_BYPOSITION | flags, WM_PASTE, CString(MAKEINTRESOURCE(IDS_MENUSTRING_PASTE))); menu.InsertMenu(iPos++, MF_BYPOSITION | MF_SEPARATOR); int len = GetWindowTextLength(); flags = (!len || (lStart == 0 && lEnd == len)) ? MF_GRAYED : 0; menu.InsertMenu(iPos++, MF_BYPOSITION | flags, EM_SELECTALL, CString(MAKEINTRESOURCE(IDS_MENUSTRING_SELECTALL))); menu.InsertMenu(iPos++, MF_BYPOSITION | MF_SEPARATOR); for (size_t i = 0; i < m_vmenu_items.size(); i++) { menu.InsertMenu((int)i + iPos, MF_BYPOSITION | m_vmenu_items[i].flags, m_vmenu_items[i].message_number, m_vmenu_items[i].menu_string.c_str()); if (!m_vmenu_items[i].bEnable) menu.EnableMenuItem((int)i + iPos, MF_BYPOSITION | MF_GRAYED); } if (point.x == -1 || point.y == -1) { CRect rc; GetClientRect(&rc); point = rc.CenterPoint(); ClientToScreen(&point); } // For some reason - weird cursor m_bContextMenu = true; // Now show menu UINT_PTR nCmd = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RETURNCMD | TPM_RIGHTBUTTON, point.x, point.y, this); // Restore cursor m_bContextMenu = false; if (nCmd == 0) return; std::vector<st_context_menu>::iterator iter; iter = std::find_if(m_vmenu_items.begin(), m_vmenu_items.end(), equal_cmd(nCmd)); if (iter != m_vmenu_items.end()) { this->GetParent()->SendMessage((UINT)nCmd, iter->wParam, iter->lParam); return; } switch (nCmd) { case EM_UNDO: case WM_CUT: case WM_COPY: case WM_CLEAR: SendMessage((UINT)nCmd); break; case WM_PASTE: SendMessage(EM_PASTESPECIAL, CF_UNICODETEXT, NULL); break; case EM_SELECTALL: SendMessage(EM_SETSEL, 0, -1); break; default: break; } }
bool CMainFrame::SetLanguageMenu() { CMenu* pParentMenu = GetMenu(); CMenu* pMenu = GetMenu()->GetSubMenu( m_nLangOptionMenuPos ); CUStringConvert strCnv; ASSERT( pMenu ); if ( NULL == m_pPopupMenu ) { m_pPopupMenu = new CMenu; m_pPopupMenu->CreatePopupMenu(); CUString strAdd( g_language.GetString( IDS_CHECKFORADDITIONAL_LANGUAGE_FILES ) ); CUStringConvert strCnv; // Add Check for Updates m_pPopupMenu->AppendMenu( MF_STRING | MF_ENABLED, ID_LANGUAGE_START, strCnv.ToT( strAdd ) ); // Add language menu items for ( DWORD idx = 0; idx < g_language.GetNumLanguageStrings() ; idx++ ) { CUString strAdd( g_language.GetLanguageString( idx ) ); m_pPopupMenu->AppendMenu( MF_STRING | MF_ENABLED, ID_LANGUAGE_START + idx + 1, strCnv.ToT( strAdd ) ); } } CString strCurrent; pMenu->GetMenuString( m_nLangLangMenuPos, strCurrent, MF_BYPOSITION ); // Add language menu items for ( DWORD idx = 0; idx < m_pPopupMenu->GetMenuItemCount(); idx++ ) { CString strMenu; if ( 0 == idx ) { m_pPopupMenu->ModifyMenu( idx, MF_BYPOSITION | MF_STRING, ID_LANGUAGE_START, strCnv.ToT( g_language.GetString( IDS_CHECKFORADDITIONAL_LANGUAGE_FILES ) )); } // get menu string m_pPopupMenu->GetMenuString( idx, strMenu, MF_BYPOSITION ); // check if this is the selected language if ( 0 == g_language.GetLanguage().CompareNoCase( CUString( strMenu ) ) ) { m_pPopupMenu->CheckMenuItem( idx, MF_BYPOSITION | MF_CHECKED ); } else { m_pPopupMenu->CheckMenuItem( idx, MF_BYPOSITION | MF_UNCHECKED ); } } // remove exisiting menu item pMenu->RemoveMenu( m_nLangLangMenuPos, MF_BYPOSITION ); // insert new popup menu pMenu->InsertMenu( m_nLangLangMenuPos, MF_BYPOSITION | MF_POPUP, (UINT)m_pPopupMenu->m_hMenu, strCurrent ); // peform translation g_language.TranslateMenu( GetMenu(), m_nMenuID ); // refresh frame windows ActivateFrame( SW_HIDE ); ActivateFrame( SW_SHOW ); return true; }
void CHexEdit::OnContextMenu(CWnd* pWnd, CPoint point) { int start,end; GetSel(start,end); CString text; this->GetWindowText(text); char head=0,second=0; bool bCut=true; SetFocus(); CMenu menu; menu.CreatePopupMenu(); //No problems with default undo BOOL bReadOnly = GetStyle() & ES_READONLY; DWORD flags = CanUndo() && !bReadOnly ? 0 : MF_GRAYED; menu.InsertMenu(0, MF_BYPOSITION | flags, EM_UNDO, MES_UNDO); menu.InsertMenu(1, MF_BYPOSITION | MF_SEPARATOR); //No problem with default Copy DWORD sel = GetSel(); flags = LOWORD(sel) == HIWORD(sel) ? MF_GRAYED : 0; menu.InsertMenu(2, MF_BYPOSITION | flags, WM_COPY, MES_COPY); //Cut and delete should be modified if(text.GetLength()>0) head=text.GetAt(0); if(text.GetLength()>1) second=text.GetAt(1); if(second=='X'||second=='x'){ //does not allow cut first char if(start==0&&end==1) bCut=false; } flags = (flags == MF_GRAYED || bReadOnly||!bCut) ? MF_GRAYED : 0; menu.InsertMenu(2, MF_BYPOSITION | flags, WM_CUT, MES_CUT); menu.InsertMenu(4, MF_BYPOSITION | flags, WM_CLEAR, MES_DELETE); //Paste should be modified flags = IsClipboardFormatAvailable(CF_TEXT) && !bReadOnly ? 0 : MF_GRAYED; if(!this->OpenClipboard()) ::AfxMessageBox("Cannot open clipboard!"); HGLOBAL hglb; LPTSTR lptstr; hglb=GetClipboardData(CF_TEXT); if (hglb != NULL) { lptstr =(LPTSTR) GlobalLock(hglb); //Check invalid hex string if(!this->IsHexConvertableText(lptstr)) { flags=MF_GRAYED; } } CloseClipboard(); menu.InsertMenu(4, MF_BYPOSITION | flags, WM_PASTE, MES_PASTE); menu.InsertMenu(6, MF_BYPOSITION | MF_SEPARATOR); //No problem with default Sel All int len = GetWindowTextLength(); flags = (!len || (LOWORD(sel) == 0 && HIWORD(sel) == len)) ? MF_GRAYED : 0; menu.InsertMenu(7, MF_BYPOSITION | flags, ME_SELECTALL, MES_SELECTALL); flags=0; if(text.GetLength()==0||(text.GetLength()==2&&text.Find("0x")==0)) flags=MF_GRAYED; menu.InsertMenu(8, MF_BYPOSITION | MF_SEPARATOR); menu.InsertMenu(9, MF_BYPOSITION | flags, ME_CONVERT, MES_CONVERT); menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON, point.x, point.y, this); }
BOOL CXTPResizePropertySheet::OnInitDialog() { CRect rcClientBegin, rcClientEnd; GetWindowRect(rcClientBegin); SendMessage(WM_NCCALCSIZE, FALSE, (LPARAM)(LPRECT)rcClientBegin); // Modify the window style to include WS_THICKFRAME for resizing. ::SetWindowLong(m_hWnd, GWL_STYLE, GetStyle() | WS_THICKFRAME); GetWindowRect(rcClientEnd); SendMessage(WM_NCCALCSIZE, FALSE, (LPARAM)(LPRECT)rcClientEnd); CPropertySheet::OnInitDialog(); // subclass our "flicker-free" tab control. m_tabCtrl.SubclassWindow(GetTabControl()->m_hWnd); // the size icon is too close to the buttons, so inflate the sheet CRect rc; GetWindowRect(rc); if (rcClientBegin.Width() - rcClientEnd.Width() > 3) { rc.InflateRect((rcClientBegin.Width() - rcClientEnd.Width()) / 2, (rcClientBegin.Height() - rcClientEnd.Height()) / 2); MoveWindow(rc); } // Do this last so that any prop pages are moved accordingly else if (!HasFlag(xtpResizeNoSizeIcon) && !IsWizard()) { rc.InflateRect(1, 1, 2, 2); MoveWindow(rc); } // add sizing entries to the system menu CMenu* pSysMenu = (CMenu*)GetSystemMenu(FALSE); if (pSysMenu) { CString szMaximize, szMinimize, szSize, szRestore; // try to get the strings from the topmost window CWnd* pwndTop; for (pwndTop = this; pwndTop->GetParent(); pwndTop = pwndTop->GetParent()); CMenu* pTopSysMenu = (CMenu*)pwndTop->GetSystemMenu(FALSE); if (pTopSysMenu) { pTopSysMenu->GetMenuString(SC_MAXIMIZE, szMaximize, MF_BYCOMMAND); pTopSysMenu->GetMenuString(SC_MINIMIZE, szMinimize, MF_BYCOMMAND); pTopSysMenu->GetMenuString(SC_SIZE, szSize, MF_BYCOMMAND); pTopSysMenu->GetMenuString(SC_RESTORE, szRestore, MF_BYCOMMAND); } // if we din't get the strings then set them to the English defaults if (szMaximize.IsEmpty()) szMaximize = _T("Ma&ximize"); if (szMinimize.IsEmpty()) szMinimize = _T("Mi&nimize"); if (szSize.IsEmpty()) szSize = _T("&Size"); if (szRestore.IsEmpty()) szRestore = _T("&Restore"); pSysMenu->InsertMenu(1, MF_BYPOSITION | MF_SEPARATOR, 0, (LPCTSTR) 0); pSysMenu->InsertMenu(1, MF_BYPOSITION | MF_STRING, SC_MAXIMIZE, szMaximize); pSysMenu->InsertMenu(1, MF_BYPOSITION | MF_STRING, SC_MINIMIZE, szMinimize); pSysMenu->InsertMenu(1, MF_BYPOSITION | MF_STRING, SC_SIZE, szSize); pSysMenu->InsertMenu(0, MF_BYPOSITION | MF_STRING, SC_RESTORE, szRestore); } DWORD dwStyle = ::GetWindowLong(m_hWnd, GWL_STYLE); if ((dwStyle & WS_THICKFRAME) == 0) { SetFlag(xtpResizeNoSizeIcon); } CXTPResize::Init(); // Check which buttons are available in sheet or wizard if (IsWizard()) { SetResize(ID_WIZBACK, XTP_ATTR_REPOS(1)); SetResize(ID_WIZNEXT, XTP_ATTR_REPOS(1)); SetResize(ID_WIZFINISH, XTP_ATTR_REPOS(1)); SetResize(ID_WIZLINE, XTP_ANCHOR_BOTTOMLEFT, XTP_ANCHOR_BOTTOMRIGHT); } else { SetResize(IDOK, XTP_ATTR_REPOS(1)); SetResize(ID_APPLY_NOW, XTP_ATTR_REPOS(1)); SetResize(AFX_IDC_TAB_CONTROL, XTP_ATTR_RESIZE(1)); } SetResize(IDCANCEL, XTP_ATTR_REPOS(1)); SetResize(IDHELP, XTP_ATTR_REPOS(1)); // set page sizings CRect rcPage; GetActivePage()->GetWindowRect(rcPage); ScreenToClient(rcPage); int i; for (i = 0; i <GetPageCount(); i++) { SetResize(GetPage(i), XTP_ATTR_RESIZE(1), rcPage); } return TRUE; }
// we use this as a hook to customize the language menu void CLangModelsDoc::OnUpdateLangProperties(CCmdUI* pCmdUI) { CWnd* pWnd = AfxGetMainWnd(); //CMenu* pTopMenu = pWnd->GetMenu(); // this is wierd but it seemed that we have to search for the menu // I know, it should be 3, but sometimes our commands ended up in the view menu /* CMenu* pMenu = NULL; for(int i=2; i < 5; i++) { CString s; pTopMenu->GetMenuString(i, s, MF_BYPOSITION ); if(s == "&Language") { pMenu = pTopMenu->GetSubMenu(i); break; } } */ CMenu* pMenu = pCmdUI->m_pMenu; if(!pMenu) // null when you make a choice in the menu? return; const int kSynthSeqIndex = 3; //const int kItemsAfterTransfer = 2; const CTypedPtrArray<CPtrArray, CLangModelsDoc*>& pLangDocs = getProject()->getLangDocs(); // remove existing transfer menu items for( int z=pMenu->GetMenuItemCount(); z >= 0; z--) { int iCMD = pMenu->GetMenuItemID(z); // is this a transfer sequence item? if(iCMD >= kTransferCMDBase && iCMD <= (kTransferCMDBase+ pLangDocs.GetSize()-1)) pMenu->DeleteMenu(z, MF_BYPOSITION ); } // now we should have the menu as in the resource editor // stick in an item for each transfer process sequence // note that this is written with the assumption that there // is one transfer sequence for each other language in the // project int iItem = kSynthSeqIndex; // which menu item int iCount = 0; // index into the transfer sequences for(int iTrg=0; iTrg<pLangDocs.GetSize(); iTrg++) { if(pLangDocs[iTrg] != this) { #ifndef hab17a1 CString s("Transfer "); if ((m_pLang->m_wDisplayFlags & m_pLang->kLocateTransferWithTarget) > 0) s += "From "; else s += "To "; #else // hab17a1 CString s("Transfer To "); #endif // hab17a1 s += pLangDocs[iTrg]->getLang()->getName(); s += " Sequence..."; pMenu->InsertMenu(iItem, MF_ENABLED | MF_BYPOSITION | MF_STRING , kTransferCMDBase + iCount, // cmd id s); iItem++; iCount++; } } pWnd->DrawMenuBar(); }