<?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 : 9.80:Strange behaviour CXTButt&#111;n::SetIc&#111;n</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Toolkit Pro : 9.80:Strange behaviour CXTButt&#111;n::SetIc&#111;n]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Wed, 22 Apr 2026 01:47:34 +0000</pubDate>
  <lastBuildDate>Thu, 20 Oct 2005 23:26:33 +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=3047</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[9.80:Strange behaviour CXTButt&#111;n::SetIc&#111;n : Arrgh! . Now I removed the 32x32...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=3047&amp;PID=9164&amp;title=9-80strange-behaviour-cxtbuttonseticon#9164</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=807">Uwe Keim</a><br /><strong>Subject:</strong> 3047<br /><strong>Posted:</strong> 20 October 2005 at 11:26pm<br /><br /><P>Arrgh! <IMG src="http://forum.codejock.com/smileys/smiley5.gif" border="0">.</P><P>Now I removed the 32x32 leaving <EM>only</EM> the 16x16 bitmap in the icon file. The result? Now the 16x16 icon is resized to be 32x32 resulting in a rasterized image, drawn at the wrong position (because too wide and too high).</P><P>Hmmmmmmm...</P>]]>
   </description>
   <pubDate>Thu, 20 Oct 2005 23:26:33 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=3047&amp;PID=9164&amp;title=9-80strange-behaviour-cxtbuttonseticon#9164</guid>
  </item> 
  <item>
   <title><![CDATA[9.80:Strange behaviour CXTButt&#111;n::SetIc&#111;n :  The problem now that LoadIcon...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=3047&amp;PID=9114&amp;title=9-80strange-behaviour-cxtbuttonseticon#9114</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=6851">Oleg</a><br /><strong>Subject:</strong> 3047<br /><strong>Posted:</strong> 18 October 2005 at 12:50pm<br /><br /><P>&nbsp;</P><P>The problem now that LoadIcon loads 32*32 icon instead of 16*16 so <FONT size=1>CXTPImageManagerIcon::SetIcon works as expected.</FONT></P><P><FONT size=1>To load corrrect Icon you can remove 32*32 layout from ico file, or use LoadImage instead:</FONT></P><P><FONT size=1>HICON hIcon = (HICON)LoadImage(..,..,IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);</FONT></P><P><FONT size=1></FONT>&nbsp;</P>]]>
   </description>
   <pubDate>Tue, 18 Oct 2005 12:50:06 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=3047&amp;PID=9114&amp;title=9-80strange-behaviour-cxtbuttonseticon#9114</guid>
  </item> 
  <item>
   <title><![CDATA[9.80:Strange behaviour CXTButt&#111;n::SetIc&#111;n : I think I found another issue: I...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=3047&amp;PID=9108&amp;title=9-80strange-behaviour-cxtbuttonseticon#9108</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=807">Uwe Keim</a><br /><strong>Subject:</strong> 3047<br /><strong>Posted:</strong> 18 October 2005 at 8:33am<br /><br /><P><FONT color=#000000>I think I found another issue:</FONT></P><P><FONT color=#000000>I now do call SetIcon() as you suggested. Now the icon IS loaded correctly, but since the Icon file contains a 32x32 and a 16x16, I do pass CSize(16,16), but internally you overwrite it again. </FONT></P><P><FONT color=#000000>Namely here:</FONT></P><FONT size=1><P><FONT color=#000000>01: m_pIcon </FONT></FONT><FONT color=#000000><FONT size=1>=</FONT><FONT size=1> </FONT><FONT size=1>new</FONT><FONT size=1> CXTPImageManagerIcon</FONT><FONT size=1>(</FONT><FONT size=1>0</FONT><FONT size=1>,</FONT><FONT size=1> size</FONT><FONT size=1>.</FONT><FONT size=1>cx</FONT><FONT size=1>,</FONT><FONT size=1> size</FONT><FONT size=1>.</FONT><FONT size=1>cy</FONT></FONT><FONT color=#000000><FONT size=1>);<BR></FONT><FONT size=1>02: m_pIcon</FONT><FONT size=1>-&gt;</FONT><FONT size=1>SetIcon</FONT><FONT size=1>(</FONT><FONT size=1>hIcon</FONT><FONT size=1>);</FONT></FONT></P><P><FONT size=1><FONT face="Verdana, Arial, Helvetica, sans-serif" color=#000000>Line 01 correctly passes my CSize(16,16), but when entering line 02 the function called there looks like the following:</FONT></FONT></P><P><FONT color=#000000 size=1>01: BOOL CXTPImageManagerIcon::SetIcon(CXTPImageManagerIconHandle hIcon)<BR>02: {<BR>03: &nbsp;ASSERT(!hIcon.IsEmpty());<BR>04: &nbsp;Clear(TRUE);<BR>05: &nbsp;m_hIcon.CopyHandle(hIcon);<BR>06: &nbsp;CSize sz = GetExtent();<BR>07: <BR>08: &nbsp;m_nHeight = sz.cy;<BR>09: &nbsp;m_nWidth = sz.cx;<BR>10: <BR>11: &nbsp;m_bScaled = FALSE;<BR>12: <BR>13: &nbsp;if (m_pIconSet)<BR>14: &nbsp;&nbsp;m_pIconSet-&gt;RefreshAll();<BR>15: <BR>16: &nbsp;return TRUE;<BR>17: }</FONT></P><P><FONT color=#000000 size=1>The lines 08 and 09 overwrite it again with CSize (32,32). I think this is an error.</FONT></P><P><FONT color=#000000 size=1>Am I right here?</FONT></P><P><FONT color=#0000ff size=1><FONT color=#000000>Thanks<BR>Uwe</FONT></P></FONT>]]>
   </description>
   <pubDate>Tue, 18 Oct 2005 08:33:43 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=3047&amp;PID=9108&amp;title=9-80strange-behaviour-cxtbuttonseticon#9108</guid>
  </item> 
  <item>
   <title><![CDATA[9.80:Strange behaviour CXTButt&#111;n::SetIc&#111;n : 2005-10-18_081123_common_icon_arrow_right.zip...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=3047&amp;PID=9107&amp;title=9-80strange-behaviour-cxtbuttonseticon#9107</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=807">Uwe Keim</a><br /><strong>Subject:</strong> 3047<br /><strong>Posted:</strong> 18 October 2005 at 8:11am<br /><br /><A href="http://forum.codejock.com/uploads/UweKeim/2005-10-18_081123_comm&#111;n_ic&#111;n_arrow_right.zip" target="_blank">2005-10-18_081123_common_icon_arrow_right.zip</A>]]>
   </description>
   <pubDate>Tue, 18 Oct 2005 08:11:29 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=3047&amp;PID=9107&amp;title=9-80strange-behaviour-cxtbuttonseticon#9107</guid>
  </item> 
  <item>
   <title><![CDATA[9.80:Strange behaviour CXTButt&#111;n::SetIc&#111;n : Another option is to call  BOOL...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=3047&amp;PID=9103&amp;title=9-80strange-behaviour-cxtbuttonseticon#9103</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=6851">Oleg</a><br /><strong>Subject:</strong> 3047<br /><strong>Posted:</strong> 18 October 2005 at 4:47am<br /><br /><P>Another option is to call </P><P>BOOL CXTButton::SetIcon(CSize size, HICON hIcon, HICON hIconHot/*= NULL*/, BOOL bRedraw/*= TRUE*/)</P><P>instead of </P><P>BOOL CXTButton::SetIcon(CSize size, UINT nID, UINT nHotID/*= 0*/, BOOL bRedraw/*= TRUE*/)</P><P>&nbsp;</P><P>so you can load Icon useing AfxGetApp()-&gt;LoadIcon(idr) and call first method.</P><P>&nbsp;</P><P>but,&nbsp;fix must work :( Can you attach icon that have problem?</P><P>&nbsp;</P>]]>
   </description>
   <pubDate>Tue, 18 Oct 2005 04:47:34 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=3047&amp;PID=9103&amp;title=9-80strange-behaviour-cxtbuttonseticon#9103</guid>
  </item> 
  <item>
   <title><![CDATA[9.80:Strange behaviour CXTButt&#111;n::SetIc&#111;n : Just tried, still did not work. The...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=3047&amp;PID=9099&amp;title=9-80strange-behaviour-cxtbuttonseticon#9099</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=807">Uwe Keim</a><br /><strong>Subject:</strong> 3047<br /><strong>Posted:</strong> 18 October 2005 at 4:06am<br /><br /><P><FONT face="Verdana, Arial, Helvetica, sans-serif" size=2>Just tried, still did not work.</FONT></P><P><FONT face="Verdana, Arial, Helvetica, sans-serif" size=2>The reason is that it still passes the "1" from lpGrpIconDir<FONT color=#0000ff>-&gt;</FONT>idEntries<FONT color=#0000ff>&#091;</FONT>i<FONT color=#0000ff>&#093;.</FONT>nID to the first recursion of the function (instead of my real resource ID).</FONT></P><P><FONT face="Verdana, Arial, Helvetica, sans-serif" size=2>I do not fully understand what the function does, so I'll try it now and see how I can fix it.</FONT></P><P><FONT face="Verdana, Arial, Helvetica, sans-serif" size=2>Maybe you can tell me another option, too, if I find no solution by myself.</FONT></P><P><FONT face="Verdana, Arial, Helvetica, sans-serif" size=2>Thanks<BR>Uwe</FONT></P>]]>
   </description>
   <pubDate>Tue, 18 Oct 2005 04:06:46 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=3047&amp;PID=9099&amp;title=9-80strange-behaviour-cxtbuttonseticon#9099</guid>
  </item> 
  <item>
   <title><![CDATA[9.80:Strange behaviour CXTButt&#111;n::SetIc&#111;n : Ok, Please give me know if it...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=3047&amp;PID=9098&amp;title=9-80strange-behaviour-cxtbuttonseticon#9098</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=6851">Oleg</a><br /><strong>Subject:</strong> 3047<br /><strong>Posted:</strong> 18 October 2005 at 3:42am<br /><br />Ok, Please give me know if it helps.]]>
   </description>
   <pubDate>Tue, 18 Oct 2005 03:42:45 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=3047&amp;PID=9098&amp;title=9-80strange-behaviour-cxtbuttonseticon#9098</guid>
  </item> 
  <item>
   <title><![CDATA[9.80:Strange behaviour CXTButt&#111;n::SetIc&#111;n : Thank you, I will try the second...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=3047&amp;PID=9094&amp;title=9-80strange-behaviour-cxtbuttonseticon#9094</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=807">Uwe Keim</a><br /><strong>Subject:</strong> 3047<br /><strong>Posted:</strong> 18 October 2005 at 12:36am<br /><br /><P>Thank you, I will try the second approach.</P><P>BTW: My&nbsp;IDR_MAINFRAME is <EM>not</EM> 1 but 150. Probably returning the&nbsp; IDR_MAINFRAME (i.e. the lowest icon) when requesting with ID 1 is a Windows default behaviour.</P>]]>
   </description>
   <pubDate>Tue, 18 Oct 2005 00:36:29 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=3047&amp;PID=9094&amp;title=9-80strange-behaviour-cxtbuttonseticon#9094</guid>
  </item> 
  <item>
   <title><![CDATA[9.80:Strange behaviour CXTButt&#111;n::SetIc&#111;n : Hello, Thank you, we agree that...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=3047&amp;PID=9092&amp;title=9-80strange-behaviour-cxtbuttonseticon#9092</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=6851">Oleg</a><br /><strong>Subject:</strong> 3047<br /><strong>Posted:</strong> 17 October 2005 at 11:42pm<br /><br /><P>Hello,</P><P>Thank you, we agree that the problem exists, </P><P>To fix you can</P><P>1. Change resource of IDR_MAINFRAME (Main Icon) from 1 to 128 </P><P>or</P><P>patch sources </P><P>1. Add third parameter to CreateIconFromResource </P><P>bGroupResource = TRUE</P><P>and</P><P>change line <FONT face="Courier New" size=1>04:</FONT></P><P><FONT face="Courier New" size=1>if (hRsrc != NULL <strong>&amp;&amp; bGroupResource</strong>)</FONT></P><P><FONT face="Courier New" size=1>change line 15:</FONT></P><P>&nbsp;&nbsp;&nbsp;&nbsp;if  (CreateIconFromResource(MAKEINTRESOURCE(lpGrpIconDir-&gt;idE ntries<em>.nID), szIcon, <strong>FALSE</strong>))<BR></P><P>&nbsp;</P><P>Thank you, </P>]]>
   </description>
   <pubDate>Mon, 17 Oct 2005 23:42:52 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=3047&amp;PID=9092&amp;title=9-80strange-behaviour-cxtbuttonseticon#9092</guid>
  </item> 
  <item>
   <title><![CDATA[9.80:Strange behaviour CXTButt&#111;n::SetIc&#111;n : In version 9.80, the implementation...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=3047&amp;PID=9080&amp;title=9-80strange-behaviour-cxtbuttonseticon#9080</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=807">Uwe Keim</a><br /><strong>Subject:</strong> 3047<br /><strong>Posted:</strong> 17 October 2005 at 8:08am<br /><br /><P>In version 9.80, the implementation of <FONT size=1><FONT face="Courier New, Courier, mono">CXTButton<FONT color=#0000ff>::</FONT></FONT><FONT face="Courier New, Courier, mono">SetIcon</FONT> has changed.</FONT></P><P><FONT size=1>It is internally routed to <FONT face="Courier New, Courier, mono"><FONT color=#008080 size=1>BOOL</FONT><FONT size=1> CXTPImageManagerIconHandle</FONT><FONT color=#0000ff size=1>::</FONT><FONT size=1>CreateIconFromResource</FONT><FONT color=#0000ff size=1>(</FONT><FONT color=#008080 size=1>LPCTSTR</FONT><FONT size=1> lpszResourceName</FONT><FONT color=#0000ff size=1>,</FONT><FONT size=1> </FONT><FONT color=#008080 size=1>CSize</FONT><FONT size=1> szIcon</FONT><FONT color=#0000ff size=1>)<FONT face="Verdana, Arial, Helvetica, sans-serif" color=#000000> which internally has the following code:</FONT></FONT></FONT></FONT></P><P><FONT face="Courier New, Courier, mono"><FONT size=1><FONT color=#0000ff size=1><FONT color=#000000>...<BR>01: HINSTANCE hInst = AfxFindResourceHandle(lpszResourceName, RT_GROUP_ICON);<BR>02: HRSRC hRsrc = ::FindResource(hInst, lpszResourceName, RT_GROUP_ICON);<BR>03: <BR>04: if (hRsrc != NULL)<BR>05: {<BR>06: &nbsp;// Load and Lock to get a pointer to a GRPICONDIR<BR>07: &nbsp;HGLOBAL hGlobal = LoadResource( hInst, hRsrc );<BR>08: <BR>09: &nbsp;CXTPImageManagerIcon::GRPICONDIR* lpGrpIconDir = (CXTPImageManagerIcon::GRPICONDIR*)LockResource( hGlobal );<BR>10: <BR>11: &nbsp;for (int i = (int)lpGrpIconDir-&gt;idCount - 1; i &gt;= 0; i--)<BR>12: &nbsp;{<BR>13: &nbsp;&nbsp;if (lpGrpIconDir-&gt;idEntries&#091; i &#093;.bWidth == szIcon.cx &amp;&amp; lpGrpIconDir-&gt;idEntries&#091;i&#093;.bHeight == szIcon.cy)<BR>14: &nbsp;&nbsp;{<BR>15: &nbsp;&nbsp;&nbsp;if  (CreateIconFromResource(MAKEINTRESOURCE(lpGrpIconDir-&gt;idE ntries&#091;i&#093;.nID), szIcon))<BR>16: &nbsp;&nbsp;&nbsp;&nbsp;return TRUE;<BR>17: &nbsp;&nbsp;}<BR>18: &nbsp;}<BR>19: <BR>20: &nbsp;return FALSE;<BR>21: }<BR>22: <BR>23: hInst = AfxFindResourceHandle(lpszResourceName, RT_ICON);<BR>24: hRsrc = ::FindResource(hInst, lpszResourceName, RT_ICON);<BR>25: <BR>26: if (hRsrc == NULL)<BR>27: &nbsp;return FALSE;<BR></FONT></FONT></FONT><FONT size=1><FONT color=#0000ff size=1><FONT color=#000000>...</FONT></FONT></FONT></FONT></P><P><FONT size=1><FONT face="Courier New, Courier, mono"><FONT color=#0000ff size=1><FONT face=Verdana color=#000000>Now I call the <FONT face="Courier New">CXTButton<FONT color=#0000ff>::</FONT>SetIcon</FONT>&nbsp; from within my code and the result is that the main application icon is loaded instead of the icon that is present and even found by the lines above.</FONT></FONT></FONT></FONT></P><P><FONT size=1><FONT face="Courier New, Courier, mono"><FONT color=#0000ff size=1><FONT face=Verdana color=#000000>Let me explain:</FONT></FONT></FONT></FONT></P><UL><LI><FONT size=1><FONT face="Courier New, Courier, mono"><FONT color=#0000ff size=1><FONT face=Verdana color=#000000>Line 01 and 02 do return a non-NULL value.</FONT></FONT></FONT></FONT></LI><LI><FONT size=1><FONT face="Courier New, Courier, mono"><FONT color=#0000ff size=1><FONT face=Verdana color=#000000>Then the code is executed until line 15, calling&nbsp;itself recusively &nbsp;with a value of 1 for <FONT face="Courier New">lpGrpIconDir-&gt;idEntries&#091;i&#093;.nID</FONT>.</FONT></FONT></FONT></FONT></LI><LI><FONT size=1><FONT face="Courier New, Courier, mono"><FONT color=#0000ff size=1><FONT face=Verdana color=#000000>Then the recursive call of the function with a value of 1 for the <FONT face="Courier New, Courier, mono">lpszResourceName</FONT> evalutes <FONT face="Courier New, Courier, mono">hRsrc</FONT> to NULL and thus does not branch into the block starting on line 04 (because a resource ID of 6254 was requested and now the strange recursion passes a resource ID of 1 which actually does not exist).</FONT></FONT></FONT></FONT></LI><LI><FONT size=1><FONT face="Courier New, Courier, mono"><FONT color=#0000ff size=1><FONT face=Verdana color=#000000>Instead, it goes directly to line 23 where the ID of 1 is passed and (probably by Windows default) loads the applications icon.</FONT></FONT></FONT></FONT></LI></UL><P><FONT size=1><FONT face="Courier New, Courier, mono"><FONT color=#0000ff size=1><FONT face=Verdana color=#000000><strong>Question: </strong>could you please comment on this? I do believe this is an error, because in the version prior to 9.7 everything works correctly.</FONT></FONT></FONT></FONT></P><P><FONT size=1><FONT face="Courier New, Courier, mono"><FONT color=#0000ff size=1><FONT face=Verdana color=#000000>Thanks<BR>Uwe</FONT></P></FONT></FONT></FONT>]]>
   </description>
   <pubDate>Mon, 17 Oct 2005 08:08:41 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=3047&amp;PID=9080&amp;title=9-80strange-behaviour-cxtbuttonseticon#9080</guid>
  </item> 
 </channel>
</rss>