<?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 : Center vertically the image in a ribbon button</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Toolkit Pro : Center vertically the image in a ribbon button]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Sun, 19 Apr 2026 14:23:56 +0000</pubDate>
  <lastBuildDate>Mon, 14 Nov 2016 03:34:25 +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=23198</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[Center vertically the image in a ribbon button :  Thank you very much! ]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=23198&amp;PID=75330&amp;title=center-vertically-the-image-in-a-ribbon-button#75330</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=9092">ovidiumvp</a><br /><strong>Subject:</strong> 23198<br /><strong>Posted:</strong> 14 November 2016 at 3:34am<br /><br />Thank you very much!]]>
   </description>
   <pubDate>Mon, 14 Nov 2016 03:34:25 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=23198&amp;PID=75330&amp;title=center-vertically-the-image-in-a-ribbon-button#75330</guid>
  </item> 
  <item>
   <title><![CDATA[Center vertically the image in a ribbon button : Hello Ovidiu,Algogithm for drawing...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=23198&amp;PID=75327&amp;title=center-vertically-the-image-in-a-ribbon-button#75327</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=8730">olebed</a><br /><strong>Subject:</strong> 23198<br /><strong>Posted:</strong> 12 November 2016 at 10:54am<br /><br />Hello Ovidiu,<br><br>Algogithm for drawing ribbon buttons is in CXTPPaintManager::DrawControlToolBarParent() method.&nbsp;<br>See for&nbsp;<table width="99%"><tr><td><pre class="BBcode">if (buttonStyle == xtpButtonIconAndCaptionBelow)</pre></td></tr></table><br>You can change code to<table width="99%"><tr><td><pre class="BBcode">&nbsp; &nbsp; if (buttonStyle == xtpButtonIconAndCaptionBelow)<div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; .... // without changes</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if (bDraw)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // swap parts of drawing &nbsp;text and image to get correct rcText to center image</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CRect rcText = rcButton;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ....</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CSize szText = DrawControlText2(pDC, pButton, CXTPEmptyRect(), FALSE, bVert, bTriangled);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ....</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DrawControlText2(pDC, pButton, rcText, TRUE, bVert, bTriangled);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (bDrawImage)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CSize szScalledIcon = (!bDPIIconsScallingEnabled) ? szIcon :</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CSize(XTP_DPI_X(szIcon.cx), XTP_DPI_Y(szIcon.cy));</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (bDPIIconsScallingEnabled)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; szScalledIcon.cx = min(szButton.cx - nDpiScallingButtonMargin, szScalledIcon.cx);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; szScalledIcon.cy = min(szButton.cy - nDpiScallingButtonMargin, szScalledIcon.cy);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CPoint pt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (bVert)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pt = CPoint(rcButton.left + XTP_DPI_X(4) + nSplitDropDownHeight, rcButton.CenterPoint().y - szScalledIcon.cy / 2);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <b><font color="#00cc00">rcButton.bottom -= </font><font color="#0066cc">rcText</font><font color="#00cc00">.Height();</font></b></div><div><font color="#00cc00"><b>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rcButton.top &nbsp; &nbsp;+= XTP_DPI_Y(3);</b></font></div><div><font color="#00cc00"><b>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pt = CPoint(rcButton.CenterPoint().x - szScalledIcon.cx / 2, rcButton.CenterPoint().y - szScalledIcon.cy / 2);</b></font></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DrawImage(pDC, pt, szScalledIcon, pImage, bSelected, bPressed, bEnabled, bChecked, bPopuped);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; else</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .....</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; return GetControlSize(pButton, szButton, bVert);</div>&nbsp; &nbsp; }</pre></td></tr></table><br>Regards,<br>&nbsp;Oleksandr Lebed]]>
   </description>
   <pubDate>Sat, 12 Nov 2016 10:54:53 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=23198&amp;PID=75327&amp;title=center-vertically-the-image-in-a-ribbon-button#75327</guid>
  </item> 
  <item>
   <title><![CDATA[Center vertically the image in a ribbon button :  I added button controls to a...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=23198&amp;PID=75322&amp;title=center-vertically-the-image-in-a-ribbon-button#75322</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=9092">ovidiumvp</a><br /><strong>Subject:</strong> 23198<br /><strong>Posted:</strong> 11 November 2016 at 10:30am<br /><br /><div>I added button controls to a ribbon, changing the default size for each one (that was a requirement).</div><div><font face="Courier New, Courier, mono"><font color="darkblue"><strong><br>void CMyRibbon::Init()<br>{<br>&nbsp;&nbsp;&nbsp; //...<br>&nbsp;&nbsp;&nbsp; CXTPRibbonGroup* pMyGroup = pMyTab-&gt;AddGroup(ID_MY_GROUP);<br>&nbsp;&nbsp;&nbsp; pMyGroup-&gt;SetControlsCentering();<br>&nbsp;&nbsp;&nbsp; pMyGroup-&gt;SetArrangeEditCaption(TRUE);<br>&nbsp;&nbsp;&nbsp; AddButtonToGroup(pMyGroup, ID_MY_BUTTON);<br>&nbsp;&nbsp;&nbsp; //... <br>}</strong></font></font></div><div><font face="Courier New, Courier, mono"><font color="darkblue"><strong>&nbsp;&nbsp;&nbsp; </strong></font></font></div><div><font face="Courier New, Courier, mono"><font color="darkblue"><strong>CXTPControlButton* CMyRibbon::AddButtonToGroup(CXTPRibbonGroup* pParentGroup, int nID)<br>{<br>&nbsp;&nbsp;&nbsp; CXTPControlButton* pButton = (CXTPControlButton*)pParentGroup-&gt;Add(xtpControlButton, nID);</strong></font></font></div><div><font face="Courier New, Courier, mono"><font color="darkblue"><strong><br>&nbsp;&nbsp;&nbsp; pButton-&gt;SetStyle(xtpButtonIconAndCaptionBelow);<br>&nbsp;&nbsp;&nbsp; pButton-&gt;SetWidth(XTP_DPI_X(54));<br>&nbsp;&nbsp;&nbsp; pButton-&gt;SetHeight(XTP_DPI_Y(82));</strong></font></font></div><div><font face="Courier New, Courier, mono"><font color="darkblue"><strong><br>&nbsp;&nbsp;&nbsp; return pButton;<br>}<br></strong></font></font></div><div>So far so good but someones complain that doesn't look very&nbsp;well, because the image is aligned to the top of button, the text is aligned to the bottom, so the space between image and text is too large. </div><div>&nbsp;&nbsp; </div><div>Is it any easy way to <b>center vertically</b> the image in the button?</div><div><img src="uploads/9092/Ribb&#111;n_butt&#111;n.jpg" height="96" width="130" border="0" /></div><div>Note: I'm using Office 2013 theme.&nbsp; </div>]]>
   </description>
   <pubDate>Fri, 11 Nov 2016 10:30:20 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=23198&amp;PID=75322&amp;title=center-vertically-the-image-in-a-ribbon-button#75322</guid>
  </item> 
 </channel>
</rss>