Print Page | Close Window

[SOLVED]Access viloation on CXTPControlGallery

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=22811
Printed Date: 04 May 2024 at 3:24pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [SOLVED]Access viloation on CXTPControlGallery
Posted By: jhlee.8804
Subject: [SOLVED]Access viloation on CXTPControlGallery
Date Posted: 07 December 2015 at 10:34am
Hi, I have found a some error when set true to CXTPControlGallery::SetScrollBarAuto.

Here is sample code. (Used in "Codejock/Sample/Ribbon/RibbonControls/MainFrm.cpp")


// Create Inline Gallery
if (pTabGallery)
{
  CXTPRibbonGroup* pGroup = pTabGallery->AddGroup(ID_GROUP_INLINE);
  pGroup->SetControlsCentering(TRUE);

  CXTPControlGallery* pControlGallery = new CXTPControlGallery();
  pControlGallery->SetControlSize(CSize(192, 60));
  pControlGallery->ShowLabels(FALSE);
  pControlGallery->ShowScrollBar(TRUE);
  pControlGallery->ShowBorders(TRUE);
  pControlGallery->SetItems(m_pItemsFontTextColor);
  pControlGallery->SetScrollBarAuto(TRUE);       <<<<<<<<<< I just added one line code !!!
  pGroup->Add(pControlGallery, ID_GALLERY_STYLES);
  
  ...
}


// Now ScreenShot
Just only one item displayed and occurred Access Violation error when mouse move on gallery control.


// To-be ScreenShot



// CallStack






// Stange Codes
I think below codes are strange...

void CXTPControlGallery::RepositionCore(BOOL bCheckScroll)
{
CRect rcItems = GetItemsRect();

int x = rcItems.left;
int y = rcItems.top;
BOOL bFirstItem = TRUE;

int nCount = GetItemCount();

    // if item count is 10, m_arrRects will be set size too
m_arrRects.SetSize(nCount);
int nRowHeight = 0;

for (int i = 0 ; i < nCount; i++)
{
CXTPControlGalleryItem* pItem = GetItem(i);
m_arrRects.pItem = pItem;
m_arrRects.bBeginRow = FALSE;

if (pItem->IsLabel())
{
...
}
else
{
...
}
    // but breaked when i == 5 ...
    // m_arrRects[6] ~ m_arrRects[9] are will be null pointer!!!
if (bCheckScroll && y + nRowHeight + rcItems.top > rcItems.Height())
{
break;
}
}

y += nRowHeight;

m_nTotalHeight = y - rcItems.top;
}




Thanks.



Replies:
Posted By: agontarenko
Date Posted: 22 July 2016 at 9:25am
Hello,

I'm glad to inform you that the issue has been fixed. The fix will be available in the next beta or final release.
(svn revision 17840)

Regards,
Artem Gontarenko



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