Print Page | Close Window

Find ptr to CXTPControlCheckbox on check event?

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=10927
Printed Date: 15 November 2025 at 4:23am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Find ptr to CXTPControlCheckbox on check event?
Posted By: ibmldev
Subject: Find ptr to CXTPControlCheckbox on check event?
Date Posted: 05 June 2008 at 7:01pm
A group in a tab my ribbon bar has several controls (checkbox, button, edit box with spin ctrls, etc.). Several copies of this group are in the same tab, and the IDs of the controls are also duplicated in each group.

For example, perhaps ID_CHECKBOX = 500, ID_BUTTON = 501, ID_EDITBOX = 502, and so on. So, if there are 3 groups, there are ID_CHECKBOX, ID_BUTTON, and ID_EDITBOX in the first group, and in the second group, and in the third group.

When a control sends an event (button click, check state change, spin edit change), I need to be able to tell which group the control is in. Obviously it isn't enough to know the ID, since the ID is the same in each group. For the edit box, I can catch the notify message NMXTPUPDOWN, which has a pointer to the CXTPControlEdit sending the message. That's great, but it seems to be the only case where such a lucky message occurs. I can't even use a similar mechanism if the text is edited with the keyboard--only when the spin controls are used.

Unfortunately, there isn't such a notify for button click or check state change, is there? The most I can do is to get an event with the ID, which isn't enough, since there are several controls with this same ID, one in each group.

I don't even know how to get a check state change event--right now, I am just handling ON_COMMAND( ID_CHECKBOX, OnCheckBox ) to know that something happened to the checkbox, and that doesn't pass any other information at all (there are no arguments in the handler). I can't even tell what the state of the control is--I just blindly toggle my notion of its state each time, hoping I'm matched up. This just doesn't seem right. Isn't there an event that tells that the state actually changed to?

I don't really want to reserve a huge range of control IDs for the possibility of some large number of groups duplicating these controls, and I don't know ahead of time how many there will be (they can be added or removed by the user).

Is there a way to find the group containing the control? At present we are using GetHighlightedGroup(), but that seems very bad.

Finally, is there a way to get a pointer to a CXTPControl if I know the control's HWND ? I'm really at a loss here...



Replies:
Posted By: Oleg
Date Posted: 06 June 2008 at 12:52am
Hi,
 
Controls always send both WM_COMMAND and WM_XTP_EXECUTE. So you can use second to find out what control was executed:
 
 
 ON_XTP_EXECUTE(ID_COMBO_DATE, OnComboDate)
 
void CMainFrame::OnComboDate(NMHDR* pNMHDR, LRESULT* pResult)
{
 NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)pNMHDR;
 CControlComboBoxDatePicker* pControl = DYNAMIC_DOWNCAST(CControlComboBoxDatePicker, tagNMCONTROL->pControl);
 if (pControl)
 {
  pGroup = pControl->GetRibbonGroup();
  etc;
 }
}


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


Posted By: ibmldev
Date Posted: 06 June 2008 at 10:12am
Oleg,

  Perfect! Thanks very much for your help!




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