示例#1
0
void CRuler::OnRButtonDown(UINT nFlags, CPoint point)
{
    //These things all feed back to the view port, so don't
    //even bother unless a view port exists
    if (m_View!=NULL)
    {
        CMenu Menu;
        ClientToScreen(&point);
        if (theApp.GetSettings()->IsMetric())
        {
            VERIFY(Menu.LoadMenu(IDR_RULERMENU));
        }
        else
        {
            VERIFY(Menu.LoadMenu(IDR_RULERMENUINCHES));
        }
        CMenu* pPopup = Menu.GetSubMenu(0);
        if (pPopup!=NULL)
        {
            pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x,point.y,this);
        }
        Menu.DestroyMenu();
    }
}
示例#2
0
LONG COXSizeControlBar::OnAddContextMenuItems(WPARAM /* wParam */, LPARAM lParam)
{
	HMENU hMenu = (HMENU)lParam;		// handle of menu.
	CMenu Menu;
	Menu.Attach(hMenu);
	
	DWORD dwDockStyle = m_dwDockStyle & CBRS_ALIGN_ANY;
	DWORD style;
	CString strMenu;
	
	BOOL bMDIFloating = FALSE;
	CFrameWnd* pParentFrame = GetParentFrame();
	if (IsFloating())
	{
		if (pParentFrame != NULL && 
			pParentFrame->IsKindOf(RUNTIME_CLASS(COXMDIFloatWnd)))
		{
			bMDIFloating = TRUE;
		}
	}
	style = (bMDIFloating ? MF_STRING | MF_CHECKED : MF_STRING);
	
	// if allowed - add the float as MDI floating window
	if ((m_Style&SZBARF_ALLOW_MDI_FLOAT)!=0 && m_pDockContext!=NULL)
	{	
		VERIFY(strMenu.LoadString(ID_OX_MRC_MDIFLOAT));
		Menu.AppendMenu(style, ID_OX_MRC_MDIFLOAT, strMenu);
	}
	
	if (!bMDIFloating && (dwDockStyle != 0 || m_dwAllowDockingState != 0))	// ie docking is actually allowed ...
	{
		DWORD style = (dwDockStyle != 0 ? MF_STRING | MF_CHECKED : MF_STRING);
		VERIFY(strMenu.LoadString(ID_OX_MRC_ALLOWDOCKING));
		Menu.AppendMenu(style, ID_OX_MRC_ALLOWDOCKING, strMenu);
	}
	VERIFY(strMenu.LoadString(ID_OX_MRC_HIDE));
	Menu.AppendMenu(MF_STRING, ID_OX_MRC_HIDE, strMenu);
	
	Menu.Detach();	// detatch MFC object
	return TRUE;
}
示例#3
0
void CSampleWindow::OnRButtonUp(UINT nFlags, CPoint point)
{
    CMenu PopupMenuBar;
    PopupMenuBar.LoadMenu(IDR_SAMPLE_WND_POPUP);

    CMenu *pPopupMenu = PopupMenuBar.GetSubMenu(0);

    CPoint menuPoint;
    CRect rect;

    GetWindowRect(rect);

    menuPoint.x = rect.left + point.x;
    menuPoint.y = rect.top + point.y;

    UINT menuIds[] = {ID_POPUP_SAMPLEGRAPH1, ID_POPUP_SAMPLEGRAPH2, ID_POPUP_SPECTRUMANALYZER, ID_POPUP_NOTHING};

    pPopupMenu->CheckMenuItem(menuIds[m_iCurrentState], MF_BYCOMMAND | MF_CHECKED);

    UINT Result = pPopupMenu->TrackPopupMenu(TPM_RETURNCMD, menuPoint.x, menuPoint.y, this);

    switch (Result) {
    case ID_POPUP_SAMPLEGRAPH1:
        m_iCurrentState = 0;
        break;
    case ID_POPUP_SAMPLEGRAPH2:
        m_iCurrentState = 1;
        break;
    case ID_POPUP_SPECTRUMANALYZER:
        m_iCurrentState = 2;
        break;
    case ID_POPUP_NOTHING:
        m_iCurrentState = 3;
        break;
    }

    Invalidate();
    theApp.GetSettings()->SampleWinState = m_iCurrentState;

    CWnd::OnRButtonUp(nFlags, point);
}
示例#4
0
LRESULT CBrowseRefsDlg::OnClickedInfoIcon(WPARAM /*wParam*/, LPARAM lParam)
{
	// FIXME: x64 version would get this function called with unexpected parameters.
	if (!lParam)
		return 0;

	RECT * rect = (LPRECT)lParam;
	CPoint point;
	CString temp;
	point = CPoint(rect->left, rect->bottom);
#define LOGMENUFLAGS(x) (MF_STRING | MF_ENABLED | (m_SelectedFilters & x ? MF_CHECKED : MF_UNCHECKED))
	CMenu popup;
	if (popup.CreatePopupMenu())
	{
		temp.LoadString(IDS_LOG_FILTER_REFNAME);
		popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_REFNAME), LOGFILTER_REFNAME, temp);

		temp.LoadString(IDS_LOG_FILTER_SUBJECT);
		popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_SUBJECT), LOGFILTER_SUBJECT, temp);

		temp.LoadString(IDS_LOG_FILTER_AUTHORS);
		popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_AUTHORS), LOGFILTER_AUTHORS, temp);

		temp.LoadString(IDS_LOG_FILTER_REVS);
		popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_REVS), LOGFILTER_REVS, temp);

		int selection = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
		if (selection != 0)
		{
			m_SelectedFilters ^= selection;
			SetFilterCueText();
			SetTimer(IDT_FILTER, 1000, NULL);
		}
	}
	return 0L;
}
示例#5
0
// Search the "Select" menu to see if a CRC setting name is in use.
// Returns the ID (index into settings_) if found or -1 if not
int CGeneralCRC::find_name(LPCTSTR name)
{
	int retval = -1;

	CMenu menu;
	menu.Attach(select_menu_.m_hMenu);
	int lst = menu.GetMenuItemCount();
	for (int ii = 0; ii < lst; ++ii)
	{
		CString ss;
		menu.GetMenuString(ii, ss, MF_BYPOSITION);
		if (ss.CompareNoCase(name) == 0)
		{
			retval = menu.GetMenuItemID(ii);
			break;
		}
	}

	menu.Detach();
	return retval;
}
示例#6
0
void CSignInDlg::OnNMRClickListUser(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
	// TODO: 在此添加控件通知处理程序代码
	DWORD dwPos = GetMessagePos();
	CPoint point(LOWORD(dwPos),HIWORD(dwPos));

	CMenu menu;

	menu.LoadMenu(IDR_MENU_USER);

	CMenu *popue = menu.GetSubMenu(0);

	if (pNMItemActivate->iItem == -1)
	{
		popue->DeleteMenu(ID_USER_DELETE,MF_BYCOMMAND);
	}

	popue->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,point.x,point.y,this);
	*pResult = 0;
}
示例#7
0
static void CopyMenu(HMENU srcMenuSpec, HMENU destMenuSpec)
{
  CMenu srcMenu;
  srcMenu.Attach(srcMenuSpec);
  CMenu destMenu;
  destMenu.Attach(destMenuSpec);
  int startPos = 0;
  for (int i = 0;; i++)
  {
    CMenuItem item;
    item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
    item.fType = MFT_STRING;
    if (srcMenu.GetItem(i, true, item))
    {
      if (destMenu.InsertItem(startPos, true, item))
        startPos++;
    }
    else
      break;
  }
}
示例#8
0
static void CopyMenu(HMENU srcMenuSpec, HMENU destMenuSpec)
{
  CMenu srcMenu;
  srcMenu.Attach(srcMenuSpec);
  CMenu destMenu;
  destMenu.Attach(destMenuSpec);
  int startPos = 0;
  for (int i = 0;; i++)
  {
    CMenuItem item;
    item.fMask = MIIM_SUBMENU | MIIM_STATE | MIIM_ID | Get_fMask_for_FType_and_String();
    item.fType = MFT_STRING;

    if (!srcMenu.GetItem(i, true, item))
      break;

    CopyPopMenu_IfRequired(item);
    if (destMenu.InsertItem(startPos, true, item))
      startPos++;
  }
}
//------------------------------------------------------------------------
//! 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;
		}
	}
}
示例#10
0
LRESULT CErrorReportDlg::OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
  if(g_CrashInfo.m_bQueueEnabled)
  {
    CPoint pt;
    GetCursorPos(&pt);
    CMenu menu = LoadMenu(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_POPUPMENU));
    CMenu submenu = menu.GetSubMenu(4);

    strconv_t strconv;
    CString sSendLater = Utility::GetINIString(g_CrashInfo.m_sLangFileName, _T("MainDlg"), _T("SendReportLater"));
    CString sCloseTheProgram = Utility::GetINIString(g_CrashInfo.m_sLangFileName, _T("MainDlg"), _T("CloseTheProgram"));
    
    MENUITEMINFO mii;
    memset(&mii, 0, sizeof(MENUITEMINFO));
    mii.cbSize = sizeof(MENUITEMINFO);
    mii.fMask = MIIM_STRING;

    mii.dwTypeData = sSendLater.GetBuffer(0);  
    submenu.SetMenuItemInfo(ID_MENU5_SENDREPORTLATER, FALSE, &mii);

    mii.dwTypeData = sCloseTheProgram.GetBuffer(0);  
    submenu.SetMenuItemInfo(ID_MENU5_CLOSETHEPROGRAM, FALSE, &mii);
  
    submenu.TrackPopupMenu(0, pt.x, pt.y, m_hWnd);
  }
  else
  {
    // If needed, restart the application
    g_ErrorReportSender.DoWork(RESTART_APP);

    // Remove report files
    Utility::RecycleFile(g_CrashInfo.GetReport(0).m_sErrorReportDirName, true);

    // Close dialog
    CloseDialog(wID);  
  }

	return 0;
}
示例#11
0
LRESULT CErrorReportDlg::OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{   
	// This method is called when user clicks "Close the program" or "Other actions..." button 
	// (the button is the same, its caption may differ)

	CErrorReportSender* pSender = CErrorReportSender::GetInstance();

    if(pSender->GetCrashInfo()->m_bQueueEnabled)
    {    
		// Show popup menu on "Other actions..." button click.
        CPoint pt;
        GetCursorPos(&pt);
        CMenu menu = LoadMenu(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_POPUPMENU));
        CMenu submenu = menu.GetSubMenu(4);

        strconv_t strconv;
        CString sSendLater = pSender->GetLangStr(_T("MainDlg"), _T("SendReportLater"));
		CString sCloseTheProgram = pSender->GetLangStr(_T("MainDlg"), _T("CloseTheProgram"));

        MENUITEMINFO mii;
        memset(&mii, 0, sizeof(MENUITEMINFO));
        mii.cbSize = sizeof(MENUITEMINFO);
        mii.fMask = MIIM_STRING;

        mii.dwTypeData = sSendLater.GetBuffer(0);  
        submenu.SetMenuItemInfo(ID_MENU5_SENDREPORTLATER, FALSE, &mii);

        mii.dwTypeData = sCloseTheProgram.GetBuffer(0);  
        submenu.SetMenuItemInfo(ID_MENU5_CLOSETHEPROGRAM, FALSE, &mii);

        submenu.TrackPopupMenu(0, pt.x, pt.y, m_hWnd);    
    }  
    else // "Close the program" button clicked
    {
        // Close dialog.
        CloseDialog(wID);  
    }

    return 0;
}
示例#12
0
LRESULT CTrayIcon::OnNotify(WPARAM WParam, LPARAM LParam)
{
	if (WParam != m_ntfData.uID)
	{
		return 0;
	}

	if (LParam == WM_RBUTTONUP)
	{
		CMenu menu;
		if (!menu.LoadMenu(IDR_MENU_TRAY))
		{
			return 0;
		}

		CMenu* pSubMenu = menu.GetSubMenu(0);

		if (!pSubMenu)
		{
			return 0;
		}

		::SetMenuDefaultItem(pSubMenu->m_hMenu, 0, TRUE);
		CPoint pos;
		GetCursorPos(&pos);

		SetForegroundWindow(m_pNtfWnd->m_hWnd);

		if(m_bStart)
		{
			pSubMenu->EnableMenuItem(ID_START_SRV, MF_BYCOMMAND | MF_GRAYED);
		}

		pSubMenu->TrackPopupMenu(TPM_RIGHTALIGN|TPM_LEFTBUTTON
			|TPM_RIGHTBUTTON, pos.x, pos.y, m_pNtfWnd, NULL);
	}

	return 1;
}
示例#13
0
void COptionsCodecs::OnContextMenu(CWnd * pWnd, CPoint point)
{
  if (&m_CodecInfo != pWnd)
    return;

  CPoint local = point;
  m_CodecInfo.ScreenToClient(&local);

  UINT nFlags;
  HTREEITEM hTargetItem = m_CodecInfo.HitTest(local, &nFlags);
  if (hTargetItem == NULL)
    return;

  if ((m_CodecInfo.GetItemData(hTargetItem)&DragSourceItem) == 0)
    return;

  m_CodecInfo.Select(hTargetItem, TVGN_CARET);

  CMenu menu;
  menu.CreatePopupMenu();
  menu.AppendMenu(MF_STRING, 1, L"Move");
  if (m_CodecInfo.GetParentItem(hTargetItem) == m_hDisabledCodecs)
    menu.AppendMenu(MF_STRING, 2, L"Enable");
  else
    menu.AppendMenu(MF_STRING, 3, L"Disable");

  switch (menu.TrackPopupMenu(TPM_LEFTALIGN|TPM_RETURNCMD, point.x, point.y, this)) {
    case 1 :
      StartDrag(hTargetItem, point);
      break;
    case 2 :
      Move(hTargetItem, m_hEnabledCodecs);
      break;
    case 3 :
      Move(hTargetItem, m_hDisabledCodecs);
      break;
  }
}
示例#14
0
void CMainFrame::OnMenuUpdate(UINT nID)
// Called when menu items are about to be displayed
{
    // Only for the Menu IDs we wish to modify
    if (nID >= IDM_EDIT_UNDO && nID <= IDM_EDIT_DELETE) {
        CWnd* pWnd = 0;
        CMenu Menu;
        Menu.Attach(GetFrameMenu());
        CMenu* pEditMenu = Menu.GetSubMenu(1);

        if (m_pLastActiveDocker) {
            if (m_pLastActiveDocker == &m_DockTabbedMDI)
                pWnd = m_DockTabbedMDI.GetTabbedMDI()->GetActiveMDIChild();
            else if (m_pLastActiveDocker->IsDocked())
                pWnd = m_pLastActiveDocker->GetContainer()->GetActiveView();
        }

        // Enable the Edit menu items for CViewText windows, disable them otherwise
        UINT Flags = (dynamic_cast<CViewText*>(pWnd)) ? MF_ENABLED : MF_GRAYED;
        pEditMenu->EnableMenuItem(nID, MF_BYCOMMAND | Flags);
        Menu.Detach();
    }
}
示例#15
0
void CFileManagerDlg::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
  if (nHitTest == HTSYSMENU)
  {
    Sleep(::GetDoubleClickTime());
    MSG msg;
    if (::PeekMessage(&msg, NULL, WM_NCLBUTTONDBLCLK, WM_NCLBUTTONDBLCLK, PM_NOREMOVE)) {
      SendMessage(WM_SYSCOMMAND, SC_CLOSE, MAKELPARAM(point.x, point.y));
      return; // LEFT CONTROL TO DBL CLICK ;-)
    }
    else {
      CMenu* pMenu = GetSystemMenu(FALSE);
      pMenu->EnableMenuItem(SC_RESTORE, m_bMaximized ? MF_ENABLED : MF_DISABLED);
      pMenu->EnableMenuItem(SC_MOVE, m_bMaximized ? MF_DISABLED : MF_ENABLED);
      pMenu->EnableMenuItem(SC_SIZE, m_bMaximized ? MF_DISABLED : MF_ENABLED);
      pMenu->EnableMenuItem(SC_MAXIMIZE, m_bMaximized ? MF_DISABLED : MF_ENABLED);
      pMenu->EnableMenuItem(SC_MINIMIZE, MF_ENABLED);
      if (int cmd = pMenu->TrackPopupMenu(TPM_RETURNCMD, point.x, point.y, this))
        SendMessage(WM_SYSCOMMAND, cmd, MAKELPARAM(point.x, point.y));
    }
  }
  CDialogEx::OnNcLButtonDown(nHitTest, point);
}
示例#16
0
/*************
 * DESCRIPTION:	ON_WM_RBUTTONDOWN
 *						handles right mouse button click
 *						display pop up menu
 * INPUT:			nFlags   Specifies if various flags are set
 *						point    coordinates of mouse cursor
 * OUTPUT:			-
 *************/
void CMatView::OnRButtonDown(UINT, CPoint point)
{
    CMenu Menu;
    int index;
    BOOL b;

    index = GetMaterialIndex(point);
    if (index != -1)
    {
        nSelectedMaterial = index;
        b = Menu.LoadMenu(IDR_MATERIAL);
    }
    else
        b = Menu.LoadMenu(IDR_MATERIAL_OUTSIDE);

    ClientToScreen(&point);
    if (b)
    {
        CMenu *pSubMenu = Menu.GetSubMenu(0);
        if (pSubMenu != NULL)
            pSubMenu->TrackPopupMenu(TPM_CENTERALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
    }
}
示例#17
0
void CChatCDlg::InitLogout()
{
	//// 로그아웃 상태일 때의 화면
	// 메뉴 변경
	CMenu *pMenu = GetMenu();
	pMenu->EnableMenuItem(ID_LOGOUT,TRUE);
	pMenu->EnableMenuItem(ID_CHANGENAME,TRUE);
	pMenu->EnableMenuItem(ID_ADDMYLIST,TRUE);
	pMenu->EnableMenuItem(ID_CONNECT,FALSE);
	pMenu->EnableMenuItem(ID_JOIN,FALSE);
	
	// 목록 지우기
	m_ctrlList1.DeleteAllItems();

	// 버튼,목록 변경
	m_ctrlConnect.ShowWindow(TRUE);
	m_ctrlJoin.ShowWindow(TRUE);
	m_ctrlChangename.ShowWindow(FALSE);
	m_ctrlAddmylist.ShowWindow(FALSE);
	m_ctrlDelmylist.ShowWindow(FALSE);
	m_ctrlList1.ShowWindow(FALSE);
	m_ctrlEdit1.ShowWindow(FALSE);
}
示例#18
0
void CRTListCtrl::OnContextMenu(CWnd *, CPoint point)
{
	CMenu menu;
	CMainFrame *m_pMainWnd;
	m_pMainWnd = (CMainFrame *) AfxGetMainWnd ();

		if (point.x == -1 && point.y == -1){
			CRect rect;
			GetClientRect(rect);
			ClientToScreen(rect);

			point = rect.TopLeft();
			point.Offset(5,5);
		}
		else
		{
			ClientToScreen(&point);//.Offset(50, 146);
		}
	
		menu.DestroyMenu();
		VERIFY(menu.LoadMenu(IDR_POPUP_RT_SET));


//		InitMenu(0 ,type, del_flag);

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

		while (pWndPopupOwner->GetStyle() & WS_CHILD)
			pWndPopupOwner = pWndPopupOwner->GetParent();

		//pPopup->EnableMenuItem(AFX_ID_BLOWUP,MF_GRAYED);

	pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x,point.y,pWndPopupOwner);

}
示例#19
0
LRESULT CResendDlg::OnTrayIcon(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
{
    if(LOWORD(lParam)==WM_LBUTTONDOWN || 
        LOWORD(lParam)==WM_LBUTTONDBLCLK ||
        LOWORD(lParam)==NIN_BALLOONUSERCLICK)
    {
        KillTimer(0);
        ShowWindow(SW_SHOW);
    }

    if(LOWORD(lParam)==WM_RBUTTONDOWN)
    {
        CPoint pt;
        GetCursorPos(&pt);
        CMenu menu = LoadMenu(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_POPUPMENU));
        CMenu submenu = menu.GetSubMenu(2);

        strconv_t strconv;
        CString sShow = Utility::GetINIString(g_CrashInfo.m_sLangFileName, _T("ResendDlg"), _T("PopupShow"));
        CString sExit = Utility::GetINIString(g_CrashInfo.m_sLangFileName, _T("ResendDlg"), _T("PopupExit"));

        MENUITEMINFO mii;
        memset(&mii, 0, sizeof(MENUITEMINFO));
        mii.cbSize = sizeof(MENUITEMINFO);
        mii.fMask = MIIM_STRING;

        mii.dwTypeData = sShow.GetBuffer(0);  
        submenu.SetMenuItemInfo(ID_MENU3_SHOW, FALSE, &mii);

        mii.dwTypeData = sExit.GetBuffer(0);  
        submenu.SetMenuItemInfo(ID_MENU3_EXIT, FALSE, &mii);

        submenu.TrackPopupMenu(0, pt.x, pt.y, m_hWnd);
    }

    return 0;
}
示例#20
0
void CEditEx::OnContextMenu(CWnd* pWnd, CPoint point)
{
	if (point.x == -1 && point.y == -1)
	{
		//keystroke invocation
		CRect rect;
		GetClientRect(rect);
		ClientToScreen(rect);

		point = rect.TopLeft();
		point.Offset(5, 5);
	}

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

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

	//pPopup->EnableMenuItem(ID_EDIT_UNDO, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
	//pPopup->EnableMenuItem(ID_EDIT_CLEAR, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
	//pPopup->EnableMenuItem(ID_EDIT_CUT, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
	//pPopup->EnableMenuItem(ID_EDIT_COPY, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
	
	COleDataObject	obj;	
	if (obj.AttachClipboard()) 
	{
		if(!obj.IsDataAvailable(CF_TEXT) && !obj.IsDataAvailable(RegisterClipboardFormat(L"BinaryData")))
				pPopup->EnableMenuItem(ID_EDIT_PASTE, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
	}
	

	pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,
		this);
    return;
}
示例#21
0
BOOL CCoolMenuBarCtrl::OpenMenuChar(UINT nChar)
{
	CMenu pMenu;
	pMenu.Attach( m_hMenu );

	for ( UINT nItem = 0 ; nItem < pMenu.GetMenuItemCount() ; nItem++ )
	{
		CString strMenu;
		pMenu.GetMenuString( nItem, strMenu, MF_BYPOSITION );

		LPCTSTR pszChar = _tcschr( strMenu, '&' );
		if ( ! pszChar++ ) continue;

		if ( toupper( *pszChar ) == toupper( nChar ) )
		{
			pMenu.Detach();
			if ( m_pSelect = GetIndex( nItem ) ) PostMessage( WM_TIMER, 5 );
			return TRUE;
		}
	}

	pMenu.Detach();
	return FALSE;
}
示例#22
0
void COptionsShortcuts::OnHeaderRClick(NMHDR *, LRESULT *pLResult)
{
  if (m_iColWidth == m_iDefColWidth)
    return;

  const DWORD dwTrackPopupFlags = TPM_LEFTALIGN | TPM_RIGHTBUTTON;

  CMenu menu;
  CPoint ptMousePos;
  GetCursorPos(&ptMousePos);

  if (menu.LoadMenu(IDR_POPRESETCOLUMNWIDTH)) {
    MENUINFO minfo;
    SecureZeroMemory(&minfo, sizeof(minfo));
    minfo.cbSize = sizeof(minfo);
    minfo.fMask = MIM_MENUDATA;
    minfo.dwMenuData = IDR_POPRESETCOLUMNWIDTH;
    menu.SetMenuInfo(&minfo);
    CMenu* pPopup = menu.GetSubMenu(0);

    pPopup->TrackPopupMenu(dwTrackPopupFlags, ptMousePos.x, ptMousePos.y, this);
  }
  *pLResult = TRUE;
}
示例#23
0
void CSitesWnd::OnRClick()
{
	CMenu menu;
	menu.LoadMenu (IDM_SITES);
	ApplyLanguageToMenu (&menu);
	CMenu *pPopup = menu.GetSubMenu (0);

	UpdateMenu (pPopup);

	ClientToScreen (&m_rbPt);

	m_odmenu.Attach (&menu, FALSE);

	m_odmenu.SetImageList (&((CMainFrame*)AfxGetApp ()->m_pMainWnd)->m_imgsMenu, &((CMainFrame*)AfxGetApp ()->m_pMainWnd)->m_dimgsMenu);
	fsSetImage *pImages;
	int cImages;
	CSitesWnd::Plugin_GetMenuImages (&pImages, &cImages);
	m_odmenu.SetImages (pImages, cImages);

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

	menu.DestroyMenu ();
}
//
// PopUpMenu
// point - location of the right click
//
// called when a user double clicks in the list control
void CPropMapCtrl::PopUpMenu(CPoint point)
{
	CMenu menu;
	CMenu *pPopup;
	
	if (!menu.LoadMenu(IDR_PROP_MAP_MENU))
		return;
	
	pPopup = menu.GetSubMenu(0);
	if (!pPopup)
		return;

	RECT winRect;
	GetWindowRect( &winRect );
	int newx = point.x + winRect.left;
	int newy = point.y + winRect.top;

	BOOL bResult = pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, newx, newy, this);

	// not doing anything with bResult, do we care?

	menu.DestroyMenu();

}
示例#25
0
void CTreeViewEx::OnNMRclick(NMHDR* /*pNMHDR*/, LRESULT *pResult)
{
    CPoint point;
	GetCursorPos(&point);
	CPoint omCurrentPoint(point);
	ScreenToClient(&omCurrentPoint);
	UINT flags;
	HTREEITEM hItem = GetTreeCtrl().HitTest(omCurrentPoint, &flags);
    CTreeCtrl &omTempTreeCtrl = GetTreeCtrl();
    if(hItem && (flags & TVHT_ONITEM) && !(flags & TVHT_ONITEMRIGHT))
    {
        omTempTreeCtrl.SelectItem(hItem);   
        CMenu omContextMenu;
        VERIFY(omContextMenu.CreatePopupMenu());
        if(omTempTreeCtrl.GetItemData(hItem) == def_ID_TESTSUITE)
        {
            VERIFY(omContextMenu.AppendMenu(MF_STRING, IDM_TESTSUITE_ADD, _T("Add...")));
            if(GetExecutorWindow()->bGetBusStatus() == TRUE)
            {
                VERIFY(omContextMenu.AppendMenu(MF_STRING, IDM_TESTSUITE_EXECUTE, _T("Execute")));
            }
            else
            {
                VERIFY(omContextMenu.AppendMenu(MF_STRING|MF_GRAYED, IDM_TESTSUITE_EXECUTE, _T("Execute")));
            }
        }
        else
        {
            HTREEITEM hParentItem = omTempTreeCtrl.GetParentItem(hItem);
            if(omTempTreeCtrl.GetItemData(hParentItem) == def_ID_TESTSUITE)
            {
                VERIFY(omContextMenu.AppendMenu(MF_STRING, IDM_TESTSETUP_DELETE, _T("Delete")));
                VERIFY(omContextMenu.AppendMenu(MF_STRING, IDM_TESTSETUP_MODIFY, _T("Modify...")));
            }
        }
        omContextMenu.TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, this);
        *pResult = 0;
    }
    
    else        //On Tree View Create Collapse All and Expand All
    {
        CMenu omContextMenu;
	    VERIFY(omContextMenu.CreatePopupMenu());
        VERIFY(omContextMenu.AppendMenu(MF_STRING, IDM_COLLAPSE_ALL, _T("Collapse All")));
		VERIFY(omContextMenu.AppendMenu(MF_STRING, IDM_EXPAND_ALL, _T("Expand All")));
	    omContextMenu.TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, this);
        *pResult = 0;
    }
}
示例#26
0
void CSubtitleUpDlg::OnRightClick(NMHDR* pNMHDR, LRESULT* pResult)
{
    LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;

    if (lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0) {
        auto& s = AfxGetAppSettings();
        SubtitlesProvider& provider = *(SubtitlesProvider*)(m_list.GetItemData(lpnmlv->iItem));

        enum {
            SET_CREDENTIALS = 0x1000,
            RESET_CREDENTIALS,
            MOVE_UP,
            MOVE_DOWN,
            OPEN_URL
        };

        CMenu m;
        m.CreatePopupMenu();
        m.AppendMenu(MF_STRING | (provider.Flags(SPF_LOGIN) ? MF_ENABLED : MF_DISABLED), SET_CREDENTIALS,
                     ResStr(IDS_SUBMENU_SETUP));
        m.AppendMenu(MF_STRING | (provider.Flags(SPF_LOGIN) && !provider.UserName().empty() ? MF_ENABLED : MF_DISABLED),
                     RESET_CREDENTIALS, ResStr(IDS_SUBMENU_RESET));
        m.AppendMenu(MF_SEPARATOR);
        m.AppendMenu(MF_STRING | (lpnmlv->iItem > 0 ? MF_ENABLED : MF_DISABLED), MOVE_UP, ResStr(IDS_SUBMENU_MOVEUP));
        m.AppendMenu(MF_STRING | (lpnmlv->iItem < m_list.GetItemCount() - 1  ? MF_ENABLED : MF_DISABLED), MOVE_DOWN,
                     ResStr(IDS_SUBMENU_MOVEDOWN));
        m.AppendMenu(MF_SEPARATOR);
        m.AppendMenu(MF_STRING | MF_ENABLED, OPEN_URL, ResStr(IDS_SUBMENU_OPENURL));

        CPoint pt = lpnmlv->ptAction;
        ::MapWindowPoints(lpnmlv->hdr.hwndFrom, HWND_DESKTOP, &pt, 1);

        switch (m.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RETURNCMD, pt.x, pt.y, this)) {
            case OPEN_URL:
                provider.OpenUrl();
                break;
            case SET_CREDENTIALS: {
                CString szUser(UTF8To16(provider.UserName().c_str()));
                CString szPass(UTF8To16(provider.Password().c_str()));
                CString szDomain(provider.Name().c_str());
                if (ERROR_SUCCESS == PromptForCredentials(GetSafeHwnd(),
                                                          ResStr(IDS_SUB_CREDENTIALS_TITLE),
                                                          ResStr(IDS_SUB_CREDENTIALS_MSG) + CString(provider.Url().c_str()),
                                                          szDomain, szUser, szPass, /*&bSave*/nullptr)) {
                    provider.UserName((const char*)UTF16To8(szUser));
                    provider.Password((const char*)UTF16To8(szPass));
                    m_list.SetItemText(lpnmlv->iItem, 1, szUser);
                    s.strSubtitlesProviders = CString(m_pMainFrame->m_pSubtitlesProviders->WriteSettings().c_str());
                    s.SaveSettings();
                }
                break;
            }
            case RESET_CREDENTIALS:
                provider.UserName("");
                provider.Password("");
                m_list.SetItemText(lpnmlv->iItem, 1, _T(""));
                s.strSubtitlesProviders = CString(m_pMainFrame->m_pSubtitlesProviders->WriteSettings().c_str());
                s.SaveSettings();
                break;
            case MOVE_UP: {
                m_pMainFrame->m_pSubtitlesProviders->MoveUp(lpnmlv->iItem);
                ListView_SortItemsEx(m_list.GetSafeHwnd(), SortCompare, m_list.GetSafeHwnd());
                s.strSubtitlesProviders = CString(m_pMainFrame->m_pSubtitlesProviders->WriteSettings().c_str());
                s.SaveSettings();
                break;
            }
            case MOVE_DOWN: {
                m_pMainFrame->m_pSubtitlesProviders->MoveDown(lpnmlv->iItem);
                ListView_SortItemsEx(m_list.GetSafeHwnd(), SortCompare, m_list.GetSafeHwnd());
                s.strSubtitlesProviders = CString(m_pMainFrame->m_pSubtitlesProviders->WriteSettings().c_str());
                s.SaveSettings();
                break;
            }
            default:
                break;
        }
    }
}
示例#27
0
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	// Load Lucida Grande font
	VERIFY(m_Font.CreatePointFont(80, _T("Lucida Sans Unicode")));

	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}
	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}
	m_wndStatusBar.SetPaneInfo(0,ID_INDICATOR_EVENTS,SBPS_NORMAL,60);
	m_wndStatusBar.SetPaneInfo(1,ID_SEPARATOR,SBPS_NORMAL,350);
	m_wndStatusBar.SetPaneInfo(2,ID_INDICATOR_CURSORINFO,SBPS_NORMAL,210);
	m_wndStatusBar.SetPaneInfo(3,ID_INDICATOR_IMAGEINFO,SBPS_STRETCH,0);

	m_wndStatusBar.SetFont(&m_Font);

	if( m_fastTimer == NULL )
    {
        m_fastTimer = ::SetTimer( m_hWnd, FAST_TIMER, sk_defualtFastTimerDelay, (TIMERPROC) NULL );   
    }
	if( m_slowTimer == NULL )
    {
        m_slowTimer = ::SetTimer( m_hWnd, SLOW_TIMER, sk_defualtSlowTimerDelay, (TIMERPROC) NULL );   
    }
	 	
	CFlyCap2_MFCDoc* pDoc = (CFlyCap2_MFCDoc*)GetActiveDocument();

	if (m_aboutDlg.Create(AboutDialog::IDD,this) == FALSE)
	{
		TRACE0("Failed to create about dialog box\n");
		return -1;      // fail to create UI
	}

	CMenu* mainMenu = GetMenu();
	m_bitmapHelp.LoadBitmap(IDB_BITMAP_HELP); 
	m_bitmapAbout.LoadBitmap(IDB_BITMAP_ABOUT); 
	m_bitmapSaveAs.LoadBitmap(IDB_BITMAP_SAVEAS); 
	m_bitmapExit.LoadBitmap(IDB_BITMAP_EXIT); 
	m_bitmapControl.LoadBitmap(IDB_BITMAP_CONTROL); 
	m_bitmapEventStatusBad.LoadBitmap(IDB_BITMAP_EVENT_BAD);
	m_bitmapEventStatusOK.LoadBitmap(IDB_BITMAP_EVENT_OK);
	mainMenu->SetMenuItemBitmaps(ID_LAUNCH_HELP,MF_BYCOMMAND, &m_bitmapHelp, &m_bitmapHelp);
	mainMenu->SetMenuItemBitmaps(ID_APP_ABOUT,MF_BYCOMMAND, &m_bitmapAbout, &m_bitmapAbout);
	mainMenu->SetMenuItemBitmaps(ID_FILE_SAVE_AS,MF_BYCOMMAND, &m_bitmapSaveAs, &m_bitmapSaveAs);
	mainMenu->SetMenuItemBitmaps(ID_APP_EXIT,MF_BYCOMMAND, &m_bitmapExit, &m_bitmapExit);
	mainMenu->SetMenuItemBitmaps(ID_CAMERACONTROL_TOGGLECAMERACONTROL,MF_BYCOMMAND, &m_bitmapControl, &m_bitmapControl);

    //Set Toolbar icon to true color (24 bit)
	CImageList	toolbarImageList;
	CBitmap		toolbarBitmap;

	// Create and set the enabled image list.
	toolbarBitmap.LoadBitmap(IDB_TOOLBAR_ENABLE);
	toolbarImageList.Create(30, 30, ILC_COLORDDB|ILC_MASK, 1, 1);
	toolbarImageList.Add(&toolbarBitmap, RGB(246,246,246));
	m_wndToolBar.SendMessage(TB_SETIMAGELIST, 0, (LPARAM)toolbarImageList.m_hImageList);
	toolbarImageList.Detach();
	toolbarBitmap.Detach();

	// Create and set the disabled image list.
	toolbarBitmap.LoadBitmap(IDB_TOOLBAR_DISABLE);
	toolbarImageList.Create(30, 30, ILC_COLORDDB|ILC_MASK, 1, 1);
	toolbarImageList.Add(&toolbarBitmap, RGB(246,246,246));
	m_wndToolBar.SendMessage(TB_SETDISABLEDIMAGELIST, 0, (LPARAM)toolbarImageList.m_hImageList);
	toolbarImageList.Detach();
	toolbarBitmap.Detach();

    m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	m_wndToolBar.SetFont(&m_Font);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);
	return 0;
}
示例#28
0
int BrowserPanelWnd::AddFavUrlToMenu( int &nStartItemID, int nStartPos, const char* szPath, CMenu* pMenu )
{
	vector<string>	m_arrSubDir;
	CString strPath = szPath;
	int curCnt = 0;

	if(strPath[strPath.GetLength() - 1] != _T('\\'))
		strPath += _T('\\');
	CString strFind = strPath + "*.*";

	WIN32_FIND_DATA	findData;
	HANDLE	hFile = NULL;

	hFile = FindFirstFile(strFind, &findData);
	if (hFile != INVALID_HANDLE_VALUE)
	{
		do 
		{
			if ( strcmp(".", findData.cFileName )==0
				|| strcmp("..", findData.cFileName)==0)
			{
				continue;
			}

			// 略过隐藏文件和系统文件
			if ( (findData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
				|| (findData.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM))
			{
				continue;
			}

			// 目录
			if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
			{
				string strSubDir = strPath;
				strSubDir += findData.cFileName;
				m_arrSubDir.push_back(strSubDir);
			}

			// 文件
			CString strFileName = findData.cFileName;
			strFileName.MakeLower();
			if (strFileName.Right(4) == ".url")
			{
				char szUrl[MAX_PATH] = {0};
				::GetPrivateProfileString(_T("InternetShortcut"), _T("URL"),
					"", szUrl, 400,
					strPath+strFileName);

				strFileName = strFileName.Left(strFileName.GetLength() - 4);

				m_arrFavMenuItemParam.push_back(szUrl);
				pMenu->AppendMenu(MF_STRING|MF_ENABLED, nStartItemID++, strFileName.GetBuffer(0));
				strFileName.ReleaseBuffer();
				curCnt++;
			}

		} while (FindNextFile(hFile, &findData));
	}
	FindClose(hFile);

	vector<string>::iterator it = m_arrSubDir.begin();
	for (; it != m_arrSubDir.end(); it++)
	{
		CMenu *pSubMenu = new CMenu;
		pSubMenu->CreatePopupMenu();

		int n = AddFavUrlToMenu(nStartItemID, 0, it->c_str(), pSubMenu);
		if (n > 0)
		{
			string dir = *it;
			size_t pos = dir.rfind('\\');
			dir = dir.substr(pos+1, dir.length()-pos);
			pMenu->InsertMenu(nStartItemID++, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT)pSubMenu->m_hMenu, dir.c_str());
			pSubMenu->Detach();
			m_arrFavMenuItemParam.push_back(it->c_str());
			curCnt++;
		}
		delete pSubMenu;
	}

	return curCnt;
}
示例#29
0
void CDiagramEntity::ShowPopup( CPoint point, CWnd* parent )
/* ============================================================
	Function :		CDiagramEntity::ShowPopup
	Description :	Shows the popup menu for the object.

	Return :		void
	Parameters :	CPoint point	-	The point to track.
					CWnd* parent	-	The parent CWnd of the 
										menu (should be the 
										CDiagramEditor)

	Usage :			The function uses hardcoded strings to 
					avoid having to include resource file 
					fragments. Derived classes needing a non-
					standard or localized menu should load 
					menues from resources instead.

   ============================================================*/
{

	CMenu menu;
	if( menu.CreatePopupMenu() )
	{

		menu.AppendMenu( MF_STRING, CMD_CUT, _T( "Cu&t" ) );
		menu.AppendMenu( MF_STRING, CMD_COPY, _T( "&Copy" ) );
		menu.AppendMenu( MF_STRING, CMD_DUPLICATE, _T( "Du&plicate" ) );
		menu.AppendMenu( MF_SEPARATOR );
		menu.AppendMenu( MF_STRING, CMD_UP, _T( "&Up" ) );
		menu.AppendMenu( MF_STRING, CMD_DOWN, _T( "&Down" ) );
		menu.AppendMenu( MF_STRING, CMD_FRONT, _T( "To &front" ) );
		menu.AppendMenu( MF_STRING, CMD_BOTTOM, _T( "To &back" ) );
		menu.AppendMenu( MF_SEPARATOR );
		menu.AppendMenu( MF_STRING, CMD_FREEZE, _T( "Freeze Selection" ) );
		menu.AppendMenu( MF_STRING, CMD_UNFREEZE_ALL, _T( "Unfreeze All" ) );
		menu.AppendMenu( MF_SEPARATOR );
		menu.AppendMenu( MF_STRING, CMD_HIDE, _T( "Hide Selection" ) );	
		menu.AppendMenu( MF_STRING, CMD_UNHIDE_ALL, _T( "Unhide All" ) );
		menu.AppendMenu( MF_STRING, CMD_HIDE_UNSEL, _T( "Hide Unselected" ) );
		menu.AppendMenu( MF_SEPARATOR );
		menu.AppendMenu( MF_STRING, CMD_CONTROL_LIST, _T( "Control List " ) );
		
		menu.AppendMenu( MF_SEPARATOR );
		menu.AppendMenu( MF_STRING, CMD_PROPERTIES, _T( "P&roperties" ) );
		menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, parent );

	}

}
示例#30
0
static void AppendMenuChecked(CMenu &menu, UINT nTextID, UINT_PTR nItemID, BOOL checked = FALSE, BOOL enabled = TRUE)
{
	CString text;
	text.LoadString(nTextID);
	menu.AppendMenu(MF_STRING | (enabled ? MF_ENABLED : MF_DISABLED) | (checked ? MF_CHECKED : MF_UNCHECKED), nItemID, text);
}