Example #1
0
void CMenuSpawn::RemapMenu(HMENU hMenu)
{
	static int iRecurse = 0;
	iRecurse ++;

	CMenu pMenu;
	pMenu.Attach(hMenu);
	
	ASSERT(pMenu);
	int nItem = pMenu.GetMenuItemCount();
	while ((--nItem)>=0)
	{
		UINT itemId = pMenu.GetMenuItemID(nItem);
		if (itemId == (UINT) -1)
		{
			CMenu pops(pMenu.GetSubMenu(nItem));
			if (pops.GetHandleMenu()) RemapMenu(pops.GetHandleMenu());
			if (bIsPopup || iRecurse > 0)
			{
				TCHAR cs[128];
				memset(cs,0x00,128);
				pMenu.GetMenuString(nItem, cs, 128,MF_BYPOSITION);
				if (lstrlen(cs)>0)
				{
					SpawnItem * sp = AddSpawnItem(cs, (!bIsPopup && iRecurse == 1) ? -4 : -2);
					pMenu.ModifyMenu(nItem,MF_BYPOSITION|MF_OWNERDRAW, (UINT) -1, (LPCTSTR)sp);
				}
			}
		}
		else
		{
			if (itemId != 0)
			{
				UINT oldState = pMenu.GetMenuState(nItem,MF_BYPOSITION);
				if (!(oldState&MF_OWNERDRAW) && !(oldState&MF_BITMAP))
				{
					ASSERT(oldState != (UINT)-1);
					TCHAR cs[128];
					memset(cs,0x00,128);
					pMenu.GetMenuString(nItem, cs, 128, MF_BYPOSITION);
					SpawnItem * sp = AddSpawnItem(cs, itemId);
					if (itemId!=SC_CLOSE)
					pMenu.ModifyMenu(nItem,MF_BYPOSITION|MF_OWNERDRAW|oldState, (LPARAM)itemId, (LPCTSTR)sp);
				}
			}
			else
			{
				UINT oldState = pMenu.GetMenuState(nItem,MF_BYPOSITION);
				if (!(oldState&MF_OWNERDRAW) && !(oldState&MF_BITMAP))
				{
					ASSERT(oldState != (UINT)-1);
					SpawnItem * sp = AddSpawnItem("--", -3);
					pMenu.ModifyMenu(nItem,MF_BYPOSITION|MF_OWNERDRAW|oldState, (LPARAM)itemId, (LPCTSTR)sp);
				}
			}
		}
	}
	iRecurse --;
	pMenu.Detach();
}
void CDlgQueueController::OnTrayIcon(WPARAM wParam, LPARAM lParam)
{
	switch (lParam)
	{
	case WM_RBUTTONDOWN:
		{
			CMenu menu;
			if (menu.LoadMenu(IDR_MENU_TRAY_ICON))
			{
				CMenu* pSubMenu = menu.GetSubMenu(0);
				if (this->IsWindowVisible())
				{
					CString strMenu;
					this->GetDlgItem(IDC_BUTTON_HIDE)->GetWindowText(strMenu);
					menu.ModifyMenu(IDM_SHOW_HIDE, MF_BYCOMMAND, IDM_SHOW_HIDE, strMenu);
				}
				
				CPoint pt;
				::GetCursorPos(&pt);
				
				pSubMenu->TrackPopupMenu(0, pt.x, pt.y, this);
			}
		}
		break;

	case WM_LBUTTONDBLCLK:
	case WM_LBUTTONDOWN:
		this->ShowWindow(SW_SHOW);
		break;
	}
}
Example #3
0
BOOL CColorsApp::InitInstance()
{
	// Standard initialization

	// Change the registry key under which our settings are stored.
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

	CMainFrame* pFrame = new CMainFrame;
	m_pMainWnd = pFrame;

	// create and load the frame with its resources

	pFrame->LoadFrame(IDR_MAINFRAME,
		WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
		NULL);

	pFrame->ShowWindow(SW_SHOW);
	pFrame->UpdateWindow();

	//
	// Convert the items in the Color menu to owner-draw.
	//
	CMenu* pMenu = pFrame->GetMenu ();
	ASSERT (pMenu != NULL);

	for (int i=0; i<5; i++)
		pMenu->ModifyMenu (ID_COLOR_RED + i, MF_OWNERDRAW, 
                    ID_COLOR_RED + i);

	return TRUE;
}
//右键弹出处理
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);
		}
	}
}
void CSpiderTaskTree::ShowContextMenu()
{
	HTREEITEM hItem = GetSelectedItem ();
	if (hItem == NULL)
		return;

	int iItem = FindTree (hItem);
	if (iItem == -1)
		return;

	CMenu menu;
	menu.LoadMenu (IDM_SPIDER_TREE);
	CMenu *pPopup = menu.GetSubMenu (0);

	CString str = LS (L_DONTDOWNLOADANDDEL); str += "\tDel";
	menu.ModifyMenu (ID_DONTDOWNLOADANDDEL, MF_BYCOMMAND|MF_STRING, ID_DONTDOWNLOADANDDEL, str);

	fsDLWebPage *wp = m_vConfs [iItem].wptree->GetData ();
	if (wp->dld == NULL || wp->dld->pMgr->IsDone ())
		pPopup->EnableMenuItem (ID_DONTDOWNLOADANDDEL, MF_BYCOMMAND | MF_GRAYED);

	ClientToScreen (&m_rbPt);
	pPopup->TrackPopupMenu (TPM_RIGHTBUTTON | TPM_TOPALIGN | TPM_LEFTALIGN,	m_rbPt.x, m_rbPt.y, this);
	menu.DestroyMenu ();
}
Example #6
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);
}
Example #7
0
bool IEToolbar::onQuickLinksDropdown(const NMTOOLBAR& messageInfo, 
                                     LRESULT& lResult) {
  UNREFERENCED_PARAMETER(messageInfo);
  lResult = TBDDRET_DEFAULT;
  // if not logged on then dont allow to see menu
  if (!UserDataObserver::getInstance().isLoggedIn(false)) {
    UserDataObserver::getInstance().login();
  } else {
    // Prepare menu.
    CMenu menu;
    loadQuickLinksMenu(menu);
    CMenu* settingsSubMenu = menu.GetSubMenu(0);
    if (!settingsSubMenu) {
      throw Error("Failed to get quick links sub-menu\n");
    }

    //get all the menu items messages
    for (unsigned int index = 0; index < settingsSubMenu->GetMenuItemCount(); ++index) {
      ToolbarWindow::updateItem(settingsSubMenu, index);
    }
    // get the language popup submenu caption
    String message = ResourceMessages::getMessage(kToolbarMenuLanguage);
    settingsSubMenu->ModifyMenu(14, MF_BYPOSITION | MF_STRING, 0, message.c_str());

    // Set pop-up menu flags.
    const UINT trackFlags = TPM_LEFTALIGN | TPM_RIGHTBUTTON;

    // Calculate quick links button rect to show menu in appropriate position.
    CRect quickLinksButtonRect = toolbarWindow_.getItemRect(
        quickLinksButtonIndex_);
    toolbarWindow_.MapWindowPoints(0, quickLinksButtonRect);

   
    // get the language submenu
    buildLanguagesSubMenu(*settingsSubMenu);
    
    // Track pop-up menu.
    // Determine if MS Windows is right aligned and set x position
    // of the menu
    int x = isBiDi(LOCALE_SYSTEM_DEFAULT) ? quickLinksButtonRect.right :
      quickLinksButtonRect.left;
    const BOOL trackResult = settingsSubMenu->TrackPopupMenu(trackFlags,
      x, quickLinksButtonRect.bottom, &siteWindow_);
    if (FALSE == trackResult) {
      throw Error("Failed to track quick links menu\n");
    }

  }
  return true;
}
// 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);
   }
}
Example #9
0
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 CBCGPTearOffManager::SetupTearOffMenus (HMENU hMenu)
{
	ASSERT (hMenu != NULL);

	CMenu* pMenu = CMenu::FromHandle (hMenu);
	if (pMenu == NULL)
	{
		return;
	}

	int iCount = (int) pMenu->GetMenuItemCount ();
	for (int i = 0; i < iCount; i ++)
	{
		UINT uiID = pMenu->GetMenuItemID (i);
		if (uiID != (UINT) -1)
		{
			continue;
		}

		UINT uiState = pMenu->GetMenuState (i, MF_BYPOSITION);
		if (uiState & MF_MENUBARBREAK)
		{
			CString str;
			pMenu->GetMenuString (i, str, MF_BYPOSITION);

			if (str [0] != cIDChar)
			{
				UINT uiCtrlBarId = GetFreeTearOffID ();
				if (uiCtrlBarId == 0)	// No more free IDs!
				{						// Reserve more IDs in Initialize!!!
					ASSERT (FALSE);
					return;
				}

				Build (uiCtrlBarId, str);
				pMenu->ModifyMenu (i, MF_BYPOSITION, i, str);
			}
		}

		CMenu* pPopupMenu = pMenu->GetSubMenu (i);
		if (pPopupMenu != NULL)
		{
			SetupTearOffMenus (pPopupMenu->GetSafeHmenu ());
		}
	}
}
Example #11
0
void Languages::Translate(CMenu& menu)
{
    int count = menu.GetMenuItemCount();
    for(int i=0;i<count;i++)
    {
        CMenu* subMenu = menu.GetSubMenu(i);
        if(subMenu)
            Translate(*subMenu);
    }

    //set translated text for every know control ID
    for(int i=0;i<count;i++)
    {
        UINT id = menu.GetMenuItemID(i);
        CString szText;
        if(GetItemText(id, szText))
            VERIFY(menu.ModifyMenu(i, MF_BYPOSITION | MF_STRING, id, szText));
    }
}
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 CLibraryView::OnRButtonDown(UINT nFlags, CPoint point) 
{
	// First select the clicked on symbol...
	OnLButtonDown( nFlags, point );

	ClientToScreen( &point );

	// Now bring up the context menu
	CMenu menu;
	menu.LoadMenu( IDR_LIBVIEW );

	CMenu lib_menu;
	lib_menu.CreatePopupMenu();

	CLibraryCollection::FillLibraryNames( IDM_LIBCOPY, &lib_menu );
	menu.ModifyMenu( ID_CONTEXT_COPY_TO, MF_POPUP, (unsigned int)lib_menu.m_hMenu, _T("Copy to") );
	lib_menu.Detach();
	menu.GetSubMenu(0)->TrackPopupMenu( TPM_LEFTALIGN|TPM_RIGHTBUTTON,
		point.x,point.y, AfxGetMainWnd(), NULL );
	
	CScrollView::OnRButtonDown(nFlags, point);
}
Example #14
0
void CCementBD::RenameMenuItem(UINT ID_menu_item, CString new_name)
{
    //---------------------------------------------------
    //Формируем меню внешних модулей
    CCementDoc* pDoc = (CCementDoc*)GetDocument();
    pDoc->m_DefaultMenu = 
        ::LoadMenu(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_KRSCEMENTTYPE));
    if (pDoc->m_DefaultMenu == NULL)
        return;

    CMenu* menu = CMenu::FromHandle(pDoc->GetDefaultMenu());
    if(menu)
    {
        int iPos, iMaxPos, jPos, jMaxPos;
        CMenu *submenu = NULL;
		iMaxPos = (int)menu->GetMenuItemCount();
        for(iPos = 0; iPos < iMaxPos; iPos++)
        {
			submenu = menu->GetSubMenu(iPos);
			jMaxPos = (int)submenu->GetMenuItemCount();
			for(jPos = 0; jPos < jMaxPos; jPos++)
			{
				if(submenu->GetMenuItemID(jPos) == ID_menu_item) 
					break;
			}
			if (jPos < jMaxPos)
				break;
        }
        if(submenu == NULL || jPos >= jMaxPos || new_name.GetLength() == 0)
			return;
        BOOL flg = submenu->ModifyMenu(jPos, MF_BYPOSITION, ID_menu_item, new_name);
		//BOOL flg = submenu->ModifyMenu(ID_menu_item, MF_BYCOMMAND, ID_menu_item, new_name);
        CMDIFrameWnd* frame = ((CMDIChildWnd *) GetParent())->GetMDIFrame();
        frame->MDISetMenu(menu, NULL);
        frame->DrawMenuBar();
	}
}
Example #15
0
	//-----------------------------------------------------------------------------
	void set_itemtext(int id, char* itemtxt)	// set menu item text
	{
		popmenu.ModifyMenu(id+100,MF_BYCOMMAND|MF_STRING, id+100, itemtxt );
	};
Example #16
0
void CDownloads_Groups::ShowGrpContextMenu(HTREEITEM hItem, BOOL bAutoDetect)
{
	if (bAutoDetect)	
	{
		hItem = GetSelectedItem ();
		if (hItem)
		{
			RECT rc;
			GetItemRect (hItem, &rc, TRUE);
			m_rbX = rc.left;
			m_rbY = rc.top;
		}
	}

	m_hContextMenuItem = hItem;

	if (hItem)
	{
		if (hItem == m_hDeleted)
		{
			ShowDeletedContextMenu ();
			return;
		}

		if (hItem == m_hHistory || GetParentItem (hItem) == m_hHistory)
		{
			ShowHistoryContextMenu ();
			return;
		}
	}

	CMenu menu;
	menu.LoadMenu (IDM_GROUP);
	CMenu *pPopup = menu.GetSubMenu (0);

	ApplyLanguageToMenu (pPopup);

	pPopup->SetDefaultItem (ID_GRPPROPERTIES);

	if (hItem)	
	{
		
		
		if (hItem == m_hAllGroups || IsGroupItem (hItem))
		{
			if (hItem == m_hAllGroups)
			{
				pPopup->EnableMenuItem (ID_GRPDELETE, MF_BYCOMMAND | MF_GRAYED);
				pPopup->EnableMenuItem (ID_OPENGROUPFOLDER, MF_BYCOMMAND | MF_GRAYED);
				pPopup->ModifyMenu (ID_GRPPROPERTIES, MF_BYCOMMAND, ID_GRPSETROOTFOLDER, LS (L_SETGRPROOTFOLDER));
			}

			if (hItem == m_hOther)
			{
				pPopup->EnableMenuItem (ID_GRPDELETE, MF_BYCOMMAND | MF_GRAYED);
			}
		}
		else
		{
			pPopup->EnableMenuItem (ID_GRPPROPERTIES, MF_BYCOMMAND | MF_GRAYED);
			pPopup->EnableMenuItem (ID_GRPDELETE, MF_BYCOMMAND | MF_GRAYED);
			pPopup->EnableMenuItem (ID_OPENGROUPFOLDER, MF_BYCOMMAND | MF_GRAYED);
		
			if (hItem != m_hFilters && hItem != m_hCompleted && hItem != m_hAllGroups)
			{
				pPopup->EnableMenuItem (ID_GRPDELETEALLSUCCESSFUL, MF_BYCOMMAND | MF_GRAYED);
				pPopup->EnableMenuItem (ID_GRPDELETEALLDEADDLDS, MF_BYCOMMAND | MF_GRAYED);
			}
			else if (hItem == m_hCompleted)
			{
				pPopup->EnableMenuItem (ID_GRPSTARTALL, MF_BYCOMMAND | MF_GRAYED);
				pPopup->EnableMenuItem (ID_GRPSTOPALL, MF_BYCOMMAND | MF_GRAYED);
				pPopup->EnableMenuItem (ID_GRPDELETEALL, MF_BYCOMMAND | MF_GRAYED);
			}	
		}
	}
	else  
	{
		

		pPopup->EnableMenuItem (ID_GRPPROPERTIES, MF_BYCOMMAND | MF_GRAYED);
		pPopup->EnableMenuItem (ID_GRPDELETE, MF_BYCOMMAND | MF_GRAYED);
		pPopup->EnableMenuItem (ID_OPENGROUPFOLDER, MF_BYCOMMAND | MF_GRAYED);
		pPopup->EnableMenuItem (ID_GRPSTARTALL, MF_BYCOMMAND | MF_GRAYED);
		pPopup->EnableMenuItem (ID_GRPSTOPALL, MF_BYCOMMAND | MF_GRAYED);
		pPopup->EnableMenuItem (ID_GRPDELETEALL, MF_BYCOMMAND | MF_GRAYED);
		pPopup->EnableMenuItem (ID_GRPDELETEALLSUCCESSFUL, MF_BYCOMMAND | MF_GRAYED);
		pPopup->EnableMenuItem (ID_GRPDELETEALLDEADDLDS, MF_BYCOMMAND | MF_GRAYED);
	}

	CPoint pt (m_rbX, m_rbY);
	ClientToScreen (&pt);

	m_odmenu.Attach (&menu, FALSE);

	fsSetImage images [] =
	{
		fsSetImage (ID_GRPCREATE, 0),
		fsSetImage (ID_GRPDELETE, 1),
		fsSetImage (ID_GRPDELETEALL, 2),
		fsSetImage (ID_GRPPROPERTIES, 3),
	};

	m_odmenu.SetImages (images, sizeof (images) / sizeof (fsSetImage));

	pPopup->TrackPopupMenu (TPM_RIGHTBUTTON | TPM_TOPALIGN | TPM_LEFTALIGN,	pt.x, pt.y, this);
	m_odmenu.Detach ();

	menu.DestroyMenu ();
}
void CHotGamePanel::OnNMRClickListGame(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
	*pResult = 0;

	int nItem = m_lstGame.GetNextItem(-1, LVIS_SELECTED);
	if (nItem == -1 || nItem >= (int)(m_GameInfo.size()))
		return ;

	CMenu menu;
	menu.LoadMenu(MAKEINTRESOURCE(IDR_TRAY_MENU));
	CMenu* pContextMenu = menu.GetSubMenu(1);

	CPoint oPoint;
	GetCursorPos( &oPoint );
	SetForegroundWindow();
	CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();

	for (UINT idx=0; idx<pContextMenu->GetMenuItemCount(); idx++)
	{
		UINT uFlags =  0;
		switch(pFrame->m_pPopMenu[idx].dwId)
		{
		case ID_POP_SAVE_PROGRESS:
			{
				uFlags = MF_BYCOMMAND|MF_OWNERDRAW|MF_GRAYED;
				if (m_GameInfo[nItem]->SaveFilter.IsEmpty())
				{
					lstrcpy(pFrame->m_pPopMenu[idx].szText, TEXT("保存进度(未设置)"));
				}
				else
				{
					lstrcpy(pFrame->m_pPopMenu[idx].szText, TEXT("保存进度"));
				}
				break;
			}
		case ID_POP_LOAD_PROGRESS:
			{   
				uFlags = MF_BYCOMMAND|MF_OWNERDRAW|MF_GRAYED;
				if (m_GameInfo[nItem]->SaveFilter.IsEmpty())
				{
					lstrcpy(pFrame->m_pPopMenu[idx].szText, TEXT("读取进度(未设置)"));
				}
				else
				{
					lstrcpy(pFrame->m_pPopMenu[idx].szText, TEXT("读取进度"));
				}
				break;
			}
		default:
			{
				uFlags =  MF_BYCOMMAND|MF_OWNERDRAW;
				break;
			}
		}
		pContextMenu->ModifyMenu(pFrame->m_pPopMenu[idx].dwId, uFlags, 
			pFrame->m_pPopMenu[idx].dwId, (LPCTSTR)&pFrame->m_pPopMenu[idx]);
	}
	pContextMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
		oPoint.x, oPoint.y, this);
}
Example #18
0
void CBCListCtrl::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();
		m_pMainWnd->NowAddMessageType = ListType;
		if(ListType==1)
		{
			
			VERIFY(menu.LoadMenu(IDR_POPUP_BC));
	//		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);
		
			if(m_pMainWnd->TabProjDlg.ProjectDlg[m_pMainWnd->m_now_SelectChannel].m_Tree.BCRun_flag)
			{
				pPopup->EnableMenuItem(ID_INSERTBCMES,MF_GRAYED);
				pPopup->EnableMenuItem(ID_DELETEBCMES,MF_GRAYED);

				pPopup->EnableMenuItem(ID_MOVEUPMESSAGE,MF_GRAYED);
				pPopup->EnableMenuItem(ID_MOVEDOWNMESSAGE,MF_GRAYED);

				pPopup->EnableMenuItem(ID_PROPEBC,MF_GRAYED);
				pPopup->EnableMenuItem(AFX_ID_OPENMESSAGE,MF_GRAYED);
				//pPopup->EnableMenuItem(AFX_ID_ENABLEMESSAGE,MF_GRAYED);
				//pPopup->EnableMenuItem(AFX_ID_DISABLEMESSAGE,MF_GRAYED);

				pPopup->ModifyMenu(ID_RUNBC,MF_BYCOMMAND,ID_RUNBC,">ÔËÐÐ");
				pPopup->ModifyMenu(ID_STOPBC,MF_BYCOMMAND,ID_STOPBC," ֹͣ");
				del_flag  = 0;
			}
			else
			{
				pPopup->EnableMenuItem(ID_INSERTBCMES,MF_ENABLED);
				pPopup->EnableMenuItem(ID_DELETEBCMES,MF_ENABLED);

				pPopup->EnableMenuItem(ID_MOVEUPMESSAGE,MF_ENABLED);
				pPopup->EnableMenuItem(ID_MOVEDOWNMESSAGE,MF_ENABLED);

				pPopup->EnableMenuItem(ID_PROPEBC,MF_ENABLED);
				pPopup->EnableMenuItem(AFX_ID_OPENMESSAGE,MF_ENABLED);

				//pPopup->EnableMenuItem(AFX_ID_ENABLEMESSAGE,MF_ENABLED);
				//pPopup->EnableMenuItem(AFX_ID_DISABLEMESSAGE,MF_ENABLED);

				pPopup->ModifyMenu(ID_RUNBC,MF_BYCOMMAND,ID_RUNBC," ÔËÐÐ");
				pPopup->ModifyMenu(ID_STOPBC,MF_BYCOMMAND,ID_STOPBC,">Í£Ö¹");
			}
			if(del_flag==0)
			{
				pPopup->EnableMenuItem(ID_DELETEBCMES,MF_GRAYED);
				pPopup->EnableMenuItem(ID_MESSAGEMOVE1,MF_GRAYED);

				pPopup->EnableMenuItem(ID_MOVEUPMESSAGE,MF_GRAYED);
				pPopup->EnableMenuItem(ID_MOVEDOWNMESSAGE,MF_GRAYED);

				//pPopup->EnableMenuItem(AFX_ID_ENABLEMESSAGE,MF_GRAYED);
				//pPopup->EnableMenuItem(AFX_ID_DISABLEMESSAGE,MF_GRAYED);
			}
			else if(del_flag==1)
			{
				pPopup->EnableMenuItem(ID_DELETEBCMES,MF_ENABLED);
				pPopup->EnableMenuItem(ID_MESSAGEMOVE1,MF_ENABLED);

				pPopup->EnableMenuItem(ID_MOVEUPMESSAGE,MF_ENABLED);
				pPopup->EnableMenuItem(ID_MOVEDOWNMESSAGE,MF_ENABLED);

				//pPopup->EnableMenuItem(AFX_ID_ENABLEMESSAGE,MF_ENABLED);
				//pPopup->EnableMenuItem(AFX_ID_DISABLEMESSAGE,MF_ENABLED);
			}

			pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x,point.y,pWndPopupOwner);
		}
		else if(ListType==2)
		{
			VERIFY(menu.LoadMenu(IDR_POPUP_BC2));
	//		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);
		
			if(m_pMainWnd->TabProjDlg.ProjectDlg[m_pMainWnd->m_now_SelectChannel].m_Tree.BCRun_flag)
			{
				pPopup->EnableMenuItem(ID_INSERTBCMES,MF_GRAYED);
				pPopup->EnableMenuItem(ID_DELETEBCMES,MF_GRAYED);
				
				

				pPopup->EnableMenuItem(ID_PROPEBC,MF_GRAYED);
				del_flag  = 0;
			}
			else
			{
				pPopup->EnableMenuItem(ID_INSERTBCMES,MF_ENABLED);
				pPopup->EnableMenuItem(ID_DELETEBCMES,MF_ENABLED);
				pPopup->EnableMenuItem(ID_PROPEBC,MF_ENABLED);
			}
			if(del_flag==0)
			{
				pPopup->EnableMenuItem(ID_DELETEBCMES,MF_GRAYED);
				pPopup->EnableMenuItem(ID_MESSAGEMOVE1,MF_GRAYED);

				pPopup->EnableMenuItem(ID_MOVEUPMESSAGE,MF_GRAYED);
				pPopup->EnableMenuItem(ID_MOVEDOWNMESSAGE,MF_GRAYED);
			}
			else if(del_flag==1)
			{
				pPopup->EnableMenuItem(ID_DELETEBCMES,MF_ENABLED);
				pPopup->EnableMenuItem(ID_MESSAGEMOVE1,MF_ENABLED);

				pPopup->EnableMenuItem(ID_MOVEUPMESSAGE,MF_ENABLED);
				pPopup->EnableMenuItem(ID_MOVEDOWNMESSAGE,MF_ENABLED);
			}

			pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x,point.y,pWndPopupOwner);
		}
}
Example #19
0
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 CCompareResultsDlg::OnItemRightClick(NMHDR *pNMHDR, LRESULT *pLResult)
{
  *pLResult = 0; // Perform default processing on return

  NMLISTVIEW *pNMLV = (NMLISTVIEW *)pNMHDR;

  m_LCResults.SetRow(pNMLV->iItem);

  CPoint msg_pt = ::GetMessagePos();
  CMenu menu;
  int ipopup;
  bool bTargetRO(true), bSourceRO(true);

  if (m_LCResults.GetSelectedCount() != 1) {
    // Special processing - only allow "Copy All" items to original or 
    // "Synchronise All" items to original
    // Do not allow "Synchronise All" is any selected entry does not
    // have a corresponding entry in the original DB
    // No point if original is R-O - is checked in OnItemChanging()
    m_LCResults.SetColumn(COMPARE);
    ipopup = IDR_POPCOPYALLTOORIGINAL;
    bTargetRO = m_bOriginalDBReadOnly;
    bSourceRO = m_bComparisonDBReadOnly;
    
    bool bNoSyncAll(false);
    POSITION pos = m_LCResults.GetFirstSelectedItemPosition();

    while (pos) {
      const int irow = m_LCResults.GetNextSelectedItem(pos);
      DWORD_PTR dwItemData = m_LCResults.GetItemData(irow);
      st_CompareData *pst_data = GetCompareData(dwItemData);
      ASSERT(pst_data != NULL);
      if (pst_data->uuid0 == pws_os::CUUID::NullUUID() || pst_data->indatabase != BOTH) {
        bNoSyncAll = true;
        break;
      }
    }

    if (menu.LoadMenu(ipopup)) {
      MENUINFO minfo ={0};
      minfo.cbSize = sizeof(MENUINFO);
      minfo.fMask = MIM_MENUDATA;
      minfo.dwMenuData = ipopup;
      BOOL brc = menu.SetMenuInfo(&minfo);
      ASSERT(brc != 0);

      CMenu *pPopup = menu.GetSubMenu(0);
      ASSERT(pPopup != NULL);
      
      if (bNoSyncAll)
        pPopup->RemoveMenu(ID_MENUITEM_SYNCHRONIZEALL, MF_BYCOMMAND);

      pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, msg_pt.x, msg_pt.y, this);
    }
    return;
  }

  switch (pNMLV->iSubItem) {
    case 0:
      // Column is the current database
      // Therefore: Source = Current DB, Target = Comparison DB
      m_LCResults.SetColumn(CURRENT);
      ipopup = IDR_POPEDITVIEWORIGINAL;
      bTargetRO = m_bComparisonDBReadOnly;
      bSourceRO = m_bOriginalDBReadOnly;
      break;
    case 1:
      // Column is the comparison database
      // Therefore: Source = Comparison DB, Target = Current DB
      m_LCResults.SetColumn(COMPARE);
      ipopup = IDR_POPCOPYTOORIGINAL;
      bTargetRO = m_bOriginalDBReadOnly;
      bSourceRO = m_bComparisonDBReadOnly;
      break;
    default:
      return;
  }

  DWORD_PTR dwItemData = m_LCResults.GetItemData(m_LCResults.GetRow());
  st_CompareData *pst_data = GetCompareData(dwItemData);
  ASSERT(pst_data != NULL);

  // Get where this entry is:
  // IDENTICAL means CURRENT + COMPARE but identical
  // BOTH      means CURRENT + COMPARE but with differences
  int indatabase = pst_data->indatabase;

  // If entry isn't in this database that the user click or the entry is only
  // in the other column - do nothing
  if (m_LCResults.GetColumn() != indatabase && 
      (indatabase != BOTH && indatabase != IDENTICAL))
    return;

  if (menu.LoadMenu(ipopup)) {
    MENUINFO minfo ={0};
    minfo.cbSize = sizeof(MENUINFO);
    minfo.fMask = MIM_MENUDATA;
    minfo.dwMenuData = ipopup;
    BOOL brc = menu.SetMenuInfo(&minfo);
    ASSERT(brc != 0);

    CMenu *pPopup = menu.GetSubMenu(0);
    ASSERT(pPopup != NULL);

    // Disable copy/sychnronize if target is read-only or entry is protected
    // Delete synchronize if not in both databases (and not already identical)
    if (m_LCResults.GetColumn() == COMPARE) {
      // User clicked on Comparison DB
      if (bTargetRO) {
        // Can't modify RO DB
        pPopup->RemoveMenu(ID_MENUITEM_COPY_TO_ORIGINAL, MF_BYCOMMAND);
        pPopup->RemoveMenu(ID_MENUITEM_SYNCHRONIZE, MF_BYCOMMAND);
      } else {
        // If it is in the current DB (i.e. BOTH as we know it is in the compare
        // column as the user has clicked on it) and is protected - don't allow copy
        if (indatabase == BOTH && pst_data->bIsProtected0)
          pPopup->RemoveMenu(ID_MENUITEM_COPY_TO_ORIGINAL, MF_BYCOMMAND);
      }
    }

    // Can't synchonize pr compare if not in both databases!
    if (indatabase != BOTH) {
      pPopup->RemoveMenu(ID_MENUITEM_SYNCHRONIZE, MF_BYCOMMAND);
      pPopup->RemoveMenu(ID_MENUITEM_COMPARE_ENTRIES, MF_BYCOMMAND);
    }

    // Change Edit to View if source read-only OR entry is protected OR if Comparison DB
    if (bSourceRO || pst_data->bIsProtected0) {
      const CString cs_View_Entry(MAKEINTRESOURCE(IDS_VIEWENTRY2));
      pPopup->ModifyMenu(ID_MENUITEM_COMPVIEWEDIT, MF_BYCOMMAND,
                         ID_MENUITEM_COMPVIEWEDIT, cs_View_Entry);
    }

    pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, msg_pt.x, msg_pt.y, this);
  }
}