Print Page | Close Window

[solved]wrong serialization in CXTPControlComboBox

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=23508
Printed Date: 26 April 2024 at 10:14am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [solved]wrong serialization in CXTPControlComboBox
Posted By: lrenoux
Subject: [solved]wrong serialization in CXTPControlComboBox
Date Posted: 28 November 2017 at 4:29am
In save mode (schema _XTP_SCHEMA_1700), the code below is wrong, "Width" will always be saved with 0.

void CXTPControlComboBox::DoPropExchange(CXTPPropExchange* pPX)
{
CXTPControlPopup::DoPropExchange(pPX);

PX_Bool(pPX, _T("DropDown"), m_bDropDown, TRUE);

// The Width property is already serialized in CXTPControl
// so in order to avoid double DPI scaling it must not be read twice (ticket 35575),
// however the value still must be read out to provide format backward compatibility (ticket 36079).
int nUnusedWidth = 0;
PX_DPI_X_Int(pPX, _T("Width"), nUnusedWidth, 0);
UNUSED(nUnusedWidth);

Introduced in version 18.2. I don't understand the comment.


L.



Replies:
Posted By: jis
Date Posted: 05 December 2017 at 11:03am
We have seen a similar issue with 18.2.0 where ComboBoxes have almost no width.


Posted By: jis
Date Posted: 06 December 2017 at 8:04am
Ive done some, and it seems that if we do not load commandbars on launch, then the CXTPControlComboBox have a width that normal.
But when we load the commandbars the CXTPControlComboBox have a width of 0.
It looks like all combos in the XML file look like this:

<Control Class="CXTPControlComboBox" Type="5" Id="7005" HideFlags="128" TooltipText="Control Text" Width="0" Height="0" CommandBarId="16777260" DropDown="0"/>
while in 16.4 of CodeJock this combobox would have Width="128".

Possibly related to: http://forum.codejock.com/forum_posts.asp?TID=23508&KW=ComboBox&title=1820-wrong-serialization-in-cxtpcontrolcombobox" rel="nofollow - http://forum.codejock.com/forum_posts.asp?TID=23508&KW=ComboBox&title=1820-wrong-serialization-in-cxtpcontrolcombobox ?


Posted By: mschumi
Date Posted: 06 December 2017 at 12:01pm
Hi Codejock Team,

the width related code in
void CXTPControlComboBox::DoPropExchange(CXTPPropExchange* pPX)
{
    CXTPControlPopup::DoPropExchange(pPX);

    PX_Bool(pPX, _T("DropDown"), m_bDropDown, TRUE);

    // The Width property is already serialized in CXTPControl
    // so in order to avoid double DPI scaling it must not be read twice (ticket 35575),
    // however the value still must be read out to provide format backward compatibility (ticket 36079).
    int nUnusedWidth = 0;
    PX_DPI_X_Int(pPX, _T("Width"), nUnusedWidth, 0);
    UNUSED(nUnusedWidth);
    ...

is not correct, once again.
In XTP1700
PX_DPI_X_Int(pPX, _T("Width"), m_nWidth, 0) was called twice; the two writes did no harm but the two reads somehow changed the member in case of HighDPI (when XTP_DPI_X returns a modified value)

In XTP1801
PX_DPI_X_Int(pPX, _T("Width"), m_nWidth, 0) was called only once (in the base class) and for us, everything was fine (serializing to XML)

In XTP1820
- PX_DPI_X_Int(pPX, _T("Width"), m_nWidth, 0) is called in the base class
- PX_DPI_X_Int(pPX, _T("Width"), nUnusedWidth, 0) is called again in CXTPControlComboBox::DoPropExchange
Now writing is buggy:
- the base class (CXTPControl) writes e.g. Width=150 into xml
- the derived class (CXTPControlComboBox) writes Width=0 into xml and... gone is the 150

My guess is the code in the derived class should only be called in the read case (IsLoading=true)

I would appreciate it very much if the bug was fixed in the next version.

Thank you and best regards,
Michael


Posted By: olebed
Date Posted: 08 December 2017 at 3:15pm
Hello,

We fixed this with
    int nUnusedWidth = m_nWidth;
    PX_DPI_X_Int(pPX, _T("Width"), nUnusedWidth, 0);

Regards,
 Oleksandr Lebed



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