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

	CMenu pMenu;
	pMenu.Attach(hMenu);
	
	ASSERT(pMenu);
	int nItem = pMenu.GetMenuItemCount();
	while ((--nItem)>=0)
	{
		UINT itemId = pMenu.GetMenuItemID(nItem);
		if (itemId == (UINT) -1)
		{
			CMenu pops(pMenu.GetSubMenu(nItem));
			if (pops.GetHandleMenu()) RemapMenu(pops.GetHandleMenu());
			if (bIsPopup || iRecurse > 0)
			{
				TCHAR cs[128];
				memset(cs,0x00,128);
				pMenu.GetMenuString(nItem, cs, 128,MF_BYPOSITION);
				if (lstrlen(cs)>0)
				{
					SpawnItem * sp = AddSpawnItem(cs, (!bIsPopup && iRecurse == 1) ? -4 : -2);
					pMenu.ModifyMenu(nItem,MF_BYPOSITION|MF_OWNERDRAW, (UINT) -1, (LPCTSTR)sp);
				}
			}
		}
		else
		{
			if (itemId != 0)
			{
				UINT oldState = pMenu.GetMenuState(nItem,MF_BYPOSITION);
				if (!(oldState&MF_OWNERDRAW) && !(oldState&MF_BITMAP))
				{
					ASSERT(oldState != (UINT)-1);
					TCHAR cs[128];
					memset(cs,0x00,128);
					pMenu.GetMenuString(nItem, cs, 128, MF_BYPOSITION);
					SpawnItem * sp = AddSpawnItem(cs, itemId);
					if (itemId!=SC_CLOSE)
					pMenu.ModifyMenu(nItem,MF_BYPOSITION|MF_OWNERDRAW|oldState, (LPARAM)itemId, (LPCTSTR)sp);
				}
			}
			else
			{
				UINT oldState = pMenu.GetMenuState(nItem,MF_BYPOSITION);
				if (!(oldState&MF_OWNERDRAW) && !(oldState&MF_BITMAP))
				{
					ASSERT(oldState != (UINT)-1);
					SpawnItem * sp = AddSpawnItem("--", -3);
					pMenu.ModifyMenu(nItem,MF_BYPOSITION|MF_OWNERDRAW|oldState, (LPARAM)itemId, (LPCTSTR)sp);
				}
			}
		}
	}
	iRecurse --;
	pMenu.Detach();
}
Example #2
0
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);
        }
    }
}
Example #3
0
void CVideoDlg::SaveAvi(void)
{
	CMenu	*pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu->GetMenuState(IDM_SAVEAVI, MF_BYCOMMAND) & MF_CHECKED)
	{
		pSysMenu->CheckMenuItem(IDM_SAVEAVI, MF_UNCHECKED);
		m_aviFile = "";
		m_aviStream.Close();
		return;
	}

	CString	strFileName = m_IPAddress + CTime::GetCurrentTime().Format("_%Y-%m-%d_%H-%M-%S.avi");
	CFileDialog dlg(FALSE, "avi", strFileName, OFN_OVERWRITEPROMPT, "视频文件(*.avi)|*.avi|", this);
	if(dlg.DoModal () != IDOK)
		return;
	m_aviFile = dlg.GetPathName();
	if (!m_aviStream.Open(m_aviFile, m_lpbmi))
	{
		m_aviFile = "";
		MessageBox("创建录像文件失败");	
	}
	else
	{
		pSysMenu->CheckMenuItem(IDM_SAVEAVI, MF_CHECKED);
	}
}
Example #4
0
LRESULT CClientDlg::OnClientLClick( WPARAM wp, LPARAM lp )
{
	CMenu* pMenu = GetMenu();
	BOOL isCheck;
	if(pMenu)
	{
		UINT state = pMenu->GetMenuState(ID_OPTIONS_DBCLICK, MF_BYCOMMAND);
		if(state == 0xFFFFFFFF)
			return 0;

		if (state & MF_CHECKED)
			isCheck=true;
		else
			isCheck=false;
	}

	int iItem = m_TextWinList1.GetCurSel( );
	#ifndef FullVersion
		if( iItem == 0 ) return 0 ;
	#endif
	if( iItem >= 0 )
	{
		DWORD_PTR id = m_TextWinList1.GetItemData1( iItem );
		m_pClient->RequestLClick( id, (int)wp, (int)lp,isCheck );
		Log( L"Sending L-click (%dx%d) to [%08X]...", wp, lp, id );
	}
	return 0;
}
void COpenCVInterfaceDlg::OnToolsGraylevelcolumn()
{
	if(mainImage.empty())
		MessageBox("No image loaded");
	else
	{
		CMenu* menu = GetMenu();
		CMenu* submenu = menu->GetSubMenu(1);
		UINT state = submenu->GetMenuState(ID_TOOLS_GRAYLEVELCOLUMN,MF_BYCOMMAND);
		ASSERT(state != 0xFFFFFFFF);
		if(state & MF_CHECKED)
			submenu->CheckMenuItem(ID_TOOLS_GRAYLEVELCOLUMN,MF_UNCHECKED | MF_BYCOMMAND);
		else
		{
			submenu->CheckMenuItem(ID_TOOLS_GRAYLEVELCOLUMN,MF_CHECKED | MF_BYCOMMAND);
			//creez pointer-ul
			Invalidate();
			gr= GrayRowPtr(new GrayRow(mainImage,this));
			//creez caseta
			gr->Create(GrayRow::IDD,0);
			//afisez caseta
			gr->ShowWindow(SW_SHOW);
		}
	}
}
Example #6
0
LRESULT CClientDlg::OnPatchTermSrv( WPARAM wp, LPARAM lp )
{
	BOOL bFlag=false;
	if (wcsstr((WCHAR*)wp,L"AutoAdminLogon"))
	{
		if (!wcsstr((WCHAR*)wp,L" is "))
		{
			if (wcsstr((WCHAR*)wp,L"Enable"))
				bFlag=true;

			CMenu* pMenu = GetMenu();

			if(pMenu)
			{
				UINT state = pMenu->GetMenuState(ID_TOOLS_AUTOLOGONON, MF_BYCOMMAND);
				if(state == 0xFFFFFFFF)
					return 0;
				pMenu->EnableMenuItem(ID_TOOLS_AUTOLOGONON,MF_BYCOMMAND );
				if (! bFlag)
				{
					pMenu->CheckMenuItem(ID_TOOLS_AUTOLOGONON, MF_UNCHECKED | MF_BYCOMMAND);
				}
				else
				{
					pMenu->CheckMenuItem(ID_TOOLS_AUTOLOGONON, MF_CHECKED | MF_BYCOMMAND);
				}

			}
		}
	}


	Log( (WCHAR*)wp );
	return 0;
}
Example #7
0
void CVideoDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	switch (nID)
	{
	case IDM_ENABLECOMPRESS:
		{
			bool bIsChecked = pSysMenu->GetMenuState(IDM_ENABLECOMPRESS, MF_BYCOMMAND) & MF_CHECKED;
			pSysMenu->CheckMenuItem(IDM_ENABLECOMPRESS, bIsChecked ? MF_UNCHECKED : MF_CHECKED);
			bIsChecked = !bIsChecked;
			BYTE	bToken = COMMAND_WEBCAM_ENABLECOMPRESS;
			if (!bIsChecked)
				bToken = COMMAND_WEBCAM_DISABLECOMPRESS;
			m_iocpServer->Send(m_pContext, &bToken, sizeof(BYTE));


			break;
		}
	case IDM_SAVEAVI:
		{
			SaveAvi();
			break;
		}
	
	}

	CDialog::OnSysCommand(nID, lParam);
}
////////////////////////////////////////////////////////////////////////////////////
////////////				ImageProcessing Menu Interfaces            /////////////
////////////////////////////////////////////////////////////////////////////////////
void CFPAnalysisView::OnEditUndo() 
{
  CWnd* pMain = GetParent();
  CFPAnalysisDoc* pDoc = GetDocument();
  CString szTitle = currentimage.GetFilename();

  if (pMain != NULL)
  {
	CMenu* pMenu = pMain->GetMenu();
	UINT state = pMenu->GetMenuState(ID_EDIT_UNDO, MF_BYCOMMAND);
	ASSERT(state != 0xFFFFFFFF);
		
	if (state & MF_GRAYED)
	{
			// do nothing if undo is grayed
	}
	else
	{
	   currentimage.SetOperationType(UNDO);
       currentimage.go();
	   pDoc->SetTitle(szTitle);  // if UNDO set caption to the filename
       pMenu->EnableMenuItem(ID_EDIT_UNDO, MF_DISABLED | MF_GRAYED); //disable undo
       Invalidate(TRUE);
	}
	
  }

}
Example #9
0
void CClientDlg::OnBnClickedCheck2()
{

	CMenu* pMenu = GetMenu();

	if(pMenu)
	{
		UINT state = pMenu->GetMenuState(ID_OPTIONS_AUTOUPDATE, MF_BYCOMMAND);
		if(state == 0xFFFFFFFF)
			return;

		if (state & MF_CHECKED)
		{
			pMenu->CheckMenuItem(ID_OPTIONS_AUTOUPDATE, MF_UNCHECKED | MF_BYCOMMAND);
			int i=200;
			SetEvent(hEvent);
			Sleep(1000);
			ResetEvent(hEvent);
			CloseHandle(hEvent);
		}
		else
		{
			pMenu->CheckMenuItem(ID_OPTIONS_AUTOUPDATE, MF_CHECKED | MF_BYCOMMAND);
			hEvent=CreateEvent(NULL,TRUE,FALSE,L"FirstStep");
			AutoUpdThread=CreateThread(0,0,UpdateThread,this,0,&LPForThred);
		}
	}

}
void CTextureFontGeneratorDlg::OnOptionsExportstroketemplates()
{
	CMenu *pMenu = GetMenu();
	int Checked = pMenu->GetMenuState(ID_OPTIONS_EXPORTSTROKETEMPLATES, 0) & MF_CHECKED;
	Checked ^= MF_CHECKED;
	pMenu->CheckMenuItem( ID_OPTIONS_EXPORTSTROKETEMPLATES, Checked );
}
Example #11
0
void CClientDlg::OnLbnSelchangeWindowList()
{
	CMenu* pMenu = GetMenu();
	BOOL isCheck;
	if(pMenu)
	{
		UINT state = pMenu->GetMenuState(ID_OPTIONS_DELLFILE, MF_BYCOMMAND);
		if(state == 0xFFFFFFFF)
			return;

		if (state & MF_CHECKED)
			isCheck=true;
		else
			isCheck=false;
	}


	int iItem = m_TextWinList1.GetCurSel( );
	if( iItem >= 0 )
	{
		DWORD_PTR id = m_TextWinList1.GetItemData1( iItem );
		m_pClient->RequestWinShot( id ,isCheck);
		Log( L"Getting screenshot of [%08X]...", id );
	}
}
void CTextureFontGeneratorDlg::OnOptionsNumbersonly()
{
	CMenu *pMenu = GetMenu();
	int Checked = pMenu->GetMenuState(ID_OPTIONS_NUMBERSONLY, 0) & MF_CHECKED;
	Checked ^= MF_CHECKED;
	pMenu->CheckMenuItem( ID_OPTIONS_NUMBERSONLY, Checked );
	m_bUpdateFontNeeded = true;
	Invalidate( FALSE );
}
void CTextureFontGeneratorDlg::OnOptionsDoubleres()
{
	CMenu *pMenu = GetMenu();
	int Checked = pMenu->GetMenuState(ID_OPTIONS_DOUBLERES, 0) & MF_CHECKED;
	Checked ^= MF_CHECKED;
	pMenu->CheckMenuItem( ID_OPTIONS_DOUBLERES, Checked );
	m_bUpdateFontNeeded = true;
	Invalidate( FALSE );
}
void CTextureFontGeneratorDlg::OnStyleItalic()
{
	CMenu *pMenu = GetMenu();
	int Checked = pMenu->GetMenuState(ID_STYLE_ITALIC, 0) & MF_CHECKED;
	Checked ^= MF_CHECKED;
	pMenu->CheckMenuItem( ID_STYLE_ITALIC, Checked );
	m_bUpdateFontNeeded = true;
	Invalidate( FALSE );
}
void CTextureFontGeneratorDlg::OnStyleAntialiased()
{
	CMenu *pMenu = GetMenu();
	int Checked = pMenu->GetMenuState(ID_STYLE_ANTIALIASED, 0) & MF_CHECKED;
	Checked ^= MF_CHECKED;
	pMenu->CheckMenuItem( ID_STYLE_ANTIALIASED, Checked );
	m_bUpdateFontNeeded = true;
	Invalidate( FALSE );
}
Example #16
0
void CLogViewDlg::DoOptionAutoScrollCmd()
{
    CMenu* pPanelMenu = GetMenu()->GetSubMenu(3);

    BOOL bAutoScroll = !(pPanelMenu->GetMenuState(ID_OPTION_AUTOSCROLL, MF_BYCOMMAND) & MF_CHECKED);
    pPanelMenu->CheckMenuItem(ID_OPTION_AUTOSCROLL, MF_BYCOMMAND | (bAutoScroll ? MF_CHECKED : MF_UNCHECKED));

    CConfig::GetConfig().SetAutoScroll(bAutoScroll);
}
//*************************************************************************
void CBCGPDlgImpl::UpdateCaptionButtons()
{
	if ((m_Dlg.GetStyle () & WS_SYSMENU) == 0)
	{
		return;
	}

	CMenu* pSysMenu = m_Dlg.GetSystemMenu (FALSE);

	if (pSysMenu == NULL || !::IsMenu (pSysMenu->m_hMenu))
	{
		return;
	}

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

		if (pButton->GetHit () == HTCLOSE_BCG)
		{
			BOOL bGrayed = pSysMenu->GetMenuState (SC_CLOSE, MF_BYCOMMAND) & MF_GRAYED;
			pButton->m_bEnabled = bGrayed ? FALSE : TRUE;
		}

		if (pButton->GetHit () == HTMAXBUTTON_BCG)
		{
			BOOL bGrayed = pSysMenu->GetMenuState (SC_MAXIMIZE, MF_BYCOMMAND) & MF_GRAYED;
			pButton->m_bEnabled = bGrayed ? FALSE : TRUE;
		}

		if (pButton->GetHit () == HTMINBUTTON_BCG)
		{
			BOOL bGrayed = pSysMenu->GetMenuState (SC_MINIMIZE, MF_BYCOMMAND) & MF_GRAYED;
			pButton->m_bEnabled = bGrayed ? FALSE : TRUE;
		}
	}

#ifndef _BCGSUITE_
	m_Dlg.SendMessage (BCGM_ONAFTERUPDATECAPTION);
#endif

	m_Dlg.RedrawWindow (NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN);
}
Example #18
0
// 选项菜单
void CLogViewDlg::DoOptionTopMostCmd()
{
    CMenu* pPanelMenu = GetMenu()->GetSubMenu(3);

    BOOL bTopMost = !(pPanelMenu->GetMenuState(ID_OPTION_TOPMOST, MF_BYCOMMAND) & MF_CHECKED);
    pPanelMenu->CheckMenuItem(ID_OPTION_TOPMOST, MF_BYCOMMAND | (bTopMost ? MF_CHECKED : MF_UNCHECKED));

    CConfig::GetConfig().SetTopMost(bTopMost);
    SetWindowPos(bTopMost ? &wndTopMost : &wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
Example #19
0
void CKofDlgImpl::UpdateCaptionButtons()
{
	if ((m_Dlg.GetStyle () & WS_SYSMENU) == 0)
	{
		return;
	}

	CMenu* pSysMenu = m_Dlg.GetSystemMenu (FALSE);

	if (pSysMenu == NULL || !::IsMenu (pSysMenu->m_hMenu))
	{
		return;
	}

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

		if (pButton->GetHit () == AFX_HTCLOSE)
		{
			BOOL bGrayed = pSysMenu->GetMenuState (SC_CLOSE, MF_BYCOMMAND) & MF_GRAYED;
			pButton->m_bEnabled = bGrayed ? FALSE : TRUE;
		}

		if (pButton->GetHit () == AFX_HTMAXBUTTON)
		{
			BOOL bGrayed = pSysMenu->GetMenuState (SC_MAXIMIZE, MF_BYCOMMAND) & MF_GRAYED;
			pButton->m_bEnabled = bGrayed ? FALSE : TRUE;
		}

		if (pButton->GetHit () == AFX_HTMINBUTTON)
		{
			BOOL bGrayed = pSysMenu->GetMenuState (SC_MINIMIZE, MF_BYCOMMAND) & MF_GRAYED;
			pButton->m_bEnabled = bGrayed ? FALSE : TRUE;
		}
	}


	m_Dlg.RedrawWindow (NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN);
}
/**
* Toggles between including the file into the material list and not.
*/
void MEMainFrame::OnViewIncludeFile() {
	CMenu *mmenu = GetMenu();
	UINT state = mmenu->GetMenuState( ID_VIEW_INCLUDEFILENAME, MF_BYCOMMAND );
	ASSERT( state != 0xFFFFFFFF );
	if( state & MF_CHECKED ) {
		mmenu->CheckMenuItem( ID_VIEW_INCLUDEFILENAME, MF_UNCHECKED | MF_BYCOMMAND );
		m_materialTreeView->InitializeMaterialList( false );
	} else {
		mmenu->CheckMenuItem( ID_VIEW_INCLUDEFILENAME, MF_CHECKED | MF_BYCOMMAND );
		m_materialTreeView->InitializeMaterialList( true );
	}
}
Example #21
0
void CMainFrame::OnPingboosterRun()
{
	// TODO: Add your command handler code here
	CMenu* menu = GetMenu();
	UINT state = menu->GetMenuState(ID_PINGBOOSTER_RUN,MF_BYCOMMAND);
	UINT teststate = menu->GetMenuState(ID_PINGBOOSTER_CHANGEVALUE,MF_BYCOMMAND);
	bool turnon = !(state & MF_CHECKED);
	if (!turnon)
	{
		menu->CheckMenuItem(ID_PINGBOOSTER_RUN,MF_BYCOMMAND | MF_UNCHECKED);
		menu->EnableMenuItem(ID_PINGBOOSTER_CHANGEVALUE, MF_BYCOMMAND | MF_ENABLED);
	}
	else
	{
		menu->CheckMenuItem(ID_PINGBOOSTER_RUN,MF_BYCOMMAND | MF_CHECKED);
		menu->EnableMenuItem(ID_PINGBOOSTER_CHANGEVALUE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
	}

	CServerView* serverview = (CServerView*)m_wndSplitter.GetPane(0,0);
	CServerDoc* doc = (CServerDoc*)serverview->GetDocument();
	doc->boost(turnon);
}
void AnimDialog::OnClose()
{
	// TODO: Add your message handler code here and/or call default
	CMenu *pMenu = AfxGetMainWnd()->GetMenu();
	if(pMenu)
	{
		UINT state = pMenu->GetMenuState( ID_VIEW_ANIMATIONDIALOG, MF_BYCOMMAND );
		if( state == 0xFFFFFFFF )
			return;

		pMenu->CheckMenuItem(ID_VIEW_ANIMATIONDIALOG, MF_UNCHECKED | MF_BYCOMMAND);
	}

	CDialog::OnClose();
}
Example #23
0
//Стандартный вызов ON_UPDATE_COMMAND_UI запрещает элементы меню, но не делает их grayed.
//Чтобы все таки запрещенные элементы меню выглядели как grayed, нужно вызывать эту функцию
//Note: эта функция не перерисовывает меню.
//Возвращает true - если произошли изменения и нужно перерисовать меню, иначе false
bool CMainFrame::_UpdateTopLevelMainMenu(void)
{
 CMenu* pMenu = this->GetMenu();
 std::vector<UINT> old_menu_state;

 //remember old states of all menu items
 {
  int menu_items_count = pMenu->GetMenuItemCount();
  for(int i = 0; i < menu_items_count; ++i)  
   old_menu_state.push_back(pMenu->GetMenuState(pMenu->GetMenuItemID(i),MF_BYCOMMAND));   
 }

 //Perform update
 CCmdUI ui;
 ui.m_nIndexMax = pMenu->GetMenuItemCount();
 ui.m_pMenu = pMenu;
 for (ui.m_nIndex = 0; ui.m_nIndex < ui.m_nIndexMax; ui.m_nIndex++) 
 {
  ui.m_nID = pMenu->GetMenuItemID(ui.m_nIndex);
  ui.DoUpdate(this, m_bAutoMenuEnable);
 }
 
 //Check: do we need to redraw menu?
 { 
  int menu_items_count = pMenu->GetMenuItemCount();
  for(int i = 0; i < menu_items_count; ++i)
  {
   UINT old_s = old_menu_state[i];
   UINT new_s = pMenu->GetMenuState(pMenu->GetMenuItemID(i),MF_BYCOMMAND);
   if (old_s!=new_s)   
    return true; //caller should redraw main menu   
  }
 }
 //nothing changed: redraw is not needed
 return false;
}
Example #24
0
void CLogViewDlg::DoEnableRegexCmd()
{
    CMenu* pPanelMenu = GetMenu()->GetSubMenu(3);

    BOOL bEnableRegex = !(pPanelMenu->GetMenuState(ID_OPTION_ENABLE_REGEX, MF_BYCOMMAND) & MF_CHECKED);
    pPanelMenu->CheckMenuItem(ID_OPTION_ENABLE_REGEX, MF_BYCOMMAND | (bEnableRegex ? MF_CHECKED : MF_UNCHECKED));
    SetDlgItemText(IDC_LABEL_TEXT_FILTER, bEnableRegex ? _T("Rege&x Filter:") : _T("Te&xt Filter:"));

    if(bEnableRegex && CConfig::GetConfig().IsWildcardEnabled())
    {
        CConfig::GetConfig().SetWildcardEnabled(!bEnableRegex);
        pPanelMenu->CheckMenuItem(ID_OPTION_ENABLE_WILDCARD, MF_BYCOMMAND | (!bEnableRegex ? MF_CHECKED : MF_UNCHECKED));
    }

    CConfig::GetConfig().SetRegexEnabled(bEnableRegex);
}
//**************************************************************************************
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 ());
		}
	}
}
//****************************************************************************************
HMENU CBCGPToolbarSystemMenuButton::CreateMenu () const
{
	ASSERT (m_hSystemMenu != NULL);

	HMENU hMenu = CBCGPToolbarMenuButton::CreateMenu ();
	if (hMenu == NULL)
	{
		return NULL;
	}

	//---------------------------------------------------------------------
	// System menu don't produce updating command statuses via the
	// standard MFC idle command targeting. So, we should enable/disable
	// system menu items according to the standard system menu status:
	//---------------------------------------------------------------------
	CMenu* pMenu = CMenu::FromHandle (hMenu);
	ASSERT_VALID (pMenu);

	CMenu* pSysMenu = CMenu::FromHandle (m_hSystemMenu);
	ASSERT_VALID (pSysMenu);

	int iCount = (int) pSysMenu->GetMenuItemCount ();
	for (int i = 0; i < iCount; i ++)
	{
		UINT uiState = pSysMenu->GetMenuState (i, MF_BYPOSITION);
		UINT uiCmd = pSysMenu->GetMenuItemID (i);

		if (uiState & MF_CHECKED)
		{
			pMenu->CheckMenuItem (uiCmd, MF_CHECKED);
		}

		if (uiState & MF_DISABLED)
		{
			pMenu->EnableMenuItem (uiCmd, MF_DISABLED);
		}

		if (uiState & MF_GRAYED)
		{
			pMenu->EnableMenuItem (uiCmd, MF_GRAYED);
		}
	}

	return hMenu;
}
BOOL CRevisionGraphDlg::ToggleOption (UINT controlID)
{
	// check request for validity

	if (m_Graph.IsUpdateJobRunning())
	{
		// restore previous state

		int state = m_ToolBar.GetToolBarCtrl().GetState(controlID);
		if (state & TBSTATE_CHECKED)
			state &= ~TBSTATE_CHECKED;
		else
			state |= TBSTATE_CHECKED;
		m_ToolBar.GetToolBarCtrl().SetState (controlID, state);

		return FALSE;
	}

	CMenu * pMenu = GetMenu();
	if (pMenu == NULL)
		return FALSE;

	// actually toggle the option

	int tbstate = m_ToolBar.GetToolBarCtrl().GetState(controlID);
	UINT state = pMenu->GetMenuState(controlID, MF_BYCOMMAND);
	if (state & MF_CHECKED)
	{
		pMenu->CheckMenuItem(controlID, MF_BYCOMMAND | MF_UNCHECKED);
		m_ToolBar.GetToolBarCtrl().SetState(controlID, tbstate & (~TBSTATE_CHECKED));
	}
	else
	{
		pMenu->CheckMenuItem(controlID, MF_BYCOMMAND | MF_CHECKED);
		m_ToolBar.GetToolBarCtrl().SetState(controlID, tbstate | TBSTATE_CHECKED);
	}

//	CSyncPointer<CAllRevisionGraphOptions>
//		options (m_Graph.m_state.GetOptions());
//	if (((state & MF_CHECKED) != 0) == options->IsSelected (controlID))
//		options->ToggleSelection (controlID);

	return TRUE;
}
Example #28
0
void CClientDlg::OnBnClickedCheck1()
{
	CMenu* pMenu = GetMenu();

	if(pMenu)
	{
		UINT state = pMenu->GetMenuState(ID_OPTIONS_DBCLICK, MF_BYCOMMAND);
		if(state == 0xFFFFFFFF)
			return;

		if (state & MF_CHECKED)
		{
			pMenu->CheckMenuItem(ID_OPTIONS_DBCLICK, MF_UNCHECKED | MF_BYCOMMAND);
		}
		else
		{
			pMenu->CheckMenuItem(ID_OPTIONS_DBCLICK, MF_CHECKED | MF_BYCOMMAND);
		}

	}
}
Example #29
0
void CClientDlg::OnBnClickedButton4()
{
	CMenu* pMenu = GetMenu();
	BOOL isCheck;
	if(pMenu)
	{
		UINT state = pMenu->GetMenuState(ID_OPTIONS_DELLFILE, MF_BYCOMMAND);
		if(state == 0xFFFFFFFF)
			return;

		if (state & MF_CHECKED)
			isCheck=true;
		else
			isCheck=false;
	}

	m_TextWinList1.SetCurSel(-1);
	{
		m_pClient->RequestWinShot( 0 ,isCheck );
		Log( L"Getting screenshot of [%08X]...", 0 );
	}
}
Example #30
0
void CClientDlg::OnOptionsFulllistofwindows()
{
	CMenu* pMenu = GetMenu();

	if(pMenu)
	{
		UINT state = pMenu->GetMenuState(ID_OPTIONS_FULLLISTOFWINDOWS, MF_BYCOMMAND);
		if(state == 0xFFFFFFFF)
			return;

		if (state & MF_CHECKED)
		{
			pMenu->CheckMenuItem(ID_OPTIONS_FULLLISTOFWINDOWS, MF_UNCHECKED | MF_BYCOMMAND);
			m_pClient->RequestWinCmd(NULL, PK_SC_SHOWALLWINDOWS);
		}
		else
		{
			pMenu->CheckMenuItem(ID_OPTIONS_FULLLISTOFWINDOWS, MF_CHECKED | MF_BYCOMMAND);
			m_pClient->RequestWinCmd(NULL, PK_SC_SHOWALLWINDOWS);
		}

	}
}