Print Page | Close Window

[Solved] CXTPMarkupListBox crashes on empty list

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=23947
Printed Date: 21 November 2024 at 12:53pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [Solved] CXTPMarkupListBox crashes on empty list
Posted By: sdancer75
Subject: [Solved] CXTPMarkupListBox crashes on empty list
Date 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!



Replies:
Posted By: Fredrik
Date 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


Posted By: sdancer75
Date 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!



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