<?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 : Buttons lose rounded edges - OnPaint background</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Controls : Buttons lose rounded edges - OnPaint background]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Wed, 13 May 2026 00:20:48 +0000</pubDate>
  <lastBuildDate>Mon, 16 Mar 2009 18:32:57 +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=13698</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[Buttons lose rounded edges - OnPaint background : Thanks Oleg.  For others, here...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=13698&amp;PID=46783&amp;title=buttons-lose-rounded-edges-onpaint-background#46783</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=5059">doinIT</a><br /><strong>Subject:</strong> 13698<br /><strong>Posted:</strong> 16 March 2009 at 6:32pm<br /><br />Thanks Oleg.<DIV>&nbsp;</DIV><DIV>For others,&nbsp; here is a bit of an explanation and the code that fixed my problem.</DIV><DIV>&nbsp;</DIV><DIV>I needed to handle the <FONT size=2>OnCtlColor method and return the brush to be used as the background for the control to be painted.</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>Inside the OnPaint method I draw a gradient jpeg image that fits the entire background of the Dialog.</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>I had to use use the same image that was used to paint the background to create a brush inside OnCtlColor (shown below) which fixed the problem of the buttons losing the transparency.</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV><FONT size=2>HBRUSH CSkinDlgDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)</DIV><P>{</P><P>HBRUSH hbr;</P><P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2>( nCtlColor == CTLCOLOR_STATIC || nCtlColor == CTLCOLOR_BTN )</P><P>{</P><P></P><P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2>(img){</P><P>m_brush = CreatePatternBrush(img); </FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// Previously created CImage</P></FONT></FONT><FONT size=2><P></P><P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2> (pWnd-&gt;m_hWnd != </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>this</FONT></FONT><FONT size=2>-&gt;m_hWnd)</P><P>{</P><P>CXTPWindowRect rcPaint(pWnd);</P><P>CXTPWindowRect rcBrush(m_hWnd);</P><P>HDC hDC = pDC-&gt;m_hDC;</P><P>::SetBrushOrgEx(hDC, rcBrush.left - rcPaint.left, rcBrush.top - rcPaint.top, NULL);</P><P>::SetBkMode(hDC, TRANSPARENT);</P><P></P><P>::SetTextColor(hDC, GetSysColor(COLOR_BTNTEXT));</P><P>}</P><P>}</P><P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>return</FONT></FONT><FONT size=2> m_brush; </P><P>}</P><P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>else</P></FONT></FONT><FONT size=2><P>{</P><P>hbr = CXTPDialog::OnCtlColor(pDC, pWnd, nCtlColor);</P><P>}</P><P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>return</FONT></FONT><FONT size=2> hbr;</P><P>}</P><DIV></DIV><P>&nbsp;</P><P>Cheers,</P><DIV></DIV><DIV></DIV>Jai</FONT>]]>
   </description>
   <pubDate>Mon, 16 Mar 2009 18:32:57 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=13698&amp;PID=46783&amp;title=buttons-lose-rounded-edges-onpaint-background#46783</guid>
  </item> 
  <item>
   <title><![CDATA[Buttons lose rounded edges - OnPaint background : Hi, Search in this forum. There...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=13698&amp;PID=46753&amp;title=buttons-lose-rounded-edges-onpaint-background#46753</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=6851">Oleg</a><br /><strong>Subject:</strong> 13698<br /><strong>Posted:</strong> 16 March 2009 at 8:11am<br /><br />Hi,<DIV>Search in this forum. There was some samples how to draw transparent dialog.</DIV>]]>
   </description>
   <pubDate>Mon, 16 Mar 2009 08:11:41 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=13698&amp;PID=46753&amp;title=buttons-lose-rounded-edges-onpaint-background#46753</guid>
  </item> 
  <item>
   <title><![CDATA[Buttons lose rounded edges - OnPaint background : I created an MFC Dialog app and...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=13698&amp;PID=46732&amp;title=buttons-lose-rounded-edges-onpaint-background#46732</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=5059">doinIT</a><br /><strong>Subject:</strong> 13698<br /><strong>Posted:</strong> 16 March 2009 at 2:37am<br /><br /><DIV>I created an MFC Dialog app and used the vista skin which is working.</DIV><DIV>After finding out from another post that the skin builder/framework doesn't included background images for dialogs, I used the OnPaint routine of the main dialog and paint a background gradient image (from a physical .jpeg on disk)&nbsp;using CImage.</DIV><DIV>&nbsp;</DIV><DIV>Problem is after I paint the background image, the buttons on the Dialog lose the round edges.&nbsp;Looks like they can no longer handle the transparecy of the images.</DIV><DIV>&nbsp;</DIV><DIV>Anyone know why this would happen?</DIV><DIV>&nbsp;</DIV><DIV>Thanks,</DIV><DIV>&nbsp;</DIV><DIV>Jai</DIV>]]>
   </description>
   <pubDate>Mon, 16 Mar 2009 02:37:17 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=13698&amp;PID=46732&amp;title=buttons-lose-rounded-edges-onpaint-background#46732</guid>
  </item> 
 </channel>
</rss>