Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Controls
  New Posts New Posts RSS Feed - BUG: XTPMarkupStatic unusable
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

BUG: XTPMarkupStatic unusable

 Post Reply Post Reply
Author
Message
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1201
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Topic: BUG: XTPMarkupStatic unusable
    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!
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post 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).
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1201
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
jimmy View Drop Down
Senior Member
Senior Member


Joined: 11 November 2003
Location: Austria
Status: Offline
Points: 515
Post Options Post Options   Thanks (0) Thanks(0)   Quote jimmy Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 10 January 2012 at 11:19am
What if they want to display %s?
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1201
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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
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.140 seconds.