Print Page | Close Window

ribbon group withmutually exclusive buttons?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=4704
Printed Date: 10 November 2025 at 10:21pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: ribbon group withmutually exclusive buttons?
Posted By: andujar
Subject: ribbon group withmutually exclusive buttons?
Date Posted: 02 August 2006 at 8:01pm

We are developing an application with a ribbon and have multiple control buttons in a group and would like the behavior of the buttons in this group to be mutually exclusive.

So, we are trying to create a scenario where:
 One button will always be checked
 Clicking on one button unchecks the currently checked button and checks the button just clicked
 And therefore, no two buttons can be checked at the same time
 
Here is how we create the group:

 CXTPRibbonGroup* pDirectoriesGroup = pTabMain->AddGroup(ID_GROUP_DIRECTORIES);
 pDirectoriesGroup->Add(xtpControlButton, ID_Directories_C_DRIVE);
 pDirectoriesGroup->Add(xtpControlButton, ID_Directories_D_DRIVE);
 pDirectoriesGroup->Add(xtpControlButton, ID_Directories_E_DRIVE);

We also have message handlers to initiate actions on button push and to check/uncheck each button individually (as in ribbonsample):

 ON_UPDATE_COMMAND_UI_RANGE(ID_Directories_C_DRIVE, ID_Directories_E_DRIVE, OnUpdateDirectories)
 ON_COMMAND_RANGE(ID_Directories_D_DRIVE, ID_Directories_E_DRIVE,OnDirectories)

Any thoughts on the code we can replace ours with to create the behavior above?

Thanks




Replies:
Posted By: Oleg
Date Posted: 02 August 2006 at 9:25pm
Hello,
 
Something like this:
 
 
ON_UPDATE_COMMAND_UI_RANGE(ID_Directories_C_DRIVE, ID_Directories_E_DRIVE, OnUpdateDirectories)
 ON_COMMAND_RANGE(ID_Directories_D_DRIVE, ID_Directories_E_DRIVE,OnDirectories)
 
CMainFrame::CMainFrame()
{
 m_nDirectory = ID_Directories_C_DRIVE;
}

void CMainFrame::OnDirectories(UINT nID)
{
 m_nDirectory = nID;
}
 
void CMDIChildWndEx::OnUpdateDirectories(CCmdUI* pCmdUI)
{
 pCmdUI->SetCheck(pCmdUI->m_nID == m_nDirectory ? 1 : 0);
}


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: andujar
Date Posted: 02 August 2006 at 9:46pm
Perfect.  Thank you very much, Oleg.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net