Print Page | Close Window

BUG: XTPMarkupStatic unusable

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=19317
Printed Date: 17 November 2024 at 2:32am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: BUG: XTPMarkupStatic unusable
Posted By: mgampi
Subject: BUG: XTPMarkupStatic unusable
Date Posted: 15 December 2011 at 3:12pm
Hi;

Since v15.2.1 the CTPMarkupStatic control is unusable if the markup text contains a % (percent) sign.
I found no breaking change news in readme of this version about this kind of annoying error. This code change required several working hours to be located and fixed by creating our own control!!!!
Taken a look at the code change I found out that the % sign is used as a splitter for caption/text combination.

Old code:
void CXTPMarkupStatic::SetMarkupText(LPCTSTR lpszMarkup)
{
    MARKUP_RELEASE(m_pUIElement);

    m_pUIElement = Parse(lpszMarkup);

    if (m_hWnd) Invalidate(FALSE);
}

New code:
void CXTPMarkupStatic::SetMarkupText(LPCTSTR lpszMarkup)
{
    MARKUP_RELEASE(m_pUIElement);

    if (lpszMarkup && _tcschr(lpszMarkup, _T('%')) != NULL)
    {
        CString strCaption;
        GetWindowText(strCaption);

        CString strMarkup;
        strMarkup.Format(lpszMarkup, (LPCTSTR)strCaption);  <-- This crashes (ACCVIO)

        m_pUIElement = m_pMarkupContext->Parse(strMarkup);
    }
    else
    {
        m_pUIElement = m_pMarkupContext->Parse(lpszMarkup);
    }

    if (m_hWnd) Invalidate(FALSE);
}


To CJ: It would be better to create a new function "SetMarkupTextEx" to extend the functionalities for your needs.
In any case, if you leave the code as is, the control is unusable in real world applications!



Replies:
Posted By: SuperMario
Date Posted: 09 January 2012 at 12:19pm
For next release we did as you suggested and reverted SetMarkupText and added SetMarkupTextEx for the ribbon (note if you used this in backstage you now need to update the code).


Posted By: mgampi
Date Posted: 09 January 2012 at 7:31pm
Sounds good!

Thanks


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022


Posted By: jimmy
Date Posted: 10 January 2012 at 4:13am
Hello,

i think, that the correct way is to check for %s not only for %.
or check direct for lpszMarkup == "%s" or using strstr(..., "%s" )

 Jimmy


Posted By: SuperMario
Date Posted: 10 January 2012 at 11:19am
What if they want to display %s?


Posted By: mgampi
Date Posted: 10 January 2012 at 11:25am
Hi;

IMHO the string passed to SetMarkupText() should not contain any string formatting code (e.g. %f, %s, %ld, ...)! It should be plain XAML - and nothing else.


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022



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