<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>settextalign &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/settextalign/</link>
	<description>Feed of posts on WordPress.com tagged "settextalign"</description>
	<pubDate>Thu, 03 Dec 2009 00:21:19 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Right-aligning text with CDC::SetTextAlign]]></title>
<link>http://msujaws.wordpress.com/2008/11/20/right-aligning-text-with-cdcsettextalign/</link>
<pubDate>Thu, 20 Nov 2008 17:57:41 +0000</pubDate>
<dc:creator>msujaws</dc:creator>
<guid>http://msujaws.wordpress.com/2008/11/20/right-aligning-text-with-cdcsettextalign/</guid>
<description><![CDATA[Aligning text in an MFC application dialog can be done in many ways. I&#8217;ve seen some that calcu]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Aligning text in an MFC application dialog can be done in many ways. I&#8217;ve seen some that calculate the width of the text it is going to print and then recalculate the CRect that the text should be placed it to give it the look of being aligned.</p>
<p>Today I was trying to do just that and was looking through the MSDN documentation for the different method calls when I stumbled upon CDC::SetTextAlign. The MSDN documentation reads:</p>
<div dir="ltr">
<blockquote>
<pre class="libCScode">UINT SetTextAlign(
   UINT nFlags
);</pre>
<p><strong>TA_RIGHT</strong>   Aligns the point with the right side of the bounding rectangle.<br />
<strong>TA_CENTER</strong>   Aligns the point with the horizontal center of the bounding rectangle.<br />
<strong>TA_LEFT</strong>   Aligns the point with the left side of the bounding rectangle. This is the default setting.</p>
<p>Specifies text-alignment flags. The flags specify the relationship between a point and a rectangle that bounds the text. The point can be either the current position or coordinates specified by a text-output function. The rectangle that bounds the text is defined by the adjacent character cells in the text string. The <span class="parameter"><em>nFlags</em></span> parameter can be one or more flags from the following three categories. Choose only one flag from each category. The first category affects text alignment in the x-direction:</p></blockquote>
</div>
<p><!--more-->My quick and dirty read told me that if I wanted to right-align text, I should just set the CRect.right property, call SetTextAlign( TA_RIGHT), and draw the text. This didn&#8217;t work as expected though. I learned that the text align actually works with the rectangle like below:</p>
<p style="text-align:center;"><img class="size-full wp-image-74  aligncenter" title="text-align1" src="http://msujaws.wordpress.com/files/2008/11/text-align1.png" alt="text-align1" width="410" height="177" /></p>
<p>It&#8217;s not what it sounded like, and not what I expected. I hope this helps anyone else trying to figure out why the text-align isn&#8217;t working correctly.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[WinAPI : Displaying Text]]></title>
<link>http://jalaj.net/2007/03/12/winapi-displaying-text/</link>
<pubDate>Mon, 12 Mar 2007 11:46:42 +0000</pubDate>
<dc:creator>jalaj</dc:creator>
<guid>http://jalaj.net/2007/03/12/winapi-displaying-text/</guid>
<description><![CDATA[After getting a feel of how Pens and Brushes are used for drawing on a Device Context, let&#8217;s g]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>After getting a feel of how Pens and Brushes are used for drawing on a Device Context, let&#8217;s get on to displaying texts on a Device Context.<br />
<!--more--><br />
The most basic function for the purpose is the <b>TextOut</b>. The function takes handle to the device context as the first parameter. The next two parameters are the X and Y co-ordinates of the reference point that system uses to align the string. The next parameter is the pointer to the string that is to be displayed and the last parameter is the number of characters in the string. Function returns non-zero if it succeeds otherwise a zero.</p>
<pre>
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" ( _
    ByVal hDC As Long, ByVal x As Long, ByVal y As Long, _
    ByVal lpString As String, ByVal nCount As Long) As Long
</pre>
<p>By default, the text is displayed Top-Left with reference to the co-ordinates passed. This is the default behaviour of the device context, however can be changed using the <b>SetTextAlign</b> function. Further the current position on the device context is neither used nor updated by the <b>TextOut</b> function, this behaviour however can also be modified using <b>SetTextAlign</b> function.</p>
<p>The function takes first parameter the handle to the device context and the next parameter is one or more of the constants defined below while will determine the alignment of texts that would be drawn next time.</p>
<pre>
Private Declare Function SetTextAlign Lib "gdi32" ( _
    ByVal hdc As Long, ByVal wFlags As Long) As Long

Const TA_LEFT = 0
Const TA_TOP = 0
Const TA_NOUPDATECP = 0
Const TA_UPDATECP = 1
Const TA_RIGHT = 2
Const TA_CENTER = 6
Const TA_BOTTOM = 8
Const TA_BASELINE = 24
Const TA_MASK = (TA_BASELINE + TA_CENTER + TA_UPDATECP)
</pre>
<p>Similarly <b>SetTextColor</b> function can be used to change the text color associated with the device context. The function takes handle to the device context as the first parameter. The second parameter is the Color reference calculated using RGB macro. </p>
<pre>
Private Declare Function SetTextColor Lib "gdi32" Alias "SetTextColor" ( _
    ByVal hdc As Long, ByVal crColor As Long) As Long
</pre>
<p class="postmetadata">
Similar posts on Technorati : <a href="http://technorati.com/posts/tag/visual-basic/" title="Visual Basic" rel="tag">Visual Basic</a>,  <a href="http://technorati.com/posts/tag/programming/" title="Programming" rel="tag">Programming</a>,  <a href="http://technorati.com/posts/tag/microsoft/" title="Microsoft" rel="tag">Microsoft</a>,  <a href="http://technorati.com/posts/tag/windows/" title="Windows" rel="tag">Windows</a>,  <a href="http://technorati.com/posts/tag/winapi/" title="WinAPI" rel="tag">WinAPI</a>,  <a href="http://technorati.com/posts/tag/gdi32/" title="GDI32" rel="tag">GDI32</a>,  <a href="http://technorati.com/posts/tag/text/" title="Text" rel="tag">Text</a>,  <a href="http://technorati.com/posts/tag/functions/" title="Functions" rel="tag">Functions</a>,  <a href="http://technorati.com/posts/tag/textout/" title="TextOut" rel="tag">TextOut</a>,  <a href="http://technorati.com/posts/tag/settextalign/" title="SetTextAlign" rel="tag">SetTextAlign</a>,  <a href="http://technorati.com/posts/tag/settextcolor/" title="SetTextColor" rel="tag">SetTextColor</a>,</p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
