Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Controls
  New Posts New Posts RSS Feed - [Solved]  CXTPMarkupListBox crashes on empty list
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[Solved] CXTPMarkupListBox crashes on empty list

 Post Reply Post Reply
Author
Message
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 Topic: [Solved] CXTPMarkupListBox crashes on empty list
    Posted: 28 January 2020 at 3:49am
Version : 15.x 16.x and maybe newer versions

Symptoms : CXTPMarkupListBox and CXTPListBox crashes when the list box is empty and move mouse inside its client area.

Problem
Inside  void CXTPListBox::OnMouseMove(UINT nFlags, CPoint point)
the MFC function ItemFromPoint() returns a WORD (not signed) value of 65535 which means invalid or empty list. This value is returned to nHotItem.

int nHotItem = ItemFromPoint(point, bOutside) 

The signed int nHotItem is now 4 bytes so instead of converting the non signed word 65535 to -1, it remains 65535. After this, the code is calling 

BOOL CXTPMarkupListBox::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult) 

which in turn is calling an invalid item in  code below.

XTP_MARKUP_LISTITEM *pItem = reinterpret_cast<XTP_MARKUP_LISTITEM*>(GetItemDataPtr(m_nHotItem));

At this point the code crashes.

Solution

Inside void CXTPListBox::OnMouseMove(UINT nFlags, CPoint point)

declare nHotItem as short int instead of an int like below. 

short int nHotItem = ItemFromPoint(point, bOutside) 

Recompile all codejock libs and rebuild your project.
Just me!
Back to Top
Fredrik View Drop Down
Senior Member
Senior Member


Joined: 22 June 2005
Status: Offline
Points: 226
Post Options Post Options   Thanks (0) Thanks(0)   Quote Fredrik Quote  Post ReplyReply Direct Link To This Post Posted: 03 February 2020 at 12:23pm
Just looked at the code in version 18.x and 19 it's fixed there.
Windows 10, Visual Studio 20157, Toolkit Pro 18.3.0
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: 03 February 2020 at 2:44pm
Originally posted by Fredrik Fredrik wrote:

Just looked at the code in version 18.x and 19 it's fixed there.


Thanks
Just me!
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.141 seconds.