Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Controls
  New Posts New Posts RSS Feed - [SOVLED] Bug in CXTPListbox in v16.3.1
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[SOVLED] Bug in CXTPListbox in v16.3.1

 Post Reply Post Reply
Author
Message
pjna View Drop Down
Newbie
Newbie


Joined: 30 January 2014
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote pjna Quote  Post ReplyReply Direct Link To This Post Topic: [SOVLED] Bug in CXTPListbox in v16.3.1
    Posted: 04 June 2014 at 9:50am
I believe I have discovered a bug in the list box control which was not present in the previous version I have been using of the CodeJock library.

To reproduce the bug you can use the built in sample "MarkupSample".

Modify the CMarkupSampleDlg::OnInitDialog function to hook up an OnClick handler and add a button to the markup list box as follows:

        .
        .
        .
     if (m_wndTabControl.GetCurSel() == 0)
     {
          AddListItem(_T("<Border BorderThickness='2' BorderBrush='DodgerBlue' Margin='2' Padding='3'><StackPanel Orientation='Horizontal'>")
               _T("<Border Width='32' Height='32'/>")
               _T("<Grid><Grid.ColumnDefinitions><ColumnDefinition Width='Auto'/><ColumnDefinition Width='*'/></Grid.ColumnDefinitions>")
               _T("<Grid.RowDefinitions><RowDefinition/><RowDefinition/></Grid.RowDefinitions>")
               _T("<TextBlock TextAlignment='Right' FontWeight='Bold' Foreground='Navy' Text='Description:'/>")
               _T("<TextBlock TextAlignment='Right' Grid.Row='1' FontWeight='Bold' Foreground='Navy' Text='Current Price:'/>")
               _T("<TextBlock Margin='6, 0, 0, 0' Grid.Column='1' Text='Digital camera'> <Hyperlink Tag='camera'>Link</Hyperlink></TextBlock>")
               _T("<TextBlock Margin='6, 0, 0, 0' Grid.Column='1' Grid.Row='1' Text='$321'/>")
       //PJ
        _T("<Button Name='Button1' Margin='2' Cursor='Hand'><TextBlock>Button Test</TextBlock></Button>")
        //PJ
               _T("</Grid></StackPanel></Border>"));
     .
        .
        .


     // Add handlers for hyperlinks
     m_wndStatic.GetMarkupContext()->AddHandler(CXTPMarkupButton::m_pClickEvent, CreateMarkupClassDelegate(this, &CMarkupSampleDlg::OnHyperlinkClick));
     m_wndRadio.GetMarkupContext()->AddHandler(CXTPMarkupHyperlink::m_pClickEvent, CreateMarkupClassDelegate(this, &CMarkupSampleDlg::OnHyperlinkClick));
     m_wndCheckBox.GetMarkupContext()->AddHandler(CXTPMarkupHyperlink::m_pClickEvent, CreateMarkupClassDelegate(this, &CMarkupSampleDlg::OnHyperlinkClick));
//PJ
     //m_wndList.GetMarkupContext()->AddHandler(CXTPMarkupHyperlink::m_pClickEvent, CreateMarkupClassDelegate(this, &CMarkupSampleDlg::OnHyperlinkClick));
     m_wndList.GetMarkupContext()->AddHandler(CXTPMarkupButton::m_pClickEvent, CreateMarkupClassDelegate(this, &CMarkupSampleDlg::OnHyperlinkClick));
//PJ
        .
        .
        .



What you will observe when you run the sample is that the cursor does not change to the hand icon when you hover over the button in the markup list box. In addition the OnClick handler is never called when you attempt to click on the button in the markup list box. I have confirmed that by making the same changes to MarkupSample in Xtreme ToolkitPro v16.2.3 which I also have installed locally that the problem does not occur.

Tracing through the code I believe I have found the bug occurs because of changes introduced in CXTPListBox in v16.3.1 through the introduction of this new
method:

BOOL CXTPListBox::TryItemFromPoint(CPoint pt, BOOL& bOutside, int& nIndex) const
{
     BOOL bFound = FALSE;
     int nCount = GetCount();
     if (0 < nCount)
     {
          nIndex = ItemFromPoint(pt, bOutside);
          if (!(0 <= nIndex && nIndex < nCount))
          {
               nIndex = -1;
          }
     }
     else
     {
          nIndex = -1;
     }

     return bFound;
}


The variable "bFound" is never used in this method meaning that the function always returns FALSE which means that CXTPListBox::OnMouseMove effectively does nothing:

void CXTPListBox::OnMouseMove(UINT nFlags, CPoint point)
{
     CListBox::OnMouseMove(nFlags, point);
/*
     if (m_nStyle != xtpListBoxOffice2007)
          return;
*/
     BOOL bOutside = FALSE;
     int nHotItem = 0;
//PJ The following chunk of code will never execute in v16.3.1 because of a bug in TryItemFromPoint
     if (TryItemFromPoint(point, bOutside, nHotItem))
     {
          if (bOutside) nHotItem = -1;

          if (nHotItem != m_nHotItem)
          {
               m_nHotItem = nHotItem;
               Invalidate(FALSE);

               if (m_nHotItem != -1)
               {
                    TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT), TME_LEAVE, m_hWnd, HOVER_DEFAULT };
                    _TrackMouseEvent(&tme);
               }
          }
     }
}


I believe the fix should be to modify TryItemFromPoint as follows:

BOOL CXTPListBox::TryItemFromPoint(CPoint pt, BOOL& bOutside, int& nIndex) const
{
     BOOL bFound = FALSE;
     int nCount = GetCount();
     if (0 < nCount)
     {
          nIndex = ItemFromPoint(pt, bOutside);
          if (!(0 <= nIndex && nIndex < nCount))
          {
               nIndex = -1;
          }
     }
     else
     {
          nIndex = -1;
     }

//BUG BUG Bug fix by PJ
bFound = (nIndex != -1);
     return bFound;
}

I would appreciate you confirming that this is an real issue in v16.3.1, if my temporary fix is correct and also when there will be an official fix for this?

PJ Naughter
Back to Top
sdancer75 View Drop Down
Groupie
Groupie
Avatar

Joined: 08 July 2008
Location: Greece
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote sdancer75 Quote  Post ReplyReply Direct Link To This Post Posted: 10 October 2014 at 4:06am
Hi,

m_wndList.GetMarkupContext()->AddHandler(CXTPMarkupButton::m_pClickEvent, CreateMarkupClassDelegate(this, &CMarkupSampleDlg::OnHyperlinkClick));

The CXTPMarkupListBox does not support the GetMarkupContect(), so how the heck did you compiled the sample and you found a bug ?

Regards,

Just me!
Back to Top
mcmastl View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 April 2015
Status: Offline
Points: 79
Post Options Post Options   Thanks (0) Thanks(0)   Quote mcmastl Quote  Post ReplyReply Direct Link To This Post Posted: 16 April 2015 at 1:03pm
Hello and thank you for letting us know of this issue.  We have brought this up to the development team and will be looking into it.  If this issue has been resolved please let us know.
Luke McMasters, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
agontarenko View Drop Down
Admin Group
Admin Group


Joined: 25 March 2016
Status: Offline
Points: 291
Post Options Post Options   Thanks (0) Thanks(0)   Quote agontarenko Quote  Post ReplyReply Direct Link To This Post Posted: 21 June 2016 at 4:33am
Hello, I'm glad to inform you that the issue has been addressed and fixed. The fix is already available in current version.
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.125 seconds.