CXTPControlComboBox shallow copy bug |
Post Reply |
Author | |
rhfritz
Groupie Joined: 19 September 2014 Status: Offline Points: 9 |
Post Options
Thanks(0)
Posted: 26 July 2019 at 7:00am |
I am adding a CXTPControlComboBox to a toolbar and getting a handle to it like this: pToolBarCombo = (CXTPControlComboBox*)GetControls()->Add(xtpControlComboBox, IDC_COMBO, 0, CAPTION_ADD_BEFORE); I then use the pointer to set attributes and add rows to the combo box. And most notably, I'm using SetItemData() to set the DWORD_PTR associated with each item to an internal data type I need to reference as each combo item is selected. However, when using the built-in mechanism allowing a user to add/remove buttons from the toolbar, I've noted that I can hide this combo box and restore it. However, upon restoring it, the combo text is all correct but the GetItemData() values are all NULL. I've noted that the control pointer value changes between the Add above and the subsequently retrieved value: CXTPControlComboBox *pToolBarCombo = (dynamic_cast<CXTPControlComboBox*>(CUtilXtreme::GetCommandBarControl(this, IDC_COMBO))); This implies that the object is being copied and removed from the toolbar and then restored, but it seems like a shallow rather than a deep copy was done. FWIW: I've verified that void CXTPControlComboBoxList::Copy(CXTPCommandBar* pCommandBar, BOOL bRecursive); does a deep copy. But that just means that whatever is preserving the ComboBox list for unhiding is likely not another ComboBox. But I have also discovered a workable solution: pToolBarCombo ->SetFlags(xtpFlagNoMovable); // Disables the ability to remove the combo during customization as it no longer appears on the buttons customization submenu displayed by Add/Remove. So for now I've mitigated the bad thing by preventing the user from performing the action causing it. Any insight or other recommendations appreciated.
|
|
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 |