Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Find ptr to CXTPControlCheckbox on check event?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Find ptr to CXTPControlCheckbox on check event?

 Post Reply Post Reply
Author
Message
ibmldev View Drop Down
Groupie
Groupie


Joined: 17 October 2006
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote ibmldev Quote  Post ReplyReply Direct Link To This Post 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...
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
ibmldev View Drop Down
Groupie
Groupie


Joined: 17 October 2006
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote ibmldev Quote  Post ReplyReply Direct Link To This Post Posted: 06 June 2008 at 10:12am
Oleg,

  Perfect! Thanks very much for your help!

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.