![]() |
Find ptr to CXTPControlCheckbox on check event? |
Post Reply
|
| Author | |
ibmldev
Groupie
Joined: 17 October 2006 Status: Offline Points: 19 |
Post Options
Thanks(0)
Quote Reply
Topic: Find ptr to CXTPControlCheckbox on check event?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... ![]() |
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
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 |
|
![]() |
|
ibmldev
Groupie
Joined: 17 October 2006 Status: Offline Points: 19 |
Post Options
Thanks(0)
Quote Reply
Posted: 06 June 2008 at 10:12am |
|
Oleg,
Perfect! Thanks very much for your help! |
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |