Пример #1
0
void CDownloadMonitorDlg::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
{
	CMainWnd* pMainWnd = (CMainWnd*)AfxGetMainWnd();
	if ( ! pMainWnd || ! IsWindow( pMainWnd->m_hWnd ) ) return;

	CDownloadsWnd* pDownWnd = (CDownloadsWnd*)pMainWnd->m_pWindows.Find( RUNTIME_CLASS(CDownloadsWnd) );
	if ( ! pDownWnd ) return;

	if ( ! pDownWnd->Select( m_pDownload ) ) return;

	CMenu* pPopup = ::Skin.GetMenu( _T("CDownloadsWnd.Download") );
	if ( ! pPopup ) return;

	MENUITEMINFO pInfo;
	pInfo.cbSize	= sizeof(pInfo);
	pInfo.fMask		= MIIM_STATE;
	GetMenuItemInfo( pPopup->GetSafeHmenu(), m_pDownload->IsCompleted() ?
		ID_DOWNLOADS_LAUNCH_COMPLETE : ID_DOWNLOADS_LAUNCH_COPY, FALSE, &pInfo );
	pInfo.fState	|= MFS_DEFAULT;
	SetMenuItemInfo( pPopup->GetSafeHmenu(), m_pDownload->IsCompleted() ?
		ID_DOWNLOADS_LAUNCH_COMPLETE : ID_DOWNLOADS_LAUNCH_COPY, FALSE, &pInfo );

	CoolMenu.AddMenu( pPopup, TRUE );

	UINT nID = pPopup->TrackPopupMenu( TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON|TPM_RETURNCMD,
		point.x, point.y, pDownWnd );

	if ( nID && pDownWnd->Select( m_pDownload ) )
	{
		pDownWnd->SendMessage( WM_COMMAND, nID );
	}
}
void CImageTreeCtrl::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
{
	// TODO: Add your message handler code here

	
	CPoint pt(point);
	ScreenToClient(&pt);
	UINT flags;
	HTREEITEM hItem = HitTest(pt, &flags);
	bool bOnItem = (flags & TVHT_ONITEM) != 0;

	CMenu add;
	VERIFY(add.CreatePopupMenu());
	if(bOnItem) {
		if(CanInsertItem(GetParentItem(hItem)))
			VERIFY(add.AppendMenu(MF_STRING, ID_ADD_SIBLING, _T("New Sibling\tINS")));
		if(CanInsertItem(hItem))
			VERIFY(add.AppendMenu(MF_STRING, ID_ADD_CHILD, _T("New Child Item\tCtrl+INS")));
	}
	if(CanInsertItem(0))
		VERIFY(add.AppendMenu(MF_STRING, ID_ADD_ROOT, _T("New Root Item\tShift+INS")));

	CMenu sort;
	VERIFY(sort.CreatePopupMenu());
	VERIFY(sort.AppendMenu(MF_STRING, ID_SORT_LEVEL, _T("Current Level\tCtrl+S")));
	VERIFY(sort.AppendMenu(MF_STRING, ID_SORT_LEVELANDBELOW, _T("Current Level And Below\tCtrl+Shift+S")));

	CMenu menu;
	VERIFY(menu.CreatePopupMenu());
	if(bOnItem) {
		if(CanEditLabel(hItem))
			VERIFY(menu.AppendMenu(MF_STRING, ID_RENAME, _T("Rename\tF2")));
		if(CanDeleteItem(hItem))
			VERIFY(menu.AppendMenu(MF_STRING, ID_DELETE, _T("Delete\tDEL")));
	}
	if(add.GetMenuItemCount() > 0)
		VERIFY(menu.AppendMenu(MF_POPUP, UINT(add.GetSafeHmenu()), _T("Add")));
	if(bOnItem) {
		if(menu.GetMenuItemCount() > 0)
			VERIFY(menu.AppendMenu(MF_SEPARATOR));
		VERIFY(menu.AppendMenu(MF_POPUP, UINT(sort.GetSafeHmenu()), _T("Sort")));
	}

	

	// maybe the menu is empty...
	if(menu.GetMenuItemCount() > 0)
		menu.TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, this);
	

}
BOOL COXShellNamespaceNavigator::InvokeDefaultCommand(const LPSHELLFOLDER lpParentFolder, 
													  const LPITEMIDLIST lpRelativeIDL) const
{
	// retrieve the default command ID
	HMENU hMenu=GetObjectContextMenu(lpParentFolder,lpRelativeIDL,CMF_DEFAULTONLY);
	if(hMenu==NULL)
	{
		TRACE(_T("COXShellNamespaceNavigator::InvokeDefaultCommand: GetObjectContextMenu() failed\n"));
		return FALSE;
	}

	CMenu menuPopup;
	VERIFY(menuPopup.Attach(hMenu));
	if(menuPopup.GetMenuItemCount()==0)
	{
		TRACE(_T("COXShellNamespaceNavigator::InvokeDefaultCommand: there is no context menu for the specified object\n"));
		return FALSE;
	}

	int nDefaultCmdID=-1;
#if _MFC_VER > 0x0421
	nDefaultCmdID=menuPopup.GetDefaultItem(GMDI_GOINTOPOPUPS,FALSE);
#else
	nDefaultCmdID=::GetMenuDefaultItem(menuPopup.GetSafeHmenu(),
		FALSE,GMDI_GOINTOPOPUPS);
#endif
	if(nDefaultCmdID==-1)
	{
		TRACE(_T("COXShellNamespaceNavigator::InvokeDefaultCommand: there is no default menu item for the specified object\n"));
		return FALSE;
	}
	VERIFY(menuPopup.DestroyMenu());

	return InvokeCommand(lpParentFolder,lpRelativeIDL,nDefaultCmdID,CMF_DEFAULTONLY);
}
Пример #4
0
void CDlgMenuThread::BuildMenu(CMenu* menu, CMenu* pMenu) 
{
	for ( UINT i=0; i< pMenu->GetMenuItemCount(); i++ )
	{
		CMenu* sub = pMenu->GetSubMenu(i);
		
		CString menuText;
		pMenu->GetMenuString(i, menuText, MF_BYPOSITION);
		UINT menuFlag = pMenu->GetMenuState(i, MF_BYPOSITION);
		UINT menuCode = pMenu->GetMenuItemID(i) ;

		if ( sub != NULL )
		{
			CMenu* subMenu = CreateMenu();
			BuildMenu(subMenu,(CMenu*)sub );
	        menu->AppendMenu(MF_POPUP, (UINT)subMenu->GetSafeHmenu(), menuText);
		}

		else
		{
	        menu->AppendMenu(MF_STRING | menuFlag, menuCode, menuText);
			if ( menuFlag & MF_CHECKED ) 
				 menu->CheckMenuItem( menu->GetMenuItemCount() - 1, MF_CHECKED);
		}

	}
}
Пример #5
0
BOOL CMainFrame::OnShowMDITabContextMenu (CPoint point, DWORD dwAllowedItems, BOOL bDrop)
{
	TRACE("CMainFrame::OnShowMDITabContextMenu");

	if (bDrop || !theApp.m_Options.m_bMDITabsContextMenu)
	{
		return FALSE;
	}

	CMenu menu;
	VERIFY(menu.LoadMenu (IDR_POPUP_MDITABS));

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

	if (pPopup)
	{
		if ((dwAllowedItems & AFX_MDI_CAN_BE_DOCKED) == 0)
		{
			pPopup->DeleteMenu (ID_MDI_TABBED, MF_BYCOMMAND);
		}

		CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu;
		if (pPopupMenu)
		{
			pPopupMenu->SetAutoDestroy (FALSE);
			pPopupMenu->Create (this, point.x, point.y, pPopup->GetSafeHmenu ());
		}
	}

	return TRUE;
}
Пример #6
0
void CAgencyList::OnContextMenu(CWnd* pWnd, CPoint point) 
{
	CMenu pMenu;
	pMenu.LoadMenu( IDR_AGENCY );
	
	CMenu* pPopup = pMenu.GetSubMenu( 0 );
	
	MENUITEMINFO pInfo;
	pInfo.cbSize	= sizeof(pInfo);
	pInfo.fMask		= MIIM_STATE;
	GetMenuItemInfo( pPopup->GetSafeHmenu(), ID_AGENCY_XPROPERTY, FALSE, &pInfo );
	pInfo.fState	|= MFS_DEFAULT;
	SetMenuItemInfo( pPopup->GetSafeHmenu(), ID_AGENCY_XPROPERTY, FALSE, &pInfo );
	
	pPopup->TrackPopupMenu( TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, point.x, point.y, AfxGetMainWnd() );
}
Пример #7
0
//*************************************************************************************
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;
}
Пример #8
0
BOOL CSkin::LoadMenu(CXMLElement* pXML)
{
	CString strName = pXML->GetAttributeValue( _T("name") );
	if ( strName.IsEmpty() ) return FALSE;
	
	CMenu* pMenu = NULL;
	
	if ( m_pMenus.Lookup( strName, (void*&)pMenu ) )
	{
		delete pMenu;
		m_pMenus.RemoveKey( strName );
	}
	
	pMenu = new CMenu();
	
	if ( pXML->GetAttributeValue( _T("type"), _T("popup") ).CompareNoCase( _T("bar") ) == 0 )
	{
		pMenu->CreateMenu();
	}
	else
	{
		pMenu->CreatePopupMenu();
	}
	
	if ( CreateMenu( pXML, pMenu->GetSafeHmenu() ) )
	{
		m_pMenus.SetAt( strName, pMenu );
		return TRUE;
	}
	else
	{
		delete pMenu;
		return FALSE;
	}
}
Пример #9
0
BOOL CMainFrame::OnShowMDITabContextMenu (CPoint point, DWORD dwAllowedItems, BOOL bDrop)
{
	CMenu menu;
	VERIFY(menu.LoadMenu (bDrop ? IDR_POPUP_DROP_MDITABS : IDR_POPUP_MDITABS));

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

	if ((dwAllowedItems & BCGP_MDI_CREATE_HORZ_GROUP) == 0)
	{
		pPopup->DeleteMenu (ID_MDI_NEW_HORZ_TAB_GROUP, MF_BYCOMMAND);
	}

	if ((dwAllowedItems & BCGP_MDI_CREATE_VERT_GROUP) == 0)
	{
		pPopup->DeleteMenu (ID_MDI_NEW_VERT_GROUP, MF_BYCOMMAND);
	}

	if ((dwAllowedItems & BCGP_MDI_CAN_MOVE_NEXT) == 0)
	{
		pPopup->DeleteMenu (ID_MDI_MOVE_TO_NEXT_GROUP, MF_BYCOMMAND);
	}

	if ((dwAllowedItems & BCGP_MDI_CAN_MOVE_PREV) == 0)
	{
		pPopup->DeleteMenu (ID_MDI_MOVE_TO_PREV_GROUP, MF_BYCOMMAND);
	}

	CBCGPPopupMenu* pPopupMenu = new CBCGPPopupMenu;
	pPopupMenu->SetAutoDestroy (FALSE);
	pPopupMenu->Create (this, point.x, point.y, pPopup->GetSafeHmenu ());

	return TRUE;
}
Пример #10
0
bool CMainFrame::UpdateTemplateMenu(CMFCPopupMenu* pMenu)
{
	if(pMenu == nullptr)
	{
		return false;
	}


	CString str;
	CMFCToolBarMenuButton* pParent = pMenu->GetParentButton();

	if(pParent == nullptr)
	{
		return false;
	}
	if(pParent->m_strText != L"GameObject")
	{
		return false;
	}


	UpdateTemplateMap();
	using namespace engine;

	boost::unordered_map<std::wstring, std::vector<engine::GameObjectTemplate*> >::iterator it = m_templateMap.begin();

	pMenu->RemoveAllItems();

	CMFCToolBarMenuButton b(ID_GAMEOBJECT_CREATEEMPTY, nullptr, -1, L"Empty");

	pMenu->InsertItem(b);

	pMenu->InsertSeparator();

	int id = ID_COMPONENT_MENU_BASE + 1001;
	for(it; it != m_templateMap.end(); ++it)
	{
		if(it->second.size() == 0)
		{
			continue;
		}
		CMenu m;
		
		m.CreateMenu();
		for(size_t i = 0; i < it->second.size(); ++i)
		{
			m.InsertMenuW(i, MF_BYPOSITION, id, it->second[i]->GetName().c_str());

			id++;
		}

		CMFCToolBarMenuButton b(-1, m.GetSafeHmenu(), -1, it->first.c_str());
		m.Detach();

		pMenu->InsertItem(b);
	}

	return true;
}
Пример #11
0
void CRemoteWnd::OnRButtonDown(UINT /*nFlags*/, CPoint point)
{
	CMenu* pMenu = Skin.GetMenu( L"CRemoteWnd" );
	if ( pMenu == NULL ) pMenu = Skin.GetMenu( L"CMainWnd.Tray" );
	if ( pMenu == NULL ) return;

	MENUITEMINFO pInfo;
	pInfo.cbSize	= sizeof( pInfo );
	pInfo.fMask		= MIIM_STATE;
	GetMenuItemInfo( pMenu->GetSafeHmenu(), ID_TRAY_OPEN, FALSE, &pInfo );
	pInfo.fState	|= MFS_DEFAULT;
	SetMenuItemInfo( pMenu->GetSafeHmenu(), ID_TRAY_OPEN, FALSE, &pInfo );

	ClientToScreen( &point );
	pMenu->TrackPopupMenu( TPM_CENTERALIGN|TPM_TOPALIGN|TPM_RIGHTBUTTON,
		point.x, point.y, AfxGetMainWnd(), NULL );
}
Пример #12
0
BOOL CKofDlgImpl::PreTranslateMessage( MSG* pMsg )
{
	switch (pMsg->message)
	{
		case WM_NCRBUTTONUP:
			if (pMsg->message == WM_NCRBUTTONUP && pMsg->hwnd == m_Dlg.GetSafeHwnd () && IsOwnerDrawCaption ())
			{
				CPoint pt (AFX_GET_X_LPARAM(pMsg->lParam), AFX_GET_Y_LPARAM(pMsg->lParam));

				UINT nHit = OnNcHitTest (pt);

				if (nHit == HTCAPTION || nHit == HTSYSMENU)
				{
					CMenu* pMenu = m_Dlg.GetSystemMenu (FALSE);
					if (pMenu->GetSafeHmenu () != NULL && ::IsMenu (pMenu->GetSafeHmenu ()))
					{
						/*UINT uiRes = ::TrackPopupMenu (pMenu->GetSafeHmenu(), TPM_LEFTBUTTON | TPM_RETURNCMD, 
							pt.x, pt.y, 0, m_Dlg.GetSafeHwnd (), NULL);*/

						UINT uiRes = 0;
						if (((CWinAppEx*)AfxGetApp())->GetContextMenuManager() != NULL)
						{
							((CWinAppEx*)AfxGetApp())->GetContextMenuManager()->ShowPopupMenu(pMenu->GetSafeHmenu(), pt.x, pt.y, &m_Dlg, TRUE);
						} 
						else
						{
							uiRes = ::TrackPopupMenu (pMenu->GetSafeHmenu(), TPM_LEFTBUTTON | TPM_RETURNCMD, 
								pt.x, pt.y, 0, m_Dlg.GetSafeHwnd (), NULL);
						}

						if (uiRes != 0)
						{
							m_Dlg.SendMessage (WM_SYSCOMMAND, uiRes);
							return TRUE;
						}
					}

				}
			}
			break;
	}

	return FALSE;
}
Пример #13
0
////////////////////////////////////////////////////////////
//	Desc:
//		Handles all the messages that are delivered to the
//		shell icon in the system tray.
////////////////////////////////////////////////////////////
LRESULT CTrayIcon::OnNotification( WPARAM uID, LPARAM lEvent ) {	
	if( ( uID != m_notifydata.uID ) ||  
		( ( lEvent != WM_RBUTTONUP ) && ( lEvent != WM_LBUTTONDBLCLK ) ) ||
		( ! m_menu.GetSafeHmenu() ) )  {
			return 0;
	}

	CPoint pt;	
	CMenu* pPop = m_menu.GetSubMenu( 0 );
	::SetMenuDefaultItem( pPop->GetSafeHmenu(), 0, TRUE);

	if( lEvent == WM_RBUTTONUP ) {
			// if right click we need to display popup menu.		
		::GetCursorPos( &pt );
		::SetForegroundWindow( m_notifydata.hWnd );
		::TrackPopupMenuEx( pPop->GetSafeHmenu(), 0, pt.x, pt.y, m_notifydata.hWnd, NULL );
	}else{
		::SendMessage( m_notifydata.hWnd, WM_COMMAND, pPop->GetMenuItemID( 0 ), 0 );
	}
	
	return 1;
}
Пример #14
0
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();
}
Пример #15
0
bool CMainFrame::UpdateComponentMenu(CMFCPopupMenu* pMenu)
{
	if(pMenu == nullptr)
	{
		return false;
	}

	CString str;
	CMFCToolBarMenuButton* pParent = pMenu->GetParentButton();

	if(pParent == nullptr)
	{
		return false;
	}
	if(pParent->m_strText != L"Component")
	{
		return false;
	}

	using namespace engine;

	UpdateComClassMap();

	boost::unordered_map<std::wstring, std::vector<ExtPackage::ComponentClass*> >::iterator it = m_ComClassMap.begin();

	pMenu->RemoveAllItems();

	int id = ID_COMPONENT_MENU_BASE + 1;
	for(it; it != m_ComClassMap.end(); ++it)
	{
		if(it->second.size() == 0)
		{
			continue;
		}
		CMenu m;
		m.CreateMenu();
		for(size_t i = 0; i < it->second.size(); ++i)
		{
			m.InsertMenuW(i, MF_BYPOSITION, id, it->second[i]->m_name.c_str());

			id++;
		}

		CMFCToolBarMenuButton b(-1, m.GetSafeHmenu(), -1, it->first.c_str());
		m.Detach();

		pMenu->InsertItem(b);
	}

	return true;
}
Пример #16
0
// Add a popup menu for the different marker types and frequencies
void	CXYChart::AddMarkerPopup( CMenu *addMenu, LPCTSTR titleString, int dataID, int startVal )
{
	CMenu			subMenu;
	int				i, markerShape, freq;
	CString			string;
	UINT			flag;

	subMenu.CreatePopupMenu();

	// Marker shape
	markerShape = GetMarkerType( dataID );
	flag = GetPopupCheckedFlag( markerShape == kXYMarkerNone );
	addMenu->AppendMenu( MF_STRING | flag, startVal+kXYMarkerNone, _T("No marker"));
	flag = GetPopupCheckedFlag( markerShape == kXYMarkerCircle );
	addMenu->AppendMenu( MF_STRING | flag, startVal+kXYMarkerCircle, _T("Circle marker"));
	flag = GetPopupCheckedFlag( markerShape == kXYMarkerSquare );
	addMenu->AppendMenu( MF_STRING | flag, startVal+kXYMarkerSquare, _T("Square marker"));
	flag = GetPopupCheckedFlag( markerShape == kXYMarkerTriangle );
	addMenu->AppendMenu( MF_STRING | flag, startVal+kXYMarkerTriangle, _T("Triangle marker"));
	flag = GetPopupCheckedFlag( markerShape == kXYMarkerX );
	addMenu->AppendMenu( MF_STRING | flag, startVal+kXYMarkerX, _T("X marker"));

	addMenu->AppendMenu( MF_SEPARATOR);

	flag = GetPopupCheckedFlag( GetMarkerFillState( dataID ) );
	addMenu->AppendMenu( MF_STRING | flag, startVal+kMenuMarkerFill, _T("Filled marker"));

	addMenu->AppendMenu( MF_SEPARATOR);
	
	// Marker size
	for( i = 0; i < nMarkerSizes; i++ )
	{
		flag = GetPopupCheckedFlag( GetMarkerSize( dataID ) == 10*(i+1) );
		string.Format( _T("%d"), i+1 );
		subMenu.AppendMenu( MF_STRING | flag, startVal+i+kMenuMarkerSize, string );
	}
	addMenu->AppendMenu( MF_POPUP, (UINT) subMenu.GetSafeHmenu(), _T("Marker size"));

	// Marker frequency
	freq = abs(GetMarkerFrequency( dataID ));
	if( freq == 1 ) freq = 10;
	flag = GetPopupCheckedFlag( GetMarkerFrequency( dataID ) == 1 );
	addMenu->AppendMenu( MF_STRING | flag, startVal+kMenuMarkerFrequency, _T("Mark every point"));
	flag = GetPopupCheckedFlag( (GetMarkerFrequency( dataID )) > 1 );
	string.Format( _T("Mark every %d points"), freq );
	addMenu->AppendMenu( MF_STRING | flag, startVal+kMenuMarkerFrequency+1, string );
	flag = GetPopupCheckedFlag( (GetMarkerFrequency( dataID )) < 0 );
	string.Format( _T("Mark %d points"), freq );
	addMenu->AppendMenu( MF_STRING | flag, startVal+kMenuMarkerFrequency+2, string );
}
Пример #17
0
void CRunView::ShowPictureComplete(LPCTSTR lpszPicture)
{
	IDispatch* pMenuObject = GetMainMenu();

	if (pMenuObject != NULL)
	{
		m_arrAccels.RemoveAll();

		if (m_menu.m_hMenu != NULL)
			m_menu.DestroyMenu();

		m_menu.CreateMenu();
		
		CComQIPtr<IDrawMenu, &IID_IDrawMenu> spDrawMenu(pMenuObject);
		long lCount;
		spDrawMenu->get_ItemCount(&lCount);
		
		int nIndex = 0;
		AddMenuItems(m_menu.m_hMenu, spDrawMenu, nIndex, lCount, 0);
		
		if (m_pMenu == NULL)
		{
			CMenu* pMenu = AfxGetMainWnd()->GetMenu();
			if (pMenu != NULL)
				m_hAltMenu = pMenu->GetSafeHmenu();
		}

		AfxGetMainWnd()->SetMenu(&m_menu);
		
		m_pMenu = spDrawMenu;

		m_bLockMenu = FALSE;
	
		pMenuObject->Release();

		if (m_arrAccels.GetSize() > 0)
			m_hAccelTable = CreateAcceleratorTable(m_arrAccels.GetData(), m_arrAccels.GetSize());
	}
	else
	{
		if (m_pMenu != NULL)
		{
			::SetMenu(AfxGetMainWnd()->GetSafeHwnd(), m_hAltMenu);
			
			m_hAltMenu = NULL;
			m_pMenu = NULL;
		}
	}
}
//**************************************************************************************
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 ());
		}
	}
}
Пример #19
0
// Adds a popup menu for font sizes.
void	AddFontSizePopup( CMenu *addMenu, LPCTSTR titleString, long compare, int startVal )
{
	CMenu			subMenu;
	int				i;
	CString			string;
	UINT			flag;

	subMenu.CreatePopupMenu();

	for( i = 0; i < nFontSizes; i++ )
	{
		flag = GetPopupCheckedFlag( compare == fontSizes[i] );
		string.Format( _T("%d"), fontSizes[i] );
		subMenu.AppendMenu( MF_STRING | flag, startVal+i, string );
	}

	addMenu->AppendMenu( MF_POPUP, (UINT) subMenu.GetSafeHmenu(), titleString );
}
Пример #20
0
// Add a popup for the line size of a data set
void	CXYChart::AddLineSizePopup( CMenu *addMenu, LPCTSTR titleString, int dataID, int startVal )
{
	CMenu		subMenu;
	int			i;
	UINT		flag;
	CString		string;

	subMenu.CreatePopupMenu();

	// Line size
	for( i = 0; i < nLineSizes; i++ )
	{
		flag = GetPopupCheckedFlag( GetDataLineSize( dataID ) == i+1 );
		string.Format( _T("%d"), i+1 );
		subMenu.AppendMenu( MF_STRING | flag, startVal+i, string );
	}
	addMenu->AppendMenu( MF_POPUP, (UINT) subMenu.GetSafeHmenu(), titleString );
}
Пример #21
0
// Add the popup menu for a specific data set
void	CXYChart::AddDataPopupMenus( int whichDataSet, CMenu *menu, int startVal )
{
	CString			string;
	CMenu			dataMenu;
	CMenu			subMenu;
	int				dataID;

	if( whichDataSet < 0 || whichDataSet >= GetDataSetCount() ) return;

	dataID = m_DataID[whichDataSet];

	dataMenu.CreatePopupMenu();

	AddChartTypePopup( &dataMenu, _T("Chart type"), this->GetChartType( dataID ), startVal+kMenuChartType );

	AddLineSizePopup( &dataMenu, _T("Line size"), dataID, startVal + kMenuLineSize );

	AddLineStylePopup( &dataMenu, _T("Line style"), dataID, startVal + kMenuLineStyle );

	dataMenu.AppendMenu( MF_SEPARATOR);

	AddMarkerPopup( &dataMenu, _T("Marker"), dataID, startVal + kMenuMarker );

	string = GetDataTitle( dataID );

	if( string == _T("") )
	{
		string.Format( _T("Data set %d of %d"), whichDataSet + 1, GetDataSetCount() );
	}
	else
	{
		if( string.GetLength() > 15 )
		{
			string = string.Left( 15 );
			string = string + _T("...");
		}
	}

	// Add it to main menu
	dataMenu.AppendMenu( MF_SEPARATOR);
	dataMenu.AppendMenu( MF_STRING, startVal+kMenuDataRange-1, _T("Settings..."));

	menu->AppendMenu( MF_POPUP, (UINT) dataMenu.GetSafeHmenu(), string );
}
//**************************************************************************************
void CBCGPTearOffManager::Reset (HMENU hMenu)
{
	int nCount = m_uiTearOffMenuLast - m_uiTearOffMenuFirst + 1;

	if (hMenu == NULL)	// Reset all
	{
		for (int i = 0; i < nCount; i ++)
		{
			m_arTearOffIDsUsage [i] = 0;
		}

		return;
	}

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

	int iCount = (int) pMenu->GetMenuItemCount ();
	for (int i = 0; i < iCount; i ++)
	{
		CString str;
		pMenu->GetMenuString (i, str, MF_BYPOSITION);

		UINT uiTearOffID = Parse (str);
		if (uiTearOffID >= m_uiTearOffMenuFirst && uiTearOffID <= m_uiTearOffMenuLast)
		{
			m_arTearOffIDsUsage [uiTearOffID - m_uiTearOffMenuFirst] = 0;
		}

		if (pMenu->GetMenuItemID (i) == (UINT)-1)
		{
			CMenu* pPopupMenu = pMenu->GetSubMenu (i);
			ASSERT (pPopupMenu != NULL);

			Reset (pPopupMenu->GetSafeHmenu ());
		}
	}
}
Пример #23
0
void MenuCreator::populateMenu(std::string pluginId, CMenu* menu, Menu itemMenu, IIdGenerator* idgenerator)
{

    switch (itemMenu.mMenuType)
    {
        case PopUp:
        {
            CMenu* popupmenu = new CMenu();
            popupmenu->CreatePopupMenu();
for (auto subitem : itemMenu.submenulist)
            {
                populateMenu(pluginId, popupmenu, subitem, idgenerator);
            }
            int submenucount = popupmenu->GetMenuItemCount();
            menu->AppendMenuA(MF_POPUP, (UINT)popupmenu->GetSafeHmenu(), itemMenu.mName.c_str());
            break;
        }


        case MenuItem:
        {
            //int id;
            idgenerator->generateId(itemMenu.mId, idgenerator->id);
            pluginIdtoMenuId pluginMenuId;
            pluginMenuId.mMenuId = itemMenu.mId;
            pluginMenuId.mPluginId = pluginId;
            mMenuIdPluginInfo[idgenerator->id] = pluginMenuId;
            menu->AppendMenu(MF_BYCOMMAND, idgenerator->id, itemMenu.mName.c_str());
            menu->EnableMenuItem(0, MF_ENABLED);
            break;
        }

        case Separator:
        {
            menu->InsertMenu(menu->GetMenuItemCount(), MF_BYPOSITION | MF_SEPARATOR);
            break;
        }

    }

}
Пример #24
0
LRESULT CDocSelector::OnDSPopup( WPARAM, LPARAM )
{
	m_btnMenuButton.SetState( TRUE );

	CMenu pPopup;
	CString strText;
	UINT nFlags;

	pPopup.CreatePopupMenu();

	for ( int i = m_nDisplayedButtons; i < m_Buttons.GetSize(); i++ )
	{
		((CSwitcherButton *) m_Buttons.GetAt( i ))->GetWindowText( strText );

		if ( m_iSelectedButton == i )
			nFlags = MF_CHECKED | MF_STRING;
		else
			nFlags = MF_STRING;

		pPopup.AppendMenu( nFlags, i + 1, strText );
	}

	CRect rRect;
	m_btnMenuButton.GetWindowRect( &rRect );

	int nChoice = ::TrackPopupMenu( pPopup.GetSafeHmenu(),
		TPM_NONOTIFY | TPM_RETURNCMD | TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_VERTICAL,
		rRect.right, rRect.top, 0, this->GetSafeHwnd(), &rRect );

	if ( nChoice != 0 ) 
	{
		nChoice--;

		if ( m_iSelectedButton != nChoice )
			OnSelChange( (WPARAM)m_Buttons.GetAt( nChoice ),0 );
	}

	m_btnMenuButton.SetState( FALSE );
	return 1;
}
Пример #25
0
// Add a popup for the line size of a data set
void	CXYChart::AddLineStylePopup( CMenu *addMenu, LPCTSTR titleString, int dataID, int startVal )
{
	CMenu		subMenu;
	UINT		flag;
	CString		string;

	subMenu.CreatePopupMenu();

	// We'll just hard code these for now
	flag = GetPopupCheckedFlag( GetDataLineStyle( dataID ) == 0 );
	subMenu.AppendMenu( MF_STRING | flag, startVal,   _T("Solid ____________"));
	flag = GetPopupCheckedFlag( GetDataLineStyle( dataID ) == 1 );
	subMenu.AppendMenu( MF_STRING | flag, startVal+1, _T("Dashed _ _ _ _ _ _"));
	flag = GetPopupCheckedFlag( GetDataLineStyle( dataID ) == 2 );
	subMenu.AppendMenu( MF_STRING | flag, startVal+2, _T("Dotted . . . . . ."));
	flag = GetPopupCheckedFlag( GetDataLineStyle( dataID ) == 3 );
	subMenu.AppendMenu( MF_STRING | flag, startVal+3, _T("Dash-Dot _ . _ . _"));
	flag = GetPopupCheckedFlag( GetDataLineStyle( dataID ) == 4 );
	subMenu.AppendMenu( MF_STRING | flag, startVal+4, _T("Dash-Dot-Dot _ . ."));

	addMenu->AppendMenu( MF_POPUP, (UINT) subMenu.GetSafeHmenu(), titleString );
}
Пример #26
0
void CUserMeetingDlg::OnMyGroup()
{
	CMenu pMenu;
	pMenu.CreatePopupMenu();
	
	if ( m_pXML ) CreateMenuGroup( m_pXML, pMenu );
	
	HMENU hMenu = CreatePopupMenu();
	AppendMenu( pMenu, MF_STRING, MIN_GROUP - 1, _T("我的所有成员") );
	
	CRect rcButton;
	m_wndMember.GetWindowRect( &rcButton );
	
	DWORD nFlags = TPM_LEFTALIGN | TPM_VERTICAL | TPM_RIGHTBUTTON;
	
	if ( UINT nMenuID = pMenu.TrackPopupMenu(nFlags | TPM_RETURNCMD, rcButton.left, rcButton.bottom, this) )
	{
		if ( nMenuID == MIN_GROUP - 1 )
		{
			CString strText;
			m_wndGroup.GetWindowText( strText );
			
			CString str;
			str.Format( "是否发布\"%s\"内的所有成员?", strText );
			
			if (AfxMessageBox(str, MB_OKCANCEL | MB_ICONQUESTION | MB_DEFBUTTON2) == IDOK)
			{
				CMenu* pSubMenu = pMenu.GetSubMenu( pMenu.GetMenuItemCount() - 2 );
				if ( pSubMenu ) PutIntoPhone( pSubMenu->GetSafeHmenu(), 0, pSubMenu->GetMenuItemCount() );
			}
		}
		else
		{
			PutIntoPhone( pMenu, nMenuID );
		}
	}
}
Пример #27
0
int	WINAPI WKPluginShowEventX(char szEvent[128],HWND pParent,COleDateTime dt,BOOL bAskMenu)
{
	static long l=0;
	if(l>0){
		return 0;
	}
	SimpleTracker lc(l);

	CString sEventName=_l2("Scheduled event");
	HINSTANCE hLLHookInst=GetModuleHandle("WP_KeyMaster.wkp");
	_WKIHOTKEYS_GetHotkeyDscByID fpHk=(_WKIHOTKEYS_GetHotkeyDscByID)GetProcAddress(hLLHookInst,"WKIHOTKEYS_GetHotkeyDscByID");
	BOOL bDef=(strcmp(szEvent,DEF_ID)==0);
	if(fpHk){
		char szTitle[256]={0};
		if((*fpHk)(szEvent,szTitle,sizeof(szTitle))){
			sEventName=szTitle;
		}else{
			sEventName=_l2("Attention! Time has come!");
		}
	}
	_GetReminder fp=(_GetReminder)GetProcAddress(hRemin,"GetReminder");
	_IsReminderFamilyPresent fpPr=(_IsReminderFamilyPresent)GetProcAddress(hRemin,"IsReminderFamilyPresent");
	CString sRMKey=szEvent;
	// Возможно нужен выбор?
	CStringArray aTitles;
	CStringArray aKeys;
	if(bDef){
		aTitles.SetAtGrow(0,_l2("Add new reminder"));
		aKeys.SetAtGrow(0,sRMKey);
	}else{
		aTitles.SetAtGrow(0,_l2("Add new schedule"));
		aKeys.SetAtGrow(0,sRMKey);
	}
	CString sSelectedKey="";
	if(bAskMenu){
		int iMaxIndex=0;
		if(fpPr && (*fpPr)(sRMKey,&iMaxIndex)){
			aKeys[0]="";
			for(int i=0;i<=iMaxIndex;i++){
				if(fp){
					CWPReminder rem;
					strcpy(rem.szKey,GetNextPrefixedId(sRMKey,i));
					if((*fp)(rem.szKey,rem)){
						AddMapItems(aKeys,aTitles, rem.szKey, GetRemDsc(rem,TRUE));
					}
				}
			}
		}
		if(aKeys.GetSize()==1){
			sRMKey=aKeys[0];
		}else{
			CMenu menu;
			menu.CreatePopupMenu();
			CPoint pt;
			GetCursorPos(&pt);
			for(int i=0;i<aKeys.GetSize();i++){
				AddMenuString(&menu,WM_USER+i,aTitles[i]);
			}
			AddMenuString(&menu,WM_USER+aKeys.GetSize()+1,_l2("Close menu"));
			int iNum=::TrackPopupMenu(menu.GetSafeHmenu(), TPM_RETURNCMD|TPM_NONOTIFY|TPM_RIGHTBUTTON, pt.x, pt.y, 0, pParent, NULL);
			if(iNum==0 || iNum<WM_USER || iNum>=WM_USER+aKeys.GetSize()){
				return 0;
			}
			sSelectedKey=aKeys[iNum-WM_USER];
			if(sSelectedKey==""){
				sSelectedKey=calcNextPrefixedId(sRMKey);
			}
			sRMKey=sSelectedKey;
		}
	}
	BOOL bNewReminder=0;
	CWPReminder rem;
	memset(&rem,0,sizeof(CWPReminder));
	if(fp && sRMKey!=""){
		strcpy(rem.szKey,sRMKey);
		if(!(*fp)(rem.szKey,rem)){
			// Создаем новый!
			bNewReminder=1;
			//COleDateTime dt=COleDateTime::GetCurrentTime();
			dt=dt+COleDateTimeSpan(0,0,1,0);
			dt.GetAsSystemTime(rem.EventTime);
			rem.bActPopup=bDef;
			rem.bActSound=bActSound;
			rem.bLoopSound=bLoopSound;
			strcpy(rem.szText,sEventName);
			strcpy(rem.szSoundPath,szWavFilePath);
			if(!bDef){
				// Здесь именно оригинальный Id-Event!!!
				strcpy(rem.szReserved,szEvent);
			}
			_PutReminder fp2=(_PutReminder)GetProcAddress(hRemin,"PutReminder");
			if(fp2){
				(*fp2)(rem.szKey,rem);
			}
		}
	}
#ifdef _DEBUG
	WKGetPluginContainer()->ShowAlert(rem.szKey,"opened reminder");
#endif
	_CallModifyReminder fp1=(_CallModifyReminder)GetProcAddress(hRemin,"CallModifyReminder");
	if(fp1){
		int iRes=(*fp1)(rem.szKey,pParent,0);
		if(iRes==IDCANCEL && bNewReminder){
			_RemoveReminder fp3=(_RemoveReminder)GetProcAddress(hRemin,"RemoveReminder");
			if(fp3){
				(*fp3)(rem.szKey);
			}
		}
	}
	return 1;
}
Пример #28
0
BOOL CExtResizableDialog::_TrackDialogSystemMenu(
	CPoint * pPoint,
	BOOL bSelectAny
	)
{
	if( (GetStyle() & WS_POPUP) == 0 )
		return FALSE;
	if(	CExtPopupMenuWnd::IsMenuTracking() )
		CExtPopupMenuWnd::CancelMenuTracking();
	m_bSysMenuTracking = FALSE;

CMenu * pSysMenu =
		GetSystemMenu( FALSE );
	if( pSysMenu == NULL )
		return FALSE;
	ASSERT( ::IsMenu(pSysMenu->GetSafeHmenu()) );
CExtPopupMenuWnd * pPopup = new CExtPopupMenuWnd;
	if( !pPopup->CreatePopupMenu( GetSafeHwnd() ) )
	{
		ASSERT( FALSE );
		return FALSE;
	}
	if( !pPopup->UpdateFromMenu(
			GetSafeHwnd(),
			pSysMenu,
			false
			)
		)
	{
		ASSERT( FALSE );
		return FALSE;
	}

CPoint point;
	if( pPoint != NULL)
		point = *pPoint;
	else
	{
		CRect rcWnd, rcClient, rcHelper;
		GetWindowRect( &rcWnd );
		GetClientRect( &rcClient );
		rcHelper = rcWnd;
		ScreenToClient( &rcHelper );
		ASSERT( rcHelper.top <= rcClient.top );
		int yDiff = rcClient.top - rcHelper.top;
		point = rcWnd.TopLeft();
		point.x += GetSystemMetrics(SM_CXFRAME);
		point.y += yDiff;
	}
	m_bSysMenuTracking =
		pPopup->TrackPopupMenu(
			TPMX_BOTTOMALIGN,
			point.x,point.y,
			GetSafeHwnd(),
			NULL,
			bSelectAny ? true : false
			) ? true : false;

	if( m_bSysMenuTracking )
		SetTimer( ID_TIMER_SYS_TRACKING, 20, NULL );
	return TRUE;
}
Пример #29
0
void CKofDlgImpl::UpdateCaption()
{
	if (!IsOwnerDrawCaption ())
	{
		return;
	}

	if (m_lstCaptionSysButtons.IsEmpty ())
	{
		//------------------------
		// Create caption buttons:
		//------------------------
		const DWORD dwStyle = m_Dlg.GetStyle ();
		HMENU hSysMenu = NULL;
		CMenu* pSysMenu = m_Dlg.GetSystemMenu (FALSE);

		if (pSysMenu != NULL && ::IsMenu (pSysMenu->m_hMenu))
		{
			hSysMenu = pSysMenu->GetSafeHmenu ();
			if (!::IsMenu (hSysMenu) || (m_Dlg.GetStyle () & WS_SYSMENU) == 0)
			{
				hSysMenu = NULL;
			}
		}

		if (hSysMenu != NULL)
		{
			m_lstCaptionSysButtons.AddTail (new CMFCCaptionButtonEx (AFX_HTCLOSE));

			if ((dwStyle & WS_MAXIMIZEBOX) == WS_MAXIMIZEBOX)
			{
				m_lstCaptionSysButtons.AddTail (new CMFCCaptionButtonEx (AFX_HTMAXBUTTON));
			}

			if ((dwStyle & WS_MINIMIZEBOX) == WS_MINIMIZEBOX)
			{
				m_lstCaptionSysButtons.AddTail (new CMFCCaptionButtonEx (AFX_HTMINBUTTON));
			}

			if ((dwStyle & DS_CONTEXTHELP) == DS_CONTEXTHELP)
			{
				if (!m_Dlg.IsKindOf (RUNTIME_CLASS (CPropertySheet)))
				{
					m_lstCaptionSysButtons.AddTail (new CMFCCaptionButtonEx (AFX_HTMINBUTTON + 1));
				}
			}
		}
	}

	CRect rectCaption = GetCaptionRect ();

	{
		CSize sizeButton = CMFCVisualManager::GetInstance()->GetNcBtnSize (FALSE);
		sizeButton.cy = min (sizeButton.cy, rectCaption.Height () - 2);

		int x = rectCaption.right - sizeButton.cx;
		int y = rectCaption.top + max (0, (rectCaption.Height () - sizeButton.cy) / 2);

		for (POSITION pos = m_lstCaptionSysButtons.GetHeadPosition (); pos != NULL;)
		{
			CMFCCaptionButtonEx* pButton = (CMFCCaptionButtonEx*)
				m_lstCaptionSysButtons.GetNext (pos);
			ASSERT_VALID (pButton);

			pButton->SetRect (CRect (CPoint (x, y), sizeButton));

			x -= sizeButton.cx;
		}
	}

	m_Dlg.RedrawWindow (NULL, NULL,
		RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN);
}
Пример #30
0
void CCoolMenuBarCtrl::ShowMenu()
{
	if ( m_pHot == NULL || ! IsMenu( m_hMenu ) ) return;

	CMenu* pMenu = CMenu::FromHandle( m_hMenu )->GetSubMenu( m_pHot->m_nID - 1 );

	if ( pMenu == NULL )
	{
		m_pHot = m_pDown = NULL;
		Invalidate();
		return;
	}

	UINT nFirstID = pMenu->GetMenuItemID( 0 );

	if ( nFirstID == ID_WINDOW_CASCADE )
	{
		UpdateWindowMenu( pMenu );
	}
	
	m_pDown = m_pHot;
	Invalidate();
	
	KillTimer( 1 );
	
	TPMPARAMS tpm;
	CRect rc;
	
	GetItemRect( m_pDown, &rc );
	ClientToScreen( &rc );
	rc.DeflateRect( 1, 2 );
	
	tpm.cbSize = sizeof(tpm);
	tpm.rcExclude = rc;
	
	m_pMenuBar = this;
	m_hMsgHook = SetWindowsHookEx( WH_MSGFILTER, MenuFilter, NULL, GetCurrentThreadId() );
	
	CoolMenu.RegisterEdge( rc.left, rc.bottom, rc.Width() );
	
	UINT nCmd = TrackPopupMenuEx( pMenu->GetSafeHmenu(),
		TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_VERTICAL|TPM_RETURNCMD,
		rc.left, rc.bottom, GetSafeHwnd(), &tpm );
	
	UnhookWindowsHookEx( m_hMsgHook );
	
	m_hMsgHook = NULL;
	m_pMenuBar = NULL;
	
	m_pDown = NULL;
	OnTimer( 1 );
	
	if ( m_pHot != NULL )
	{
		SetTimer( 1, 100, NULL );
		m_bTimer = TRUE;
	}
	
	Invalidate();
	UpdateWindow();
	
	if ( nCmd ) GetOwner()->PostMessage( WM_COMMAND, nCmd );
}