<?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 inside OnEndHook</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Skin Framework : Crash inside OnEndHook]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Mon, 25 May 2026 12:18:03 +0000</pubDate>
  <lastBuildDate>Wed, 21 Feb 2007 00:21:37 +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=6291</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 inside OnEndHook : Hello,   Use CriticalSection...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=6291&amp;PID=20604&amp;title=crash-inside-onendhook#20604</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=1756">SUNGGI</a><br /><strong>Subject:</strong> 6291<br /><strong>Posted:</strong> 21 February 2007 at 12:21am<br /><br />Hello, <DIV>&nbsp;</DIV><DIV>Use CriticalSection like this : </DIV><DIV>&nbsp;</DIV><DIV>Add CriticalSection in CXTPSkinObject Class</DIV><DIV><FONT color=#ff0000>static CCriticalSection CS_Skin;</FONT></DIV><DIV>&nbsp;</DIV><DIV>//////////////////////////////////////////////////////////</DIV><DIV>XTPSkinObject.cpp</DIV><DIV>//////////////////////////////////////////////////////////</DIV><DIV>CCriticalSection CXTPSkinObject::CS_Skin;</DIV><DIV><BR>void CXTPSkinObject::OnBeginHook(UINT nMessage, XTPSkinDefaultProc defProc, PROC defProcAddr, LPVOID defProcPrevWndFunc)<BR>{<BR><FONT color=#ff0000>&nbsp;CS_Skin.Lock();</FONT><BR>&nbsp;InternalAddRef();</DIV><DIV>&nbsp;DEFWINDOW_DESCRIPTIOR des;</DIV><DIV>&nbsp;des.defProc = defProc;<BR>&nbsp;des.nMessage = nMessage;<BR>&nbsp;des.defProcAddr = defProcAddr;<BR>&nbsp;des.lpPrev = defProcPrevWndFunc;</DIV><DIV>&nbsp;m_arrDescriptors.AddHead(des);<BR>&nbsp;<FONT color=#ff0000>CS_Skin.Unlock();</FONT><BR>}<BR>void CXTPSkinObject::OnEndHook()<BR>{<BR>&nbsp;<FONT color=#ff0000>CS_Skin.Lock();</FONT><BR>&nbsp;m_arrDescriptors.RemoveHead();<BR>&nbsp;InternalRelease();<BR>&nbsp;<FONT color=#ff0000>CS_Skin.Unlock();</FONT><BR>}</DIV><DIV>&nbsp;</DIV><DIV>////////////////////////////////////////////////////////////////</DIV><DIV>XTPSkinManagerApiHook.cpp</DIV><DIV>////////////////////////////////////////////////////////////////</DIV><DIV><BR>BOOL CXTPSkinManagerApiHook::CallHookDefWindowProc(HWND hWnd, PROC pfnOrig, XTPSkinDefaultProc defProc, LPVOID lpPrev, UINT nMessage, WPARAM&amp; wParam, LPARAM&amp; lParam, LRESULT&amp; lResult)<BR>{<BR>&nbsp;if (!XTPSkinManager()-&gt;IsEnabled())<BR>&nbsp;&nbsp;return FALSE;</DIV><DIV>&nbsp;CXTPSkinObject* pSkinObject = XTPSkinManager()-&gt;Lookup(hWnd);</DIV><DIV>&nbsp;if (!pSkinObject || pSkinObject-&gt;m_bCustomDraw)<BR>&nbsp;&nbsp;return FALSE;</DIV><DIV>&nbsp;<FONT color=#ff0000>CXTPSkinObject::CS_Skin.Lock();</FONT><BR>&nbsp;if (!pSkinObject-&gt;m_arrDescriptors.IsEmpty())<BR>&nbsp;{<BR>&nbsp;&nbsp;if (nMessage == pSkinObject-&gt;m_arrDescriptors.GetHead().nMessage)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;<FONT color=#ff0000>CXTPSkinObject::CS_Skin.Unlock();</FONT><BR>&nbsp;&nbsp;&nbsp;return FALSE;<BR>&nbsp;&nbsp;}<BR>&nbsp;}<BR>&nbsp;<FONT color=#ff0000>CXTPSkinObject::CS_Skin.Unlock();</FONT></DIV><DIV>&nbsp;if (defProc == xtpSkinDefaultCallWindowProc &amp;&amp; pSkinObject-&gt;IsDefWindowProcAvail(nMessage))<BR>&nbsp;{<BR>&nbsp;&nbsp;BOOL bAvail = FALSE;<BR>&nbsp;&nbsp;WNDPROC lpWndProc = (WNDPROC)lpPrev;</DIV><DIV>&nbsp;&nbsp;if (IsSystemWindowModule(lpWndProc, &amp;bAvail) || !bAvail)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;lpWndProc = 0;<BR>&nbsp;&nbsp;}</DIV><DIV>&nbsp;&nbsp;if (lpWndProc != 0 &amp;&amp; (!XTPSkinManager()-&gt;IsWin9x() ||<BR>&nbsp;&nbsp;&nbsp;((DWORD_PTR)lpWndProc &lt; (DWORD_PTR)0x70000000)))<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;return FALSE;<BR>&nbsp;&nbsp;}<BR>&nbsp;}</DIV><DIV>&nbsp;MSG&amp; curMsg = AfxGetThreadState()-&gt;m_lastSentMsg;<BR>&nbsp;MSG&nbsp; oldMsg = curMsg;<BR>&nbsp;curMsg.hwnd = hWnd;<BR>&nbsp;curMsg.message = nMessage;<BR>&nbsp;curMsg.wParam&nbsp; = wParam;<BR>&nbsp;curMsg.lParam&nbsp; = lParam;</DIV><DIV>&nbsp;pSkinObject-&gt;OnBeginHook(nMessage, defProc, pfnOrig, lpPrev);</DIV><DIV>&nbsp;BOOL bResult = pSkinObject-&gt;OnHookDefWindowProc(nMessage, wParam ,lParam, lResult);</DIV><DIV>&nbsp;pSkinObject-&gt;OnEndHook();</DIV><DIV>&nbsp;curMsg = oldMsg;</DIV><DIV>&nbsp;if (bResult)<BR>&nbsp;&nbsp;return TRUE;</DIV><DIV>&nbsp;return FALSE;<BR>}</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Wed, 21 Feb 2007 00:21:37 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=6291&amp;PID=20604&amp;title=crash-inside-onendhook#20604</guid>
  </item> 
  <item>
   <title><![CDATA[Crash inside OnEndHook : I did the following and it fixed...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=6291&amp;PID=20003&amp;title=crash-inside-onendhook#20003</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2321">JohnCrenshaw</a><br /><strong>Subject:</strong> 6291<br /><strong>Posted:</strong> 01 February 2007 at 11:50am<br /><br />I did the following and it fixed this:<DIV>&nbsp;</DIV><FONT color=#010001 size=2><P>BOOL</FONT><FONT size=2> </FONT><FONT color=#010001 size=2>CAppBarMngr</FONT><FONT size=2>::</FONT><FONT color=#010001 size=2>InitInstance</FONT><FONT size=2>()</P><P>{</P><P></FONT><FONT color=#008000 size=2>&nbsp;&nbsp; // unhook the window from the skin</P></FONT><FONT size=2><P></FONT><FONT color=#010001 size=2>&nbsp;&nbsp; XTPSkinManager</FONT><FONT size=2>()-&gt;</FONT><FONT color=#010001 size=2>Remove</FONT><FONT size=2>(</FONT><FONT color=#010001 size=2>m_pMainWnd</FONT><FONT size=2>-&gt;</FONT><FONT color=#010001 size=2>m_hWnd</FONT><FONT size=2>);</P><P></FONT><FONT color=#0000ff size=2>&nbsp;&nbsp; return</FONT><FONT size=2> </FONT><FONT color=#010001 size=2>TRUE</FONT><FONT size=2>;</P><P>}</P><DIV></DIV><P>It&nbsp;would still be best if the multithread issues could be fixed. It looks to me like a mutex around the <strong><FONT color=#010001 size=2>m_arrDescriptors</FONT><FONT size=2>.</FONT><FONT color=#010001 size=2>AddHead</FONT><FONT size=2>(</FONT><FONT color=#010001 size=2>des</FONT></strong><FONT size=2><strong>);</strong> and&nbsp;</FONT><FONT size=2></FONT><strong><FONT color=#010001 size=2>m_arrDescriptors</FONT><FONT size=2>.</FONT><FONT color=#010001 size=2>RemoveHead</FONT></strong><FONT size=2><strong>();</strong> functions would probably do it.</P></FONT></FONT>]]>
   </description>
   <pubDate>Thu, 01 Feb 2007 11:50:56 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=6291&amp;PID=20003&amp;title=crash-inside-onendhook#20003</guid>
  </item> 
  <item>
   <title><![CDATA[Crash inside OnEndHook : OK, wierd, it just crashed in...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=6291&amp;PID=19999&amp;title=crash-inside-onendhook#19999</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2321">JohnCrenshaw</a><br /><strong>Subject:</strong> 6291<br /><strong>Posted:</strong> 01 February 2007 at 10:17am<br /><br />OK, wierd, it just crashed in both threads. The second thread was inside the skin framework even though it shouldn't be skinned.]]>
   </description>
   <pubDate>Thu, 01 Feb 2007 10:17:03 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=6291&amp;PID=19999&amp;title=crash-inside-onendhook#19999</guid>
  </item> 
  <item>
   <title><![CDATA[Crash inside OnEndHook : I already called SetAutoApplyNewThreads(false)...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=6291&amp;PID=19998&amp;title=crash-inside-onendhook#19998</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2321">JohnCrenshaw</a><br /><strong>Subject:</strong> 6291<br /><strong>Posted:</strong> 01 February 2007 at 10:14am<br /><br />I already called SetAutoApplyNewThreads(false) before begging for help. Somehow, just the fact that the second thread exists is a problem without it having to be skinned. <DIV>&nbsp;</DIV><DIV>For what it is worth, the crash happens far more readily if I use a call to SetWindowPos rather than a MoveWindow/ShowWindow combo.</DIV>]]>
   </description>
   <pubDate>Thu, 01 Feb 2007 10:14:58 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=6291&amp;PID=19998&amp;title=crash-inside-onendhook#19998</guid>
  </item> 
  <item>
   <title><![CDATA[Crash inside OnEndHook : Hello,  yes, we agree that multithreading...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=6291&amp;PID=19982&amp;title=crash-inside-onendhook#19982</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=6851">Oleg</a><br /><strong>Subject:</strong> 6291<br /><strong>Posted:</strong> 01 February 2007 at 1:31am<br /><br />Hello,<DIV>&nbsp;</DIV><DIV>yes, we agree that multithreading still have problems. :( try to add </DIV><DIV>XTPSkinManager()-&gt;SetAutoApplyNewThreads(FALSE)&nbsp; to remove sknning of second thread.</DIV>]]>
   </description>
   <pubDate>Thu, 01 Feb 2007 01:31:50 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=6291&amp;PID=19982&amp;title=crash-inside-onendhook#19982</guid>
  </item> 
  <item>
   <title><![CDATA[Crash inside OnEndHook : Inside of the toolkit are the...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=6291&amp;PID=19976&amp;title=crash-inside-onendhook#19976</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2321">JohnCrenshaw</a><br /><strong>Subject:</strong> 6291<br /><strong>Posted:</strong> 31 January 2007 at 7:00pm<br /><br />Inside of the toolkit are the two following functions, which have abbreviated here to highlight the problem:<DIV><FONT color=#0000ff size=2></FONT><DIV><FONT color=#0000ff size=2><P>void</FONT><FONT size=2> </FONT><FONT color=#010001 size=2>CXTPSkinObject</FONT><FONT size=2>::</FONT><FONT color=#010001 size=2>OnBeginHook</FONT><FONT size=2>(</FONT><FONT color=#010001 size=2>...</FONT><FONT size=2>)</P><P>{</P><P></FONT><FONT color=#010001 size=2>&nbsp;&nbsp; InternalAddRef</FONT><FONT size=2>();</P><DIV></FONT><FONT color=#010001 size=2>&nbsp;&nbsp;&nbsp;...</DIV><DIV></FONT><FONT color=#010001 size=2>&nbsp;&nbsp; m_arrDescriptors</FONT><FONT size=2>.</FONT><FONT color=#010001 size=2>AddHead</FONT><FONT size=2>(...</FONT><FONT size=2>);</DIV><P>}</P></FONT>void<FONT size=2> </FONT><FONT color=#010001 size=2>CXTPSkinObject</FONT><FONT size=2>::</FONT><FONT color=#010001 size=2>OnEndHook</FONT><FONT size=2>()</DIV><P>{</P><P></FONT><FONT color=#010001 size=2>&nbsp;&nbsp; m_arrDescriptors</FONT><FONT size=2>.</FONT><FONT color=#010001 size=2>RemoveHead</FONT><FONT size=2>();</P><P></FONT><FONT color=#010001 size=2>&nbsp;&nbsp; InternalRelease</FONT><FONT size=2>();</P><P>}</P><DIV>In several places inside the toolkit,&nbsp;constructions like the following are used:</DIV><FONT size=2><P></FONT><FONT color=#010001 size=2>pSkinObject</FONT><FONT size=2>-&gt;</FONT><FONT color=#010001 size=2>OnBeginHook</FONT><FONT size=2>(</FONT><FONT color=#010001 size=2>...</FONT><FONT size=2>);</P><P></FONT><FONT color=#010001 size=2>BOOL</FONT><FONT size=2> </FONT><FONT color=#010001 size=2>bResult</FONT><FONT size=2> = </FONT><FONT color=#010001 size=2>pSkinObject</FONT><FONT size=2>-&gt;</FONT><FONT color=#010001 size=2>OnHookDefWindowProc</FONT><FONT size=2>(</FONT><FONT color=#010001 size=2>...</FONT><FONT size=2>);</P><P></FONT><FONT color=#010001 size=2>pSkinObject</FONT><FONT size=2>-&gt;</FONT><FONT color=#010001 size=2>OnEndHook</FONT><FONT size=2>();</P><DIV></DIV></FONT></FONT></DIV><DIV><FONT size=2>The basic idea of this is that something is added to a stack, the message is processed, and that something is then removed from the stack. It should, in theory, be impossible to reach a state where OnEndHook is called, and there is nothing in the stack, however, I am getting into such a state.</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>I have a background worker thread that watches the mouse, and moves windows around based on what the mouse does. This gives us capture level control without having to capture the mouse. I suspect that when this second thread moves things around, and messages are therefore processed, it creates a situation where this problem can happen. I was wondering if anyone is familiar with the issue and knows what to do about it.</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>Also, probably related, is a painting problem that pops up randomly when these windows are being moved by the second thread. Newly revealed portions of the window do not always paint, this seems to only be an issue when the windows are skinned.</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>I AM running 10.4.2</FONT></DIV>]]>
   </description>
   <pubDate>Wed, 31 Jan 2007 19:00:38 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=6291&amp;PID=19976&amp;title=crash-inside-onendhook#19976</guid>
  </item> 
 </channel>
</rss>