<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>Codejock Developer Community : Crash in CXTPPaintManager::DrawControl()</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Toolkit Pro : Crash in CXTPPaintManager::DrawControl()]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Sun, 12 Apr 2026 13:39:40 +0000</pubDate>
  <lastBuildDate>Tue, 25 Aug 2009 05:39:19 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.04</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>forum.codejock.com/RSS_post_feed.asp?TID=15036</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Codejock Developer Community]]></title>
   <url>http://forum.codejock.com/forum_images/codejock-logo.gif</url>
   <link>http://forum.codejock.com/</link>
  </image>
  <item>
   <title><![CDATA[Crash in CXTPPaintManager::DrawControl() : Hi I guess problem somewhere...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=15036&amp;PID=52357&amp;title=crash-in-cxtppaintmanagerdrawcontrol#52357</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=6851">Oleg</a><br /><strong>Subject:</strong> 15036<br /><strong>Posted:</strong> 25 August 2009 at 5:39am<br /><br /><P>Hi</P><DIV>I guess problem somewhere else in your code. Maybe you store some pointer to some control and call it after you&nbsp;removed it and it not valid anymore.</DIV>]]>
   </description>
   <pubDate>Tue, 25 Aug 2009 05:39:19 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=15036&amp;PID=52357&amp;title=crash-in-cxtppaintmanagerdrawcontrol#52357</guid>
  </item> 
  <item>
   <title><![CDATA[Crash in CXTPPaintManager::DrawControl() : My application crashes when dereferencing...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=15036&amp;PID=52344&amp;title=crash-in-cxtppaintmanagerdrawcontrol#52344</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=5490">jasonaross</a><br /><strong>Subject:</strong> 15036<br /><strong>Posted:</strong> 24 August 2009 at 2:45pm<br /><br /><P>My application <FONT face=Calibri>crashes when dereferencing a null pointer within DrawControl. Any ideas on whether this is a codejock issue or something i can prevent? My application has framework that can load different dlls/components dependent on the user action. As different components are loaded, we remove controls in the CXTPMenu bar and add some back.</FONT> </P><FONT face=Calibri><P>CXTPPaintManager::DrawControl(CDC* pDC, CXTPControl* pButton, BOOL bDraw)</P><P>…</P><P>return (pButton-&gt;GetParent()-&gt;GetType() == xtpBarTypePopup)? //crashes when getting the type for the parent of the button</P><P>DrawControlPopupParent(pDC, pButton, bDraw): DrawControlToolBarParent(pDC, pButton, bDraw);</P><P>Rewritten..</P><P>CXTPCommandBar* pjCXTPCommandBar = pButton-&gt;GetParent();</P><P>XTPBarType aXTPBarType = pjCXTPCommandBar-&gt;GetType(); //crashes here as pjCXTPCommandBar is NULL</P><P>return (aXTPBarType == xtpBarTypePopup)?</P><P>DrawControlPopupParent(pDC, pButton, bDraw): DrawControlToolBarParent(pDC, pButton, bDraw);</P><P>CXTPControl::Draw(</P><P>CXTPCommandBar::DrawCommandBar(</P><P>CXTPCommandBar::OnPaint() </P><P>CXTPCommandBar::OnWndMsg(</P><P>CXTPCommandBar::DrawCommandBar(</P><P>CXTPCommandBar::OnPaint() </P><P>CXTPCommandBar::OnWndMsg(</P><P>CWnd::UpdateWindow() </P><P>CXTPPopupBar::SetTrackingMode(int 0, int 1, int 0) </P><P>CXTPCommandBar::OnDestroy() </P><P>CXTPCommandBar::OnWndMsg(</P><P>CXTPHookManager::HookWndProc(</P><P>CXTPCommandBar::OnFinalRelease() </P><P>CXTPControlPopup::~CXTPControlPopup() </P><P>CXTPControlPopup::`vector deleting destructor'(</P><P>CXTPControls::RemoveAll() </P></FONT><P>CEnhancedMenuController::AddComponentMenu //from my app </P><P>It seems the CXTPControl objects' parent is set to null within CXTPControls::RemoveAll().</P><P>void CXTPControls::RemoveAll(void)</P><P>{</P><P>for (int nIndex = 0; nIndex &lt; GetCount(); nIndex++)</P><P>{</P><P>CXTPControl* pControl = m_arrControls.GetAt(nIndex);</P><P>pControl-&gt;m_pControls = NULL;</P><P>//pControl-&gt;m_pParent = NULL; commenting out this line prevents the crash</P><P>pControl-&gt;InternalRelease();</P><P>}</P><P>m_arrControls.RemoveAll();</P><P>}</P><P>------------------ </P><P>void CEnhancedMenuController::AddComponentMenu(long hMenu)<BR>{<BR>componentCommandIds.RemoveAll();<BR>CString menuString;<BR>try<BR>{<BR>CPVFrame* ownerFrame = dynamic_cast&lt;CPVFrame*&gt; (m_ownerWnd);<BR>if (ownerFrame == NULL)<BR>{<BR>MsgWriteF (MSG_DEFAULT, eMsgLog_Commit, _T("PVAPP"), eMsgLvl_Info, _T("CEnhancedMenuController::AddComponentMenu cast of m_ownerWnd to PVFrame* returned NULL"));<BR>return;<BR>}<BR>CXTPCommandBars *pCommandBars = ownerFrame-&gt;GetCommandBars();<BR><BR>//The codejock menu bar<BR>CXTPMenuBar* pMenuBar = static_cast&lt;CXTPMenuBar*&gt; (pCommandBars-&gt;GetMenuBar());<BR>//CMenu we build first<BR>CMenu* pMenu = NULL;<BR>if (m_hFrameworkMenu == NULL)<BR>{<BR>pMenu = new CMenu();<BR>pMenu-&gt;CreateMenu();<BR>m_hFrameworkMenu = pMenu-&gt;m_hMenu;<BR>}<BR>else<BR>{<BR>pMenu = CMenu::FromHandle(m_hFrameworkMenu);<BR>for (int i = pMenu-&gt;GetMenuItemCount() - 1; i &gt;= 0; i--)<BR>{<BR>pMenu-&gt;RemoveMenu(i, MF_BYPOSITION);<BR>}<BR>}<BR><BR>//remove anything currently in the array<BR>CleanUpMenuArray(); </P><P>CXTPControls* curControls = pMenuBar-&gt;GetControls();<BR>curControls-&gt;RemoveAll(); //sets off the crash </P><P>----------- </P><P>Thanks in advance! </P>]]>
   </description>
   <pubDate>Mon, 24 Aug 2009 14:45:41 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=15036&amp;PID=52344&amp;title=crash-in-cxtppaintmanagerdrawcontrol#52344</guid>
  </item> 
 </channel>
</rss>