コード例 #1
0
ファイル: MainFrm.cpp プロジェクト: LiberatorUSA/GUCEF
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	// create a view to occupy the client area of the frame
	if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
		CRect(0, 0, 480, 160), this, AFX_IDW_PANE_FIRST, NULL))
	{
		TRACE0("Failed to create view window\n");
		return -1;
	}
	
	//ModifyStyle(WS_SYSMENU, NULL);
	
    // Remove positions of menu
    CMenu* pTopMenu = GetSystemMenu(FALSE);
    if( pTopMenu != NULL)
    {   
       // pTopMenu->DestroyMenu();
        pTopMenu->RemoveMenu(SC_SIZE, MF_BYCOMMAND);      // no resize
       // pTopMenu->RemoveMenu(SC_MOVE, MF_BYCOMMAND);      //non-Moveable window
        pTopMenu->RemoveMenu(SC_MAXIMIZE, MF_BYCOMMAND);  //no Maximize
    }	
	return 0;
}
コード例 #2
0
ファイル: DOCMAPI.CPP プロジェクト: willpoon/wcwp
void CDocument::OnUpdateFileSendMail(CCmdUI* pCmdUI)
{
    ASSERT_VALID(this);

    if (_afxIsMailAvail == (BOOL)-1)
    {
        _afxIsMailAvail = ::GetProfileInt(_T("MAIL"), _T("MAPI"), 0) != 0 &&
                          SearchPath(NULL, _T("MAPI32.DLL"), NULL, 0, NULL, NULL) != 0;
    }

    // enable the Send... menu item if available
    pCmdUI->Enable(_afxIsMailAvail);
    CMenu* pMenu = pCmdUI->m_pMenu;
    if (!_afxIsMailAvail && pMenu != NULL)
    {
        // remove the Send... menu and surrounding separators
        UINT nStateAbove = pMenu->GetMenuState(pCmdUI->m_nIndex-1, MF_BYPOSITION);
        UINT nStateBelow = pMenu->GetMenuState(pCmdUI->m_nIndex+1, MF_BYPOSITION);
        pMenu->RemoveMenu(pCmdUI->m_nIndex, MF_BYPOSITION);
        if (nStateAbove & nStateBelow & MF_SEPARATOR)
        {
            // a separator must be removed since the Send... is gone
            if (nStateAbove != (UINT)-1)
                pMenu->RemoveMenu(pCmdUI->m_nIndex-1, MF_BYPOSITION);
            else if (nStateBelow != (UINT)-1)
                pMenu->RemoveMenu(pCmdUI->m_nIndex, MF_BYPOSITION);
        }
    }
}
コード例 #3
0
ファイル: Step3View.cpp プロジェクト: thinkfeed/touchvg
bool CDrawShapeView::showContextActions(const int* actions)
{
    CMenu menu;
    CMenu* popupMenu = NULL;

    if (actions && actions[0])
    {
        menu.LoadMenu(IDR_CONTEXTMENU);
        popupMenu = menu.GetSubMenu(0);

        int i, n = popupMenu->GetMenuItemCount();
        for (i = 0; i < n && actions[i] > 0; i++) {
            m_actions[i] = actions[i];
        }
        while (--n >= i) {
            m_actions[i] = 0;
            popupMenu->RemoveMenu(ID_DUMMY_1 + n, MF_BYCOMMAND);
        }
    }
    else
    {
        menu.LoadMenu(IDR_STEP1_VIEW);
        popupMenu = menu.GetSubMenu(1);
    }

    CPoint point(mgRound(m_proxy->motion.point.x), mgRound(m_proxy->motion.point.y));
    ClientToScreen(&point);

    return !!popupMenu->TrackPopupMenu(TPM_RIGHTBUTTON | TPM_LEFTALIGN,
        point.x, point.y, GetParentFrame());
}
コード例 #4
0
void CActiveMemberView::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
{
	CMenu menu;
	VERIFY(menu.LoadMenu(IDR_ACTIVEMEMBER_MENU));//载入
	
	CBCGPGridRow* pRow = GetGridCtrl()->GetCurSel();

	if (pRow != NULL)//存在选中的子行
	{
		SendMessage(WM_LBUTTONUP);

		CMenu* pPopup = menu.GetSubMenu(0);//第一个子菜单

		if (pPopup)
		{
			// 2012/03/21-8238-gxx: 
			if (CNetBarConfig::GetInstance()->GetRealNamePassword() == 4 )
			{
				pPopup->RemoveMenu(IDM_CHECKIN, MF_BYCOMMAND);
			}

			theApp.GetContextMenuManager()->ShowPopupMenu(pPopup->Detach(), point.x, point.y, this, TRUE);
		}

		
	}
	else
	{
		CMenu* pPopup = menu.GetSubMenu(1);//第2个子菜单
		theApp.GetContextMenuManager()->ShowPopupMenu(pPopup->Detach(), point.x, point.y, this, TRUE);
	}
}
コード例 #5
0
// 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);
   }
}
コード例 #6
0
//----------------------------------------------------------------------------
// Function ClearSubMenu
// @func    emty submenu of all items
// @rdesc   nothing
// @parm    CFrameWnd    | *pWnd        | frame window to use
// @parm    UINT         | mainMenuItem | main menu item in which's menu submenu is to be added
// @parm    UINT         | itemIndex    | index of submenu in menu
//----------------------------------------------------------------------------
// @prog 
// Anneke Sicherer-Roetman
// @revs 
// 13-03-2000 - First implementation
//----------------------------------------------------------------------------
// @todo 
//----------------------------------------------------------------------------
void ClearSubMenu(CFrameWnd *pWnd, UINT mainMenuItem, UINT itemIndex)
{
	ASSERT_VALID(pWnd);

	CMenu *pMenuBar = pWnd->GetMenu();
	ASSERT_VALID(pMenuBar);

	CMenu *pSubMenu = pMenuBar->GetSubMenu(mainMenuItem);
	ASSERT_VALID(pSubMenu);

	CMenu *pMenu = pSubMenu->GetSubMenu(itemIndex);
	ASSERT_VALID(pMenu);

	while (pSubMenu->RemoveMenu(0, MF_BYPOSITION))
		;
}
コード例 #7
0
//----------------------------------------------------------------------------
// Function RemoveSubMenu
// @func    removes submenu from menu
// @rdesc   nothing
// @parm    CFrameWnd    | *pWnd        | frame window to use
// @parm    UINT         | mainMenuItem | main menu item in which's menu submenu is to be added
// @parm    UINT         | itemIndex    | index of submenu in menu
//----------------------------------------------------------------------------
// @prog 
// Anneke Sicherer-Roetman
// @revs 
// 13-03-2000 - First implementation
//----------------------------------------------------------------------------
// @todo 
//----------------------------------------------------------------------------
void RemoveSubMenu(CFrameWnd *pWnd, UINT mainMenuItem, UINT itemIndex)
{
	ASSERT_VALID(pWnd);

	CMenu *pMenuBar = pWnd->GetMenu();
	ASSERT_VALID(pMenuBar);

	CMenu *pSubMenu = pMenuBar->GetSubMenu(mainMenuItem);
	ASSERT_VALID(pSubMenu);

	CMenu *pMenu = pSubMenu->GetSubMenu(itemIndex);
	ASSERT_VALID(pMenu);

	VERIFY(pSubMenu->RemoveMenu(itemIndex, MF_BYPOSITION));
	delete pMenu;
}
コード例 #8
0
ファイル: IEToolbar.cpp プロジェクト: Inzaghi2012/ie-toolbar
void IEToolbar::buildLanguagesSubMenu(CMenu& menu) {

  CMenu* languagesMenu = menu.GetSubMenu(14);
  languagesMenu->RemoveMenu(0, MF_BYPOSITION);
  // get the current submenu list
  std::map<String, String> languages = ResourceMessages::getCulturesList();
  std::map<String, String>::iterator languageIterator;
  // fill all the available languages
  int languageIndex = ID_LANGUAGE;
  for (languageIterator = languages.begin(); languageIterator != languages.end();
    ++languageIterator) {
      UINT nFlags = MF_STRING;
      if ((*languageIterator).first == ResourceMessages::getInstance().getCurrentCulture()) {
        nFlags |= MF_CHECKED;
      }
      languagesMenu->AppendMenu(nFlags, languageIndex, (*languageIterator).second.c_str());
    ++languageIndex;
  }
}
コード例 #9
0
ファイル: QuickScripts.cpp プロジェクト: OmerMor/SciCompanion
void CQuickScripts::_PrepareViewMenu(int cItems)
{
    if (m_wndButtonViews.m_menu == NULL)
    {
        CMenu menu;
        if (menu.LoadMenu(IDR_MENUVIEWS))
        {
            // We only need to do this once...
            m_wndButtonViews.m_menu.Attach(menu.Detach());
        }
    }
    if (m_wndButtonViews.m_menu)
    {
        UINT nID;
        if (_GetMenuItem("placeholder", &m_wndButtonViews.m_menu, &nID))
        {
            CMenu *pMenuSub = m_wndButtonViews.m_menu.GetSubMenu(nID);

            // Clear the menu out first.
            UINT cItemsInMenu = pMenuSub->GetMenuItemCount();
            while (cItemsInMenu > 0)
            {
                pMenuSub->RemoveMenu(0, MF_BYPOSITION);
                cItemsInMenu--;
            }

            // And rebuild
            for (int iIndex = 0; iIndex < cItems; iIndex++)
            {
                MENUITEMINFO mii = { 0 };
                mii.cbSize = sizeof(mii);
                mii.fMask = MIIM_ID | MIIM_STRING;
                mii.wID = ID_GOTOVIEW1 + iIndex;
                mii.dwTypeData = "foo";
                pMenuSub->InsertMenuItem(ID_GOTOVIEW1 + iIndex, &mii, FALSE);
                //menu.InsertMenuItem(ID_GOTOVIEW1 + iIndex, &mii, FALSE);
            }
        }
    }
    m_wndButtonViews.EnableWindow(cItems > 0);
}
コード例 #10
0
ファイル: WorldsDlg.cpp プロジェクト: Joincheng/lithtech
void CWorldsDlg::OnContextMenu(CWnd* pWnd, CPoint point) 
{
	// TODO: Add your message handler code here
	CMenu menu;
	
	if(!GetProjectBar()->IsProjectOpen())
		return;

	CWnd* pWndPopupOwner = GetProjectBar();

	if(pWnd->m_hWnd == m_WorldTree.m_hWnd)
	{
		VERIFY(menu.LoadMenu(CG_IDR_POPUP_WORLDTREE));
	}
	else if(pWnd->m_hWnd == m_WorldList.m_hWnd)
	{
		// Nothing active unless a directory is selected.
		if(!IsDirectorySelected())
		{
			return;
		}

		//make sure that the user is depressing this over an actual world, so that
		//the action is not ambiguious to what it is acting upon

		//get the point in terms of this window
		CPoint ClientPoint(point);
		m_WorldList.ScreenToClient(&ClientPoint);

		int iIndex = m_WorldList.HitTest(ClientPoint);
		//see if we are hitting any items
		if(iIndex == -1)
		{
			//no item under the cursor, so just make a menu that can only create a new map
			VERIFY(menu.LoadMenu(CG_IDR_POPUP_WORLDLIST_NOITEM));
			pWndPopupOwner = this;
		}
		else
		{
			//we have an item, so display all the options that can be done on that item
			VERIFY(menu.LoadMenu(CG_IDR_POPUP_WORLDLIST));
			pWndPopupOwner = this;

			//now we need to see if this file is compressed and only enable the opposite
			//menu item to be enable so the user doesn't get confused
			DFileIdent *pIdent = (DFileIdent*)m_WorldList.GetItemData(iIndex);

			if(CLTAUtil::IsFileCompressed(pIdent->m_Filename))
			{
				menu.RemoveMenu(ID_WORLD_COMPRESS, MF_BYCOMMAND);
			}
			else
			{
				menu.RemoveMenu(ID_WORLD_DECOMPRESS, MF_BYCOMMAND);
			}

		}
	}
	else return;


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

	pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,
		pWndPopupOwner);	
}
コード例 #11
0
ファイル: SHCTListCtrl.cpp プロジェクト: macduff/passwordsafe
void CSHCTListCtrl::OnRButtonDown(UINT , CPoint point)
{
  CMenu PopupMenu;
  MapMenuShortcutsIter iter;
  CString str;
  CPoint pt;
  int iSubItem = -1;

  SaveHotKey();

  LVHITTESTINFO lvhti;
  lvhti.pt = point;
  SubItemHitTest(&lvhti);

  m_item = lvhti.iItem;
  iSubItem = lvhti.iSubItem;

  if (m_item < 0 || iSubItem < 0) {
    // CListCtrl::OnRButtonDown(nFlags, point);
    goto exit;
  }

  m_id = (UINT)LOWORD(GetItemData(m_item));
  if (!m_pParent->GetMapMenuShortcutsIter(m_id, iter)) {
     goto exit;
  }

  PopupMenu.LoadMenu(IDR_POPRESETSHORTCUT);
  CMenu* pContextMenu = PopupMenu.GetSubMenu(0);
  if (iter->second.siVirtKey == 0)
    pContextMenu->RemoveMenu(ID_MENUITEM_REMOVESHORTCUT, MF_BYCOMMAND);

  if (iter->second.siVirtKey   == iter->second.siDefVirtKey &&
      iter->second.cModifier  == iter->second.cDefModifier)
    pContextMenu->RemoveMenu(ID_MENUITEM_RESETSHORTCUT, MF_BYCOMMAND);

  if (pContextMenu->GetMenuItemCount() == 0)
    goto exit;

  pt = point;
  ClientToScreen(&pt);

  int nID = pContextMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RETURNCMD,
                                         pt.x, pt.y, this);

  if (nID == ID_MENUITEM_REMOVESHORTCUT) {
    iter->second.siVirtKey = 0;
    iter->second.cModifier = 0;
    str = L"";
    goto update;
  }

  if (nID != ID_MENUITEM_RESETSHORTCUT)
    goto exit;

  iter->second.siVirtKey = iter->second.siDefVirtKey;
  iter->second.cModifier = iter->second.cDefModifier;

  str = CMenuShortcut::FormatShortcut(iter);

update:
  SetItemText(m_item, SHCT_SHORTCUTKEYS, str);
  RedrawItems(m_item, m_item);
  UpdateWindow();

exit:
  if (m_pParent != NULL)
    m_pParent->ClearWarning();

  if (m_item >= 0)
    SetItemState(m_item, SHCT_SHORTCUTKEYS, LVIS_SELECTED | LVIS_DROPHILITED);
}
コード例 #12
0
ファイル: MainFrm.cpp プロジェクト: IMSoP/CDex
bool CMainFrame::SetLanguageMenu()
{
	CMenu* pParentMenu = GetMenu();
	CMenu* pMenu = GetMenu()->GetSubMenu( m_nLangOptionMenuPos );
    
    CUStringConvert strCnv;

	ASSERT( pMenu );

	if ( NULL == m_pPopupMenu )
	{
		m_pPopupMenu = new CMenu;

		m_pPopupMenu->CreatePopupMenu();

		CUString strAdd( g_language.GetString( IDS_CHECKFORADDITIONAL_LANGUAGE_FILES ) );

        CUStringConvert strCnv;

		// Add Check for Updates
        m_pPopupMenu->AppendMenu( MF_STRING | MF_ENABLED, ID_LANGUAGE_START, strCnv.ToT( strAdd ) );

		// Add language menu items
		for ( DWORD idx = 0; idx < g_language.GetNumLanguageStrings() ; idx++ )
		{

			CUString strAdd( g_language.GetLanguageString( idx ) );
			m_pPopupMenu->AppendMenu( MF_STRING | MF_ENABLED, ID_LANGUAGE_START + idx + 1, strCnv.ToT( strAdd ) );
		}
	}

	CString strCurrent;
	pMenu->GetMenuString( m_nLangLangMenuPos, strCurrent, MF_BYPOSITION );

	// Add language menu items
	for ( DWORD idx = 0; idx < m_pPopupMenu->GetMenuItemCount(); idx++ )
	{
		CString strMenu;

		if ( 0 == idx )
		{
			m_pPopupMenu->ModifyMenu(	idx, 
										MF_BYPOSITION | MF_STRING,
										ID_LANGUAGE_START,
										strCnv.ToT( g_language.GetString( IDS_CHECKFORADDITIONAL_LANGUAGE_FILES ) ));

		}

		// get menu string
		m_pPopupMenu->GetMenuString( idx, strMenu, MF_BYPOSITION );

		// check if this is the selected language
		if ( 0 == g_language.GetLanguage().CompareNoCase( CUString( strMenu ) ) )
		{
			m_pPopupMenu->CheckMenuItem( idx, MF_BYPOSITION | MF_CHECKED  );
		}
		else
		{
			m_pPopupMenu->CheckMenuItem( idx, MF_BYPOSITION | MF_UNCHECKED  );
		}
	}

	// remove exisiting menu item
	pMenu->RemoveMenu( m_nLangLangMenuPos, MF_BYPOSITION );

	// insert new popup menu
	pMenu->InsertMenu(	m_nLangLangMenuPos,
						MF_BYPOSITION | MF_POPUP, 
						(UINT)m_pPopupMenu->m_hMenu, 
						strCurrent );


	// peform translation
	g_language.TranslateMenu( GetMenu(), m_nMenuID );

	// refresh frame windows
	ActivateFrame( SW_HIDE );
	ActivateFrame( SW_SHOW );

	return true;
}
コード例 #13
0
void CDHtmlMainDialog::InitMenu()
{
	CMenu menu;
	CMenu subMenu;
	BOOL FlagHitTheme = FALSE;
	BOOL FlagHitLang = FALSE;
	UINT newItemID = 0;
	UINT currentItemID = 0;
	UINT defaultStyleItemID = 0;
	UINT defaultLanguageItemID = 0;
	WIN32_FIND_DATA findData;
	WIN32_FIND_DATA findCssData;
	HANDLE hFind;
	HANDLE hCssFind;
	CString themePath;
	CString themeCssPath;
	CString langPath;
	int i = 0;
	TCHAR *ptrEnd;
	TCHAR str[256];
	
	menu.Attach(GetMenu()->GetSafeHmenu());
	subMenu.Attach(menu.GetSubMenu(m_ThemeIndex)->GetSafeHmenu());
//	subMenu.RemoveMenu(0, MF_BYPOSITION);

	themePath.Format(_T("%s\\*.*"), m_ThemeDir);

	hFind = ::FindFirstFile(themePath, &findData);
	if(hFind != INVALID_HANDLE_VALUE)
	{
		while(::FindNextFile(hFind, &findData) && i <= 0xFF)
		{
			if(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
			{
//				themeCssPath.Format(_T("%s\\%s\\%s"), m_ThemeDir,
//									findData.cFileName, MAIN_CSS_FILE_NAME);
				hCssFind = ::FindFirstFile(themeCssPath, &findCssData);
				if(hCssFind != INVALID_HANDLE_VALUE)
				{
					// Add Theme
					newItemID = WM_THEME_ID + i;
					i++;
					subMenu.AppendMenu(MF_STRING, (UINT_PTR)newItemID, findData.cFileName);
					m_MenuArrayTheme.Add(findData.cFileName);
					if(m_CurrentTheme.Compare(findData.cFileName) == 0)
					{
						currentItemID = newItemID;
						FlagHitTheme = TRUE;
					}
					if(_tcsstr(findData.cFileName, _T("default")) != NULL)
					{
						defaultStyleItemID = newItemID;
					}
				}
			}
		}
	}
	FindClose(hFind);

	if(! FlagHitTheme)
	{
		currentItemID = defaultStyleItemID;
		m_CurrentTheme = _T("default");
	}

	subMenu.CheckMenuRadioItem(WM_THEME_ID, WM_THEME_ID + (UINT)m_MenuArrayTheme.GetSize(),
								currentItemID, MF_BYCOMMAND);

	subMenu.Detach();

#ifdef _UNICODE
	subMenu.Attach(menu.GetSubMenu(m_LangIndex)->GetSafeHmenu());

	CMenu subMenuAN;
	CMenu subMenuOZ;

	subMenuAN.Attach(subMenu.GetSubMenu(0)->GetSafeHmenu()); // 1st is "A~N"
	subMenuAN.RemoveMenu(0, MF_BYPOSITION);
	subMenuOZ.Attach(subMenu.GetSubMenu(1)->GetSafeHmenu()); // 2nd is "O~Z"
	subMenuOZ.RemoveMenu(0, MF_BYPOSITION);

	langPath.Format(_T("%s\\*.lang"), m_LangDir);
	i = 0;
	hFind = ::FindFirstFile(langPath, &findData);
	if(hFind != INVALID_HANDLE_VALUE)
	{
		do{
			if(findData.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY)
			{
				newItemID = WM_LANGUAGE_ID + i;
				i++;

				// Add Language
				CString cstr;
				cstr.Format(_T("%s\\%s"), m_LangDir, findData.cFileName);
				GetPrivateProfileString(_T("Language"), _T("LANGUAGE"), _T(""), str, 256, cstr);
				if((ptrEnd = _tcsrchr(findData.cFileName, '.')) != NULL)
				{
					*ptrEnd = '\0';
				}

				cstr.Format(_T("%s, [%s]"), str, findData.cFileName);
				if('A' <= findData.cFileName[0] && findData.cFileName[0] <= 'N')
				{
					subMenuAN.AppendMenu(MF_STRING, (UINT_PTR)newItemID, cstr);
				}
				else
				{
					subMenuOZ.AppendMenu(MF_STRING, (UINT_PTR)newItemID, cstr);
				}
				m_MenuArrayLang.Add(findData.cFileName);

				if(m_CurrentLang.Compare(findData.cFileName) == 0)
				{
					currentItemID = newItemID;
					FlagHitLang = TRUE;
				}
			}
		}while(::FindNextFile(hFind, &findData) && i <= 0xFF);
	}
	FindClose(hFind);

	subMenuAN.CheckMenuRadioItem(WM_LANGUAGE_ID, WM_LANGUAGE_ID + (UINT)m_MenuArrayLang.GetSize(),
								currentItemID, MF_BYCOMMAND);
	subMenuOZ.CheckMenuRadioItem(WM_LANGUAGE_ID, WM_LANGUAGE_ID + (UINT)m_MenuArrayLang.GetSize(),
								currentItemID, MF_BYCOMMAND);

	subMenuOZ.Detach();
	subMenuAN.Detach();
	subMenu.Detach();
	menu.Detach();
#else
	subMenu.Attach(menu.GetSubMenu(m_LangIndex)->GetSafeHmenu());
	subMenu.RemoveMenu(0, MF_BYPOSITION);//A~N
	subMenu.RemoveMenu(0, MF_BYPOSITION);//O~Z
	langPath.Format(_T("%s\\*.lang"), m_LangDir);
	i = 0;
	hFind = ::FindFirstFile(langPath, &findData);
	if(hFind != INVALID_HANDLE_VALUE)
	{
		do{
			if(findData.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY)
			{
				newItemID = WM_LANGUAGE_ID + i;
				i++;

				// Add Language
				CString cstr;
				cstr.Format(_T("%s\\%s"), m_LangDir, findData.cFileName);
				GetPrivateProfileString(_T("Language"), _T("LANGUAGE"), _T(""), str, 256, cstr);
				if((ptrEnd = _tcsrchr(findData.cFileName, '.')) != NULL){
					*ptrEnd = '\0';
				}

				cstr.Format(_T("%s, [%s]"), str, findData.cFileName);
				subMenu.AppendMenu(MF_STRING, (UINT_PTR)newItemID, cstr);
				m_MenuArrayLang.Add(findData.cFileName);

				if(m_CurrentLang.Compare(findData.cFileName) == 0)
				{
					currentItemID = newItemID;
					FlagHitLang = TRUE;
				}
			}
		}while(::FindNextFile(hFind, &findData) && i <= 0xFF);

	}
	FindClose(hFind);

	subMenu.CheckMenuRadioItem(WM_LANGUAGE_ID, WM_LANGUAGE_ID + (UINT)m_MenuArrayLang.GetSize(),
								currentItemID, MF_BYCOMMAND);

	subMenu.Detach();
	menu.Detach();
#endif
	if(! FlagHitLang)
	{
		AfxMessageBox(_T("Fatal Error. Missing Language Files!!"));
	}
}
コード例 #14
0
void SkeinWindow::OnContextMenu(CWnd* pWnd, CPoint point)
{
  // No menu if currently editing
  if (m_edit.IsWindowVisible())
    return;

  // No menu if running the game
  bool gameRunning = GetParentFrame()->SendMessage(WM_GAMERUNNING) != 0;
  bool gameWaiting = GetParentFrame()->SendMessage(WM_GAMEWAITING) != 0;
  if (gameRunning && !gameWaiting)
    return;

  // Find the node under the mouse, if any
  CPoint cp(point);
  ScreenToClient(&cp);
  Skein::Node* node = NodeAtPoint(cp);
  if (node == NULL)
    return;

  // Get the context menu
  CMenu popup;
  popup.LoadMenu(IDR_SKEIN);
  CMenu* menu = popup.GetSubMenu(0);

  // Update the state of the context menu items
  if (node->GetParent() == NULL)
  {
    menu->RemoveMenu(ID_SKEIN_EDIT,MF_BYCOMMAND);
    menu->RemoveMenu(ID_SKEIN_ADD_LABEL,MF_BYCOMMAND);
    menu->RemoveMenu(ID_SKEIN_EDIT_LABEL,MF_BYCOMMAND);
    menu->RemoveMenu(ID_SKEIN_INSERT_KNOT,MF_BYCOMMAND);
    menu->RemoveMenu(ID_SKEIN_DELETE,MF_BYCOMMAND);
    menu->RemoveMenu(ID_SKEIN_DELETE_BELOW,MF_BYCOMMAND);
    menu->RemoveMenu(ID_SKEIN_DELETE_THREAD,MF_BYCOMMAND);
    menu->RemoveMenu(ID_SKEIN_LOCK,MF_BYCOMMAND|MF_GRAYED);
    menu->RemoveMenu(ID_SKEIN_UNLOCK,MF_BYCOMMAND|MF_GRAYED);
    menu->RemoveMenu(ID_SKEIN_LOCK_THREAD,MF_BYCOMMAND|MF_GRAYED);
    menu->RemoveMenu(ID_SKEIN_UNLOCK_THREAD,MF_BYCOMMAND|MF_GRAYED);
  }
  else
  {
    if (gameRunning && m_skein->InCurrentThread(node))
    {
      menu->EnableMenuItem(ID_SKEIN_DELETE,MF_BYCOMMAND|MF_GRAYED);
      menu->EnableMenuItem(ID_SKEIN_DELETE_BELOW,MF_BYCOMMAND|MF_GRAYED);
    }
    if (gameRunning && m_skein->InCurrentThread(m_skein->GetThreadTop(node)))
      menu->EnableMenuItem(ID_SKEIN_DELETE_THREAD,MF_BYCOMMAND|MF_GRAYED);
    if (node->GetLabel().IsEmpty())
      menu->RemoveMenu(ID_SKEIN_EDIT_LABEL,MF_BYCOMMAND);
    else
      menu->RemoveMenu(ID_SKEIN_ADD_LABEL,MF_BYCOMMAND);
  }
  if (node->GetTemporary())
  {
    menu->RemoveMenu(ID_SKEIN_UNLOCK,MF_BYCOMMAND|MF_GRAYED);
    menu->RemoveMenu(ID_SKEIN_UNLOCK_THREAD,MF_BYCOMMAND|MF_GRAYED);
  }
  else
  {
    menu->RemoveMenu(ID_SKEIN_LOCK,MF_BYCOMMAND|MF_GRAYED);
    menu->RemoveMenu(ID_SKEIN_LOCK_THREAD,MF_BYCOMMAND|MF_GRAYED);
  }

  // Show the context menu
  int cmd = menu->TrackPopupMenuEx(TPM_LEFTALIGN|TPM_TOPALIGN|TPM_NONOTIFY|TPM_RETURNCMD,
    point.x,point.y,GetParentFrame(),NULL);

  // Act on the context menu choice
  switch (cmd)
  {
  case ID_SKEIN_PLAY:
    GetParentFrame()->SendMessage(WM_PLAYSKEIN,(WPARAM)node);
    break;
  case ID_SKEIN_EDIT:
    StartEdit(node,false);
    break;
  case ID_SKEIN_ADD_LABEL:
  case ID_SKEIN_EDIT_LABEL:
    // Make sure that the label background is visible
    Invalidate();
    StartEdit(node,true);
    break;
  case ID_SKEIN_TRANSCRIPT:
    GetParentFrame()->SendMessage(WM_SHOWTRANSCRIPT,(WPARAM)node,(LPARAM)GetSafeHwnd());
    break;
  case ID_SKEIN_LOCK:
    m_skein->Lock(node);
    break;
  case ID_SKEIN_UNLOCK:
    m_skein->Unlock(node);
    break;
  case ID_SKEIN_LOCK_THREAD:
    m_skein->Lock(m_skein->GetThreadBottom(node));
    break;
  case ID_SKEIN_UNLOCK_THREAD:
    m_skein->Unlock(m_skein->GetThreadTop(node));
    break;
  case ID_SKEIN_NEW_THREAD:
    {
      Skein::Node* newNode = m_skein->AddNew(node);

      // Force a repaint so that the new node is drawn and recorded
      Invalidate();
      UpdateWindow();
      StartEdit(newNode,false);
    }
    break;
  case ID_SKEIN_INSERT_KNOT:
    {
      Skein::Node* newNode = m_skein->AddNewParent(node);
      Invalidate();
      UpdateWindow();
      StartEdit(newNode,false);
    }
    break;
  case ID_SKEIN_DELETE:
    if (CanRemove(node))
      m_skein->RemoveSingle(node);
    break;
  case ID_SKEIN_DELETE_BELOW:
    if (CanRemove(node))
      m_skein->RemoveAll(node);
    break;
  case ID_SKEIN_DELETE_THREAD:
    {
      Skein::Node* topNode = m_skein->GetThreadTop(node);
      if (CanRemove(topNode))
        m_skein->RemoveAll(topNode);
    }
    break;
  case ID_SKEIN_SAVE_TRANSCRIPT:
    {
      SimpleFileDialog dialog(FALSE,"txt",NULL,OFN_HIDEREADONLY|OFN_ENABLESIZING,
        "Text Files (*.txt)|*.txt|All Files (*.*)|*.*||",this);
      dialog.m_ofn.lpstrTitle = "Save the transcript up to this knot";
      if (dialog.DoModal() == IDOK)
        m_skein->SaveTranscript(node,dialog.GetPathName());
    }
    break;
  case 0:
    // Make sure this window still has the focus
    SetFocus();
    break;
  }
}
コード例 #15
0
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);
  }
}