Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - CXTPControlComboBox shallow copy bug
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPControlComboBox shallow copy bug

 Post Reply Post Reply
rhfritz View Drop Down

Joined: 19 September 2014
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote rhfritz Quote  Post ReplyReply Direct Link To This Post Topic: CXTPControlComboBox shallow copy bug
    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.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

This page was generated in 0.078 seconds.