<?xml version="1.0" encoding="UTF-8"?>
<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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jalaj P. Jha &#187; Functions</title>
	<atom:link href="http://jalaj.net/category/functions/feed/" rel="self" type="application/rss+xml" />
	<link>http://jalaj.net</link>
	<description>Technical &#38; Miscellaneous Ramblings</description>
	<lastBuildDate>Sun, 05 Sep 2010 23:54:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Blog Revisited &#8211; 8</title>
		<link>http://jalaj.net/2007/11/21/the-blog-revisited-8/</link>
		<comments>http://jalaj.net/2007/11/21/the-blog-revisited-8/#comments</comments>
		<pubDate>Wed, 21 Nov 2007 13:23:37 +0000</pubDate>
		<dc:creator>Jalaj</dc:creator>
				<category><![CDATA[Application]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[Blogs]]></category>
		<category><![CDATA[Buzz]]></category>
		<category><![CDATA[Domain]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[GDI32]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Microsoft office]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Project Management]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Technorati]]></category>
		<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WinAPI]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[MiscPosts]]></category>

		<guid isPermaLink="false">http://jalaj.net/2007/11/21/the-blog-revisited-8/</guid>
		<description><![CDATA[Three of the posts in May were related to MS Project, discussing scheduling of tasks and setting deadlines and constraints.


MS Project : Schedule tasks - 1
MS Project : Schedule tasks - 2
MS Project : Deadlines and Constraints

With my previous insight on how Technorati fails to detect pages from same blog, I got prepared to go [...]]]></description>
			<content:encoded><![CDATA[<p>Three of the posts in May were related to MS Project, discussing scheduling of tasks and setting deadlines and constraints.<br />
<span id="more-396"></span></p>
<ul>
<li><a href="http://jalaj.net/2007/05/17/ms-project-schedule-tasks-1/">MS Project : Schedule tasks - 1</a></li>
<li><a href="http://jalaj.net/2007/05/18/ms-project-schedule-tasks-2/">MS Project : Schedule tasks - 2</a></li>
<li><a href="http://jalaj.net/2007/05/25/ms-project-deadlines-and-constraints/">MS Project : Deadlines and Constraints</a></li>
</ul>
<p>With my previous insight on how Technorati fails to detect pages from same blog, I got prepared to go deeper into it's perceived algorithm and just then Technorati saw some changes (not the expected ones) and I dropped my plans to go ahead. <a href="http://jalaj.net/2007/05/16/there-is-something-about-technorati/">There is Something about Technorati</a> and <a href="http://jalaj.net/2007/05/24/technorati-rank-is-dead/">Technorati Rank is Dead</a> (It rose again from undead...) were two posts on Technorati.</p>
<p>May saw a very good event for me, getting verified by Google for Webmaster Tools, which I later found it to be undocumented on web and thus came up the post <a href="http://jalaj.net/2007/05/21/get-your-wordpresscom-blog-google-verified/">Get your Wordpress.com Blog Google Verified</a> which saw a large number of views, and is still referred.</p>
<p>It was then that I decided to get my own domain. The decision was sudden as is documented at <a href="http://jalaj.net/2007/05/24/wordpresscom-domain-upgrade/">Wordpress.com Domain Upgrade</a>... though later I felt regretting the decision as the Toolbar update get unexpectedly delayed which also disturbed the traffic to the blog and later in posting frequency.</p>
<p>Below are some more posts on Google reviewing it's new features.</p>
<ul>
<li><a href="http://jalaj.net/2007/05/17/new-on-google-the-notebook/">New on Google - The Notebook</a></li>
<li><a href="http://jalaj.net/2007/05/31/google-reader-goes-offline/">Google Reader Goes Offline</a></li>
<li><a href="http://jalaj.net/2007/05/22/how-much-searches-does-google-trends-need/">How much searches does Google Trends need?</a></li>
</ul>
<p>May also saw last posts on WinAPI (though I have not given up yet)</p>
<ul>
<li><a href="http://jalaj.net/2007/05/23/winapi-enumerating-installed-fonts/">WinAPI : Enumerating Installed Fonts</a></li>
<li><a href="http://jalaj.net/2007/05/28/font-enumeration-application/">Font Enumeration Application</a></li>
</ul>
<p><a href="http://jalaj.net/2007/05/18/social-engineering/">Social Engineering</a> was a post that details how anyone can get cheated by someone, who not even need to be a pro hacker.</p>
<p>Many of you might have frequently received powerpoint PPS files in mails as attachement. Many a times you might have felt prompted to edit a file to your own convenience but alas... PPS files are not editable... Don't worry see how you can easily <a href="http://jalaj.net/2007/05/20/convert-pps-to-ppt/">Convert PPS to PPT</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jalaj.net/2007/11/21/the-blog-revisited-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Blog Revisited &#8211; 7</title>
		<link>http://jalaj.net/2007/11/16/the-blog-revisited-7/</link>
		<comments>http://jalaj.net/2007/11/16/the-blog-revisited-7/#comments</comments>
		<pubDate>Fri, 16 Nov 2007 04:46:51 +0000</pubDate>
		<dc:creator>Jalaj</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Application]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[Blogs]]></category>
		<category><![CDATA[Comments]]></category>
		<category><![CDATA[Crawling]]></category>
		<category><![CDATA[Custom CSS]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Domain]]></category>
		<category><![CDATA[FireFox]]></category>
		<category><![CDATA[FlashBack]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[GDI32]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Indian Languages]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Microsoft office]]></category>
		<category><![CDATA[Movies]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Project Management]]></category>
		<category><![CDATA[Registry]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Technorati]]></category>
		<category><![CDATA[Tweaking]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WinAPI]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[MiscPosts]]></category>

		<guid isPermaLink="false">http://jalaj.net/2007/11/16/the-blog-revisited-7/</guid>
		<description><![CDATA[Databases allow datatypes that can store unicode data, then why was it that while MS-Access successfully stored Unicode data whereas MS-SQL server failed when I first tried. See how to handle Unicode data in Storing Unicode Data in Databases.

After of years of existence of internet most of the dictionary words domain seem to have been [...]]]></description>
			<content:encoded><![CDATA[<p>Databases allow datatypes that can store unicode data, then why was it that while MS-Access successfully stored Unicode data whereas MS-SQL server failed when I first tried. See how to handle Unicode data in <a href="http://jalaj.net/2007/04/12/storing-unicode-data-in-databases/">Storing Unicode Data in Databases</a>.<br />
<span id="more-395"></span><br />
After of years of existence of internet most of the dictionary words domain seem to have been already taken. Do you too think so? Check for words from your regional language dictionary as domain names need not necessarily be ASCII one but can be any language text in Unicode. For details see <a href="http://jalaj.net/2007/04/13/international-domain-names/"></a></p>
<p>IME (or Input Method Editor) is an excellent way to type in Regional language text. But what to you do when a few text boxes expect English inputs while others regional inputs... do you need to switch IME on and off every now and then. Not if the software you develop takes care of automatic switching. <a href="http://jalaj.net/2007/04/16/switching-ime-during-runtime/">Switching IME during runtime</a> details how to achieve automatic switching of IME.</p>
<p>Most multilingual softwares allow you to set language options but require you to restart application before language change is effective. If you need immediate UI language change <a href="http://jalaj.net/2007/04/17/changing-ui-language-during-runtime/">Changing UI Language during Runtime</a> is one of the way to do it.</p>
<p>But what if the two languages you aer switching have different orientation of RTL (Right to Left) and LTR(Left to Right)? <a href="http://jalaj.net/2007/04/18/mirroring-form-for-rtl-languages-as-arabic/">Mirroring Form for RTL languages as Arabic</a> detilas how you can switch control locations.</p>
<p>Google Translate gives you facility to translate selected text or entire page between available languages. You can use JavaScript to provide translation button on your site/blog to translate current the current page details of which is here at <a href="http://jalaj.net/2007/04/19/google-translate/">Google Translate</a></p>
<p>Google Desktop supports interface in many languages. <a href="http://jalaj.net/2007/04/27/google-desktop-now-in-hindi/">Google Desktop Now in Hindi</a> came when Hindi language interface was added.</p>
<p>Google Reader allows you to send selected posts from RSS feed you read to your friends or share them and publish as RSS feed for others to subscribe. Read about these in <a href="http://jalaj.net/2007/05/03/more-reasons-to-use-google-reader/">More reasons to use Google Reader</a></p>
<p>After a long gap since my last post on Microsoft Project came <a href="http://jalaj.net/2007/05/10/ms-project-define-general-working-time/">MS Project : Define General Working Time</a> that shows how calendar can be modified globally or resourse-wise.</p>
<p><a href="http://jalaj.net/2007/05/11/get-into-technorati-top-100-in-24-hours/">Get into Technorati Top 100 in 24 Hours</a> was the first post that brought this blog in Growing Blogs list of botd.wordpress.com. "in 24 hours" is just for attracting attention. Applying that in the timeframe may be practical but you cannot get away without getting banned by Technorati... But since Technorati never ever seemed to resolve this problem, you can easily exploit it to get higher rank by avoiding attracting attention.</p>
<p>WinAPI functions saw a slowdown in terms of posts on this blog and subsequent two post were <a href="http://jalaj.net/2007/05/09/winapi-drawtext-drawtextex/">WinAPI : DrawText &amp; DrawTextEx</a> and <a href="http://jalaj.net/2007/05/16/winapi-the-font-object/">WinAPI : The Font Object</a></p>
<p>Google rebranded it's "personalized homepage" as iGoogle. <a href="http://jalaj.net/2007/05/02/whats-in-a-name/">What’s in a Name?</a></p>
<p>5th of February was called for as a CSS "edun" day (read quoted text in reverse, I don't feel eager to categorize my site for "tluda" content <img src='http://jalaj.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) where all blogs were asked to remove CSS for a day. Having upgraded to Custom CSS I had the option to do so. <a href="http://jalaj.net/2007/04/05/no-css-on-5th-april/">No CSS on 5th April</a>.</p>
<p>Microsoft came up with SilverLight to compete with Flash. Read about it here at <a href="http://jalaj.net/2007/04/25/flash-plus-more-with-microsoft-silverlight/">Flash plus more with Microsoft Silverlight</a>. I haven't looked back if it really succeeded or not.</p>
<p>The Flash Chart on Wordpress.com Dashboard are attractive and useful. See where did it originated in <a href="http://jalaj.net/2007/04/23/flash-charts/">Flash Charts</a></p>
<p><a href="http://jalaj.net/2007/04/24/new-features-on-wordpresscom/">New Features on Wordpress.com</a> was update on new features added to wordpress.com and <a href="http://jalaj.net/2007/04/29/twice-the-categories/">Twice the categories</a> was reporting of a bug there.</p>
<p><a href="http://jalaj.net/2007/04/02/last-30-days/">Last 30 days</a> and <a href="http://jalaj.net/2007/05/02/last-30-days-2/">Last 30 Days</a> were stats for April and May, <a href="http://jalaj.net/2007/04/04/ashirwad-projectorg/">Ashirwad-project.org</a> was announcement of a new blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://jalaj.net/2007/11/16/the-blog-revisited-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Font Enumeration Application</title>
		<link>http://jalaj.net/2007/05/28/font-enumeration-application/</link>
		<comments>http://jalaj.net/2007/05/28/font-enumeration-application/#comments</comments>
		<pubDate>Mon, 28 May 2007 14:37:38 +0000</pubDate>
		<dc:creator>Jalaj</dc:creator>
				<category><![CDATA[Application]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[GDI32]]></category>
		<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[WinAPI]]></category>
		<category><![CDATA[TechPosts]]></category>

		<guid isPermaLink="false">http://jalaj.net/2007/05/28/font-enumeration-application/</guid>
		<description><![CDATA[In the previous post in WinAPI series, WinAPI : Enumerating Installed Fonts, EnumFontFamiliesEx function was detailed which allows us to get info on all fonts installed in the system. Let's workout a application on the same.

Create a new Visual Basic project. Create a list box named List1, and change it's "Sorted" property to True. Now [...]]]></description>
			<content:encoded><![CDATA[<p>In the previous post in WinAPI series, <a href="http://jalaj.net/2007/05/23/winapi-enumerating-installed-fonts/">WinAPI : Enumerating Installed Fonts</a>, <b>EnumFontFamiliesEx</b> function was detailed which allows us to get info on all fonts installed in the system. Let's workout a application on the same.<br />
<span id="more-296"></span><br />
Create a new Visual Basic project. Create a list box named List1, and change it's "Sorted" property to True. Now create a new module. Unless stated all the code mentioned will be required to be placed in this module.</p>
<p>Declare the <b>EnumFontFamiliesEx</b> function and relevant Constants and Structures as below.</p>
<pre>
Public Declare Function EnumFontFamiliesEx Lib "gdi32" Alias "EnumFontFamiliesExA" ( _
    ByVal hDC As Long, lpLogFont As LOGFONT, ByVal lpEnumFontProc As Long, _
    ByVal lParam As Long, ByVal dw As Long) As Long

Public Const LF_FACESIZE = 32
Public Const LF_FULLFACESIZE = 64

Public Type NEWTEXTMETRIC
        tmHeight As Long
        tmAscent As Long
        tmDescent As Long
        tmInternalLeading As Long
        tmExternalLeading As Long
        tmAveCharWidth As Long
        tmMaxCharWidth As Long
        tmWeight As Long
        tmOverhang As Long
        tmDigitizedAspectX As Long
        tmDigitizedAspectY As Long
        tmFirstChar As Byte
        tmLastChar As Byte
        tmDefaultChar As Byte
        tmBreakChar As Byte
        tmItalic As Byte
        tmUnderlined As Byte
        tmStruckOut As Byte
        tmPitchAndFamily As Byte
        tmCharSet As Byte
        ntmFlags As Long
        ntmSizeEM As Long
        ntmCellHeight As Long
        ntmAveWidth As Long
End Type

Public Type FONTSIGNATURE
        fsUsb(4) As Long
        fsCsb(2) As Long
End Type

Public Type LOGFONT
        lfHeight As Long
        lfWidth As Long
        lfEscapement As Long
        lfOrientation As Long
        lfWeight As Long
        lfItalic As Byte
        lfUnderline As Byte
        lfStrikeOut As Byte
        lfCharSet As Byte
        lfOutPrecision As Byte
        lfClipPrecision As Byte
        lfQuality As Byte
        lfPitchAndFamily As Byte
        lfFaceName(1 To LF_FACESIZE) As Byte
End Type

Public Type ENUMLOGFONTEX
        elfLogFont As LOGFONT
        elfFullName(LF_FULLFACESIZE) As Byte
        elfStyle(LF_FACESIZE) As Byte
        elfScript(LF_FACESIZE) As Byte
End Type

Public Type NEWTEXTMETRICEX
        ntmTm As NEWTEXTMETRIC
        ntmFontSig As FONTSIGNATURE
End Type
</pre>
<p>The <b>EnumFontFamiliesEx</b> function once called sends all details to callback function <b>EnumFontFamExProc</b>. So let's declare the function. We would be adding more code to this function later.</p>
<pre>
Public Function EnumFontFamExProc(ByRef lpELFX As ENUMLOGFONTEX, _
    ByRef lpNTME As NEWTEXTMETRICEX, ByVal lFontType As Long, _
    ByVal lParam As Long) As Long

End Function
</pre>
<p>Now in the code section of Form place the code in the Load event of form. This will make a call to <b>EnumFontFamiliesEx</b> function.</p>
<pre>
Private Sub Form_Load()

    Dim objlogfont As LOGFONT
    EnumFontFamiliesEx Form1.hDC, objlogfont, AddressOf EnumFontFamExProc, 0, 0

End Sub
</pre>
<p>Now once the <b>EnumFontFamiliesEx</b> function has been called, callback function <b>EnumFontFamExProc</b> will start getting the font details one at a time. Let's first aim at getting all font names and fill them in the listbox List1. Place the code below within the callback function. Since the Font's face name is received as a byteArray we will loop through the 32 bytes and exit when a Null character is encountered. EnumFontFamExProc callback function continues to get data until all fonts have been enumerated or until the callback function returns false (non-zero), hence we have made the function to return 1 on each call.</p>
<pre>
    Dim ctr As Integer
    Dim sFaceName As String

    sFaceName = ""

    For ctr = 1 To LF_FACESIZE
        If lpELFX.elfLogFont.lfFaceName(ctr) = 0 Then
            Exit For
        Else
            sFaceName = sFaceName &amp; Chr(lpELFX.elfLogFont.lfFaceName(ctr))
        End If
    Next

    Form1.List1.AddItem sFaceName

    EnumFontFamExProc = 1
</pre>
<p>Execute the application and find all fonts installed on the system listed in the listbox. That ends the first part of our application.</p>
<p>Now let's add some more functionality using the data that we receive with callback and work on a problem that used to haunt me more often <b>"How to find which Unicode Scripts a font supports?"</b>. As described earlier this information is available with the <b>fsUsb</b> member of the FONTSIGNATURE structure.</p>
<p><b>fsUsb</b> is an array for four Longs, capable of identifying upto 126 Unicode Subranges as defined in ISO 10646 standard. We would here check for the 91 unicode Subranges for which let's create an array carrying the names of the subranges. Add the code below to the module.</p>
<pre>
Public Const MAXSUBRANGELISTEDHERE As Integer = 90

Public UnicodeSubRange(0 To MAXSUBRANGELISTEDHERE) As String

Public Sub PrepareSubRange()

    UnicodeSubRange(0) = "Basic Latin"
    UnicodeSubRange(1) = "Latin-1 Supplement"
    UnicodeSubRange(2) = "Latin Extended-A"
    UnicodeSubRange(3) = "Latin Extended-B"
    UnicodeSubRange(4) = "IPA Extensions"
    UnicodeSubRange(5) = "Spacing Modifier Letters"
    UnicodeSubRange(6) = "Combining Diacritical Marks"
    UnicodeSubRange(7) = "Greek and Coptic"
    UnicodeSubRange(8) = "Reserved"
    UnicodeSubRange(9) = "Cyrillic"
    UnicodeSubRange(10) = "Armenian"
    UnicodeSubRange(11) = "Basic Hebrew"
    UnicodeSubRange(12) = "Reserved"
    UnicodeSubRange(13) = "Basic Arabic"
    UnicodeSubRange(14) = "Reserved"
    UnicodeSubRange(15) = "Devanagari"
    UnicodeSubRange(16) = "Bengali"
    UnicodeSubRange(17) = "Gurmukhi"
    UnicodeSubRange(18) = "Gujarati"
    UnicodeSubRange(19) = "Oriya"
    UnicodeSubRange(20) = "Tamil"
    UnicodeSubRange(21) = "Telugu"
    UnicodeSubRange(22) = "Kannada"
    UnicodeSubRange(23) = "Malayalam"
    UnicodeSubRange(24) = "Thai"
    UnicodeSubRange(25) = "Lao"
    UnicodeSubRange(26) = "Georgian"
    UnicodeSubRange(27) = "Reserved"
    UnicodeSubRange(28) = "Hangul Jamo"
    UnicodeSubRange(29) = "Latin Extended Additional"
    UnicodeSubRange(30) = "Greek Extended"
    UnicodeSubRange(31) = "General Punctuation"
    UnicodeSubRange(32) = "Subscripts and Superscripts"
    UnicodeSubRange(33) = "Currency Symbols"
    UnicodeSubRange(34) = "Combining Diacritical Marks for Symbols"
    UnicodeSubRange(35) = "Letter-like Symbols"
    UnicodeSubRange(36) = "Number Forms"
    UnicodeSubRange(37) = "Arrows"
    UnicodeSubRange(38) = "Mathematical Operators"
    UnicodeSubRange(39) = "Miscellaneous Technical"
    UnicodeSubRange(40) = "Control Pictures"
    UnicodeSubRange(41) = "Optical Character Recognition"
    UnicodeSubRange(42) = "Enclosed Alphanumerics"
    UnicodeSubRange(43) = "Box Drawing"
    UnicodeSubRange(44) = "Block Elements"
    UnicodeSubRange(45) = "Geometric Shapes"
    UnicodeSubRange(46) = "Miscellaneous Symbols"
    UnicodeSubRange(47) = "Dingbats"
    UnicodeSubRange(48) = "Chinese, Japanese, and Korean (CJK) Symbols and Punctuation"
    UnicodeSubRange(49) = "Hiragana"
    UnicodeSubRange(50) = "Katakana"
    UnicodeSubRange(51) = "Bopomofo"
    UnicodeSubRange(52) = "Hangul Compatibility Jamo"
    UnicodeSubRange(53) = "Reserved"
    UnicodeSubRange(54) = "Enclosed CJK Letters and Months"
    UnicodeSubRange(55) = "CJK Compatibility"
    UnicodeSubRange(56) = "Hangul"
    UnicodeSubRange(57) = "Surrogates"
    UnicodeSubRange(58) = "Reserved"
    UnicodeSubRange(59) = "CJK Unified Ideographs"
    UnicodeSubRange(60) = "Private Use Area"
    UnicodeSubRange(61) = "CJK Compatibility Ideographs"
    UnicodeSubRange(62) = "Alphabetic Presentation Forms"
    UnicodeSubRange(63) = "Arabic Presentation Forms-A"
    UnicodeSubRange(64) = "Combining Half Marks"
    UnicodeSubRange(65) = "CJK Compatibility Forms"
    UnicodeSubRange(66) = "Small Form Variants"
    UnicodeSubRange(67) = "Arabic Presentation Forms-B"
    UnicodeSubRange(68) = "Halfwidth and Fullwidth Forms"
    UnicodeSubRange(69) = "Specials"
    UnicodeSubRange(70) = "Tibetan"
    UnicodeSubRange(71) = "Syriac"
    UnicodeSubRange(72) = "Thaana"
    UnicodeSubRange(73) = "Sinhala"
    UnicodeSubRange(74) = "Myanmar"
    UnicodeSubRange(75) = "Ethiopic"
    UnicodeSubRange(76) = "Cherokee"
    UnicodeSubRange(77) = "Canadian Aboriginal Syllabics"
    UnicodeSubRange(78) = "Ogham"
    UnicodeSubRange(79) = "Runic"
    UnicodeSubRange(80) = "Khmer"
    UnicodeSubRange(81) = "Mongolian"
    UnicodeSubRange(82) = "Braille"
    UnicodeSubRange(83) = "Yi"
    UnicodeSubRange(84) = "Tagalog"
    UnicodeSubRange(85) = "Old Italic"
    UnicodeSubRange(86) = "Gothic"
    UnicodeSubRange(87) = "Deseret"
    UnicodeSubRange(88) = "Byzantine Musical Symbols"
    UnicodeSubRange(89) = "Mathematical Alphanumeric Symbols"
    UnicodeSubRange(90) = "Private Use (Plane 15)"

End Sub
</pre>
<p>Since we have initialized all Subrange names in a subroutine we need to call it on Load event of the form. Add the line below to the Load event of the Form.</p>
<pre>
    Call PrepareSubRange
</pre>
<p>Add another listbox List2 on the form. Our aim is that when a font is selected from List1 the Unicode Subranges, whose glyphs are present in the font, should get listed in this new listbox. This has one concern that the FONTSIGNATURE structure for the font is available when the callback function is called. If we need to use those, the same must be preserved while processing the callback. Let's store them in an array. Signature is the array where we would be storing the fsUsb and FontCtr is the counter which will store the number of fonts that have been processed.</p>
<pre>
Public Signature() As Variant
Public FontCtr As Long
</pre>
<p>Add the following code at the end of the callback function. The Signature array is redimensioned on each callback, font name and fsUsb is stored and the FontCtr is incremented by 1.</p>
<pre>
    If FontCtr &gt; 0 Then
        ReDim Preserve Signature(0 To 1, 0 To FontCtr + 1)
    Else
        ReDim Signature(0 To 1, 0 To 0)
    End If

    Signature(0, FontCtr) = sFaceName
    Signature(1, FontCtr) = lpNTME.ntmFontSig.fsUsb
    FontCtr = FontCtr + 1
</pre>
<p>Now once the required information has been saved, we just require to use it when the selection in the List1 changes to populate the List2. Let's code this functionality in a separate subroutine named "PopulateList2" and call this subroutine from the Click event of the List1. Add the following line to the Click event of the List1 in the Form.</p>
<pre>
Private Sub List1_Click()

    Call PopulateList2

End Sub
</pre>
<p>Now for the last part the PopulateList2 subroutine. This clears the List2. It then searches for the Font Name (as selected in the List1) in the Signature array and stores the corresponding fsUsb array in the variable vSig. It then runs through the complete list of Unicode SubRanges and uses Bitwise operations to check if the glyphs for the subrange exist in the font or not. If present, populates the List2 with the corresponding SubRange name.</p>
<pre>
Public Sub PopulateList2()

    Dim vSig As Variant
    Dim p As Integer
    Dim q As Integer
    Dim ctr As Integer

    Form1.List2.Clear

    For ctr = 0 To UBound(Signature, 2)
        If Signature(0, ctr) = Form1.List1.Text Then Exit For
    Next

    vSig = Signature(1, ctr)

    For ctr = 0 To MAXSUBRANGELISTEDHERE
        p = Int(ctr / 32)
        q = ctr Mod 32

        If q &lt;&gt; 31 Then
            If vSig(p) And 2 ^ q Then
                Form1.List2.AddItem UnicodeSubRange(ctr)
            End If
        Else
            If vSig(p) &lt; 0 Then
                Form1.List2.AddItem UnicodeSubRange(ctr)
            End If
        End If
    Next

End Sub
</pre>
<p>And that completes our application. The complete Source code is repeated below to facilitate direct copy/paste.<br />
<!--more--></p>
<pre>
<b>Code in Form1</b>

Private Sub Form_Load()

    Dim objlogfont As LOGFONT
    Call PrepareSubRange
    EnumFontFamiliesEx Form1.hDC, objlogfont, AddressOf EnumFontFamExProc, 0, 0

End Sub

Private Sub List1_Click()

    Call PopulateList2

End Sub
</pre>
<pre>
<b>Code in Module1</b>

Option Explicit

Public Declare Function EnumFontFamiliesEx Lib "gdi32" Alias "EnumFontFamiliesExA" ( _
    ByVal hDC As Long, lpLogFont As LOGFONT, ByVal lpEnumFontProc As Long, _
    ByVal lParam As Long, ByVal dw As Long) As Long

Public Const MAXSUBRANGELISTEDHERE As Integer = 90
Public Const LF_FACESIZE = 32
Public Const LF_FULLFACESIZE = 64

Public UnicodeSubRange(0 To MAXSUBRANGELISTEDHERE) As String
Public Signature() As Variant
Public FontCtr As Long

Public Type NEWTEXTMETRIC
        tmHeight As Long
        tmAscent As Long
        tmDescent As Long
        tmInternalLeading As Long
        tmExternalLeading As Long
        tmAveCharWidth As Long
        tmMaxCharWidth As Long
        tmWeight As Long
        tmOverhang As Long
        tmDigitizedAspectX As Long
        tmDigitizedAspectY As Long
        tmFirstChar As Byte
        tmLastChar As Byte
        tmDefaultChar As Byte
        tmBreakChar As Byte
        tmItalic As Byte
        tmUnderlined As Byte
        tmStruckOut As Byte
        tmPitchAndFamily As Byte
        tmCharSet As Byte
        ntmFlags As Long
        ntmSizeEM As Long
        ntmCellHeight As Long
        ntmAveWidth As Long
End Type

Public Type FONTSIGNATURE
        fsUsb(4) As Long
        fsCsb(2) As Long
End Type

Public Type LOGFONT
        lfHeight As Long
        lfWidth As Long
        lfEscapement As Long
        lfOrientation As Long
        lfWeight As Long
        lfItalic As Byte
        lfUnderline As Byte
        lfStrikeOut As Byte
        lfCharSet As Byte
        lfOutPrecision As Byte
        lfClipPrecision As Byte
        lfQuality As Byte
        lfPitchAndFamily As Byte
        lfFaceName(1 To LF_FACESIZE) As Byte
End Type

Public Type ENUMLOGFONTEX
        elfLogFont As LOGFONT
        elfFullName(LF_FULLFACESIZE) As Byte
        elfStyle(LF_FACESIZE) As Byte
        elfScript(LF_FACESIZE) As Byte
End Type

Public Type NEWTEXTMETRICEX
        ntmTm As NEWTEXTMETRIC
        ntmFontSig As FONTSIGNATURE
End Type

Public Sub PrepareSubRange()

    UnicodeSubRange(0) = "Basic Latin"
    UnicodeSubRange(1) = "Latin-1 Supplement"
    UnicodeSubRange(2) = "Latin Extended-A"
    UnicodeSubRange(3) = "Latin Extended-B"
    UnicodeSubRange(4) = "IPA Extensions"
    UnicodeSubRange(5) = "Spacing Modifier Letters"
    UnicodeSubRange(6) = "Combining Diacritical Marks"
    UnicodeSubRange(7) = "Greek and Coptic"
    UnicodeSubRange(8) = "Reserved"
    UnicodeSubRange(9) = "Cyrillic"
    UnicodeSubRange(10) = "Armenian"
    UnicodeSubRange(11) = "Basic Hebrew"
    UnicodeSubRange(12) = "Reserved"
    UnicodeSubRange(13) = "Basic Arabic"
    UnicodeSubRange(14) = "Reserved"
    UnicodeSubRange(15) = "Devanagari"
    UnicodeSubRange(16) = "Bengali"
    UnicodeSubRange(17) = "Gurmukhi"
    UnicodeSubRange(18) = "Gujarati"
    UnicodeSubRange(19) = "Oriya"
    UnicodeSubRange(20) = "Tamil"
    UnicodeSubRange(21) = "Telugu"
    UnicodeSubRange(22) = "Kannada"
    UnicodeSubRange(23) = "Malayalam"
    UnicodeSubRange(24) = "Thai"
    UnicodeSubRange(25) = "Lao"
    UnicodeSubRange(26) = "Georgian"
    UnicodeSubRange(27) = "Reserved"
    UnicodeSubRange(28) = "Hangul Jamo"
    UnicodeSubRange(29) = "Latin Extended Additional"
    UnicodeSubRange(30) = "Greek Extended"
    UnicodeSubRange(31) = "General Punctuation"
    UnicodeSubRange(32) = "Subscripts and Superscripts"
    UnicodeSubRange(33) = "Currency Symbols"
    UnicodeSubRange(34) = "Combining Diacritical Marks for Symbols"
    UnicodeSubRange(35) = "Letter-like Symbols"
    UnicodeSubRange(36) = "Number Forms"
    UnicodeSubRange(37) = "Arrows"
    UnicodeSubRange(38) = "Mathematical Operators"
    UnicodeSubRange(39) = "Miscellaneous Technical"
    UnicodeSubRange(40) = "Control Pictures"
    UnicodeSubRange(41) = "Optical Character Recognition"
    UnicodeSubRange(42) = "Enclosed Alphanumerics"
    UnicodeSubRange(43) = "Box Drawing"
    UnicodeSubRange(44) = "Block Elements"
    UnicodeSubRange(45) = "Geometric Shapes"
    UnicodeSubRange(46) = "Miscellaneous Symbols"
    UnicodeSubRange(47) = "Dingbats"
    UnicodeSubRange(48) = "Chinese, Japanese, and Korean (CJK) Symbols and Punctuation"
    UnicodeSubRange(49) = "Hiragana"
    UnicodeSubRange(50) = "Katakana"
    UnicodeSubRange(51) = "Bopomofo"
    UnicodeSubRange(52) = "Hangul Compatibility Jamo"
    UnicodeSubRange(53) = "Reserved"
    UnicodeSubRange(54) = "Enclosed CJK Letters and Months"
    UnicodeSubRange(55) = "CJK Compatibility"
    UnicodeSubRange(56) = "Hangul"
    UnicodeSubRange(57) = "Surrogates"
    UnicodeSubRange(58) = "Reserved"
    UnicodeSubRange(59) = "CJK Unified Ideographs"
    UnicodeSubRange(60) = "Private Use Area"
    UnicodeSubRange(61) = "CJK Compatibility Ideographs"
    UnicodeSubRange(62) = "Alphabetic Presentation Forms"
    UnicodeSubRange(63) = "Arabic Presentation Forms-A"
    UnicodeSubRange(64) = "Combining Half Marks"
    UnicodeSubRange(65) = "CJK Compatibility Forms"
    UnicodeSubRange(66) = "Small Form Variants"
    UnicodeSubRange(67) = "Arabic Presentation Forms-B"
    UnicodeSubRange(68) = "Halfwidth and Fullwidth Forms"
    UnicodeSubRange(69) = "Specials"
    UnicodeSubRange(70) = "Tibetan"
    UnicodeSubRange(71) = "Syriac"
    UnicodeSubRange(72) = "Thaana"
    UnicodeSubRange(73) = "Sinhala"
    UnicodeSubRange(74) = "Myanmar"
    UnicodeSubRange(75) = "Ethiopic"
    UnicodeSubRange(76) = "Cherokee"
    UnicodeSubRange(77) = "Canadian Aboriginal Syllabics"
    UnicodeSubRange(78) = "Ogham"
    UnicodeSubRange(79) = "Runic"
    UnicodeSubRange(80) = "Khmer"
    UnicodeSubRange(81) = "Mongolian"
    UnicodeSubRange(82) = "Braille"
    UnicodeSubRange(83) = "Yi"
    UnicodeSubRange(84) = "Tagalog"
    UnicodeSubRange(85) = "Old Italic"
    UnicodeSubRange(86) = "Gothic"
    UnicodeSubRange(87) = "Deseret"
    UnicodeSubRange(88) = "Byzantine Musical Symbols"
    UnicodeSubRange(89) = "Mathematical Alphanumeric Symbols"
    UnicodeSubRange(90) = "Private Use (Plane 15)"

End Sub

Public Function EnumFontFamExProc(ByRef lpELFX As ENUMLOGFONTEX, _
    ByRef lpNTME As NEWTEXTMETRICEX, ByVal lFontType As Long, _
    ByVal lParam As Long) As Long

    Dim ctr As Integer
    Dim sFaceName As String

    sFaceName = ""

    For ctr = 1 To LF_FACESIZE
        If lpELFX.elfLogFont.lfFaceName(ctr) = 0 Then
            Exit For
        Else
            sFaceName = sFaceName &amp; Chr(lpELFX.elfLogFont.lfFaceName(ctr))
        End If
    Next

    Form1.List1.AddItem sFaceName

    If FontCtr &gt; 0 Then
        ReDim Preserve Signature(0 To 1, 0 To FontCtr + 1)
    Else
        ReDim Signature(0 To 1, 0 To 0)
    End If

    Signature(0, FontCtr) = sFaceName
    Signature(1, FontCtr) = lpNTME.ntmFontSig.fsUsb
    FontCtr = FontCtr + 1

    EnumFontFamExProc = 1

End Function

Public Sub PopulateList2()

    Dim vSig As Variant
    Dim p As Integer
    Dim q As Integer
    Dim ctr As Integer

    Form1.List2.Clear

    For ctr = 0 To UBound(Signature, 2)
        If Signature(0, ctr) = Form1.List1.Text Then Exit For
    Next

    vSig = Signature(1, ctr)

    For ctr = 0 To MAXSUBRANGELISTEDHERE
        p = Int(ctr / 32)
        q = ctr Mod 32

        If q &lt;&gt; 31 Then
            If vSig(p) And 2 ^ q Then
                Form1.List2.AddItem UnicodeSubRange(ctr)
            End If
        Else
            If vSig(p) &lt; 0 Then
                Form1.List2.AddItem UnicodeSubRange(ctr)
            End If
        End If
    Next

End Sub
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jalaj.net/2007/05/28/font-enumeration-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WinAPI : Enumerating Installed Fonts</title>
		<link>http://jalaj.net/2007/05/23/winapi-enumerating-installed-fonts/</link>
		<comments>http://jalaj.net/2007/05/23/winapi-enumerating-installed-fonts/#comments</comments>
		<pubDate>Wed, 23 May 2007 14:10:23 +0000</pubDate>
		<dc:creator>Jalaj</dc:creator>
				<category><![CDATA[Functions]]></category>
		<category><![CDATA[GDI32]]></category>
		<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[WinAPI]]></category>
		<category><![CDATA[TechPosts]]></category>

		<guid isPermaLink="false">http://jalaj.wordpress.com/2007/05/23/winapi-enumerating-installed-fonts/</guid>
		<description><![CDATA[Now after the last post WinAPI : The Font Object, let's see what all fonts are installed on your system. We would do this with the help of EnumFontFamiliesEx function. Once you have called he function, you receive each of the (matching) font's details vide callback function EnumFontFamExProc.

The EnumFontFamiliesEx function as defined below takes the [...]]]></description>
			<content:encoded><![CDATA[<p>Now after the last post <a href="http://jalaj.net/2007/05/16/winapi-the-font-object/">WinAPI : The Font Object</a>, let's see what all fonts are installed on your system. We would do this with the help of <b>EnumFontFamiliesEx</b> function. Once you have called he function, you receive each of the (matching) font's details vide callback function <b>EnumFontFamExProc</b>.<br />
<span id="more-280"></span><br />
The EnumFontFamiliesEx function as defined below takes the first parameter the handle to the Device Context. The Second parameter that it takes is the pointer to the LOGFONT structure, already described in the last post. This parameter is used by the system to determine which of the font's details you require, passing a Null provides you with details of all of them. The next parameter that it takes is the pointer to the <b>EnumFontFamExProc</b> callback function. Next parameter lParam is the application defined value which is returned to the callback function with the other details. Last parameter is unused and should be passed as Zero.</p>
<pre>
Public Declare Function EnumFontFamiliesEx Lib "gdi32" Alias "EnumFontFamiliesExA" ( _
	ByVal hDC As Long, lpLogFont As LOGFONT, ByVal lpEnumFontProc As Long, _
	ByVal lParam As Long, ByVal dw As Long) As Long
</pre>
<p>Now lets see what the <b>EnumFontFamExProc</b> callback function looks like.</p>
<pre>
Public Function EnumFontFamExProc(ByRef lpELFX As ENUMLOGFONTEX, _
	ByRef lpNTME As NEWTEXTMETRICEX, ByVal lFontType As Long, _
	ByVal lParam As Long) As Long
. . .
. . .
. . .
End Function
</pre>
<p>The first parameter is the pointer to the ENUMLOGFONTEX structure giving logical font data, detailed later. The second parameter is the pointer to the NEWTEXTMETRICEX structure that gives the physical font data, also detailed later. Next parameter is FontType which can be equal to one of the constants as defined below. Last parameter is the lParam as was passed while calling the <b>EnumFontFamiliesEx</b> function.</p>
<pre>
Public Const RASTER_FONTTYPE = 1
Public Const DEVICE_FONTTYPE = 2
Public Const TRUETYPE_FONTTYPE = 4
</pre>
<p>ENUMLOGFONTEX structure as defined below contains a LOGFONT structure, Full name of the font (a Null terminated string, 64 bytes), a Null terminated string of 32 bytes specifying the style of the font, and a Null terminated string of 32 bytes specifying the script or character set of the font.</p>
<pre>
Public Const LF_FACESIZE = 32
Public Const LF_FULLFACESIZE = 64

Public Type ENUMLOGFONTEX
        elfLogFont As LOGFONT
        elfFullName(LF_FULLFACESIZE) As Byte
        elfStyle(LF_FACESIZE) As Byte
        elfScript(LF_FACESIZE) As Byte
End Type
</pre>
<p>The NEWTEXTMETRICEX structure as defined below itself consolidates the other two structures NEWTEXTMETRIC and FONTSIGNATURE also defined below.</p>
<pre>
Public Type NEWTEXTMETRICEX
        ntmTm As NEWTEXTMETRIC
        ntmFontSig As FONTSIGNATURE
End Type

Public Type NEWTEXTMETRIC
        tmHeight As Long
        tmAscent As Long
        tmDescent As Long
        tmInternalLeading As Long
        tmExternalLeading As Long
        tmAveCharWidth As Long
        tmMaxCharWidth As Long
        tmWeight As Long
        tmOverhang As Long
        tmDigitizedAspectX As Long
        tmDigitizedAspectY As Long
        tmFirstChar As Byte
        tmLastChar As Byte
        tmDefaultChar As Byte
        tmBreakChar As Byte
        tmItalic As Byte
        tmUnderlined As Byte
        tmStruckOut As Byte
        tmPitchAndFamily As Byte
        tmCharSet As Byte
        ntmFlags As Long
        ntmSizeEM As Long
        ntmCellHeight As Long
        ntmAveWidth As Long
End Type

Public Type FONTSIGNATURE
        fsUsb(4) As Long
        fsCsb(2) As Long
End Type
</pre>
<p>The members in the NEWTEXTMETRIC structure are as under:<br />
<b>tmHeight</b> - Specifies the height (ascent + descent) of characters.<br />
<b>tmAscent</b> - Specifies the ascent (units above the base line) of characters.<br />
<b>tmDescent</b> - Specifies the descent (units below the base line) of characters.<br />
<b>tmInternalLeading</b> - Specifies the amount of leading (space) inside the bounds set by the tmHeight member. Accent marks and other diacritical characters, if any, occurs in this area.<br />
<b>tmExternalLeading</b> - Specifies the amount of extra leading (space) that the application adds between rows. This area is outside the font, and hence can contain no marks.<br />
<b>tmAveCharWidth</b> - Specifies the average width of characters in the font (generally defined as the width of the letter x). This value does not include overhang required for bold or italic characters.<br />
<b>tmMaxCharWidth</b> - Specifies the width of the widest character in the font.<br />
<b>tmWeight</b> - Specifies the weight of the font.<br />
<b>tmOverhang</b> - Specifies the extra width per string that may be added to some synthesized fonts. When synthesizing some attributes, such as bold or italic, graphics device interface (GDI) or a device may have to add width to a string on both a per-character and per-string basis. <b>tmDigitizedAspectX</b> - Specifies the horizontal aspect of the device for which the font was designed.<br />
<b>tmDigitizedAspectY</b> - Specifies the vertical aspect of the device for which the font was designed. The ratio of the tmDigitizedAspectX and tmDigitizedAspectY members is the aspect ratio of the device for which the font was designed.<br />
<b>tmFirstChar</b> - Specifies the value of the first character defined in the font.<br />
<b>tmLastChar</b> - Specifies the value of the last character defined in the font.<br />
<b>tmDefaultChar</b> - Specifies the value of the character to be substituted for characters that are not in the font.<br />
<b>tmBreakChar</b> - Specifies the value of the character to be used to define word breaks for text justification.<br />
<b>tmItalic</b> - Specifies an italic font if it is nonzero.<br />
<b>tmUnderlined</b> - Specifies an underlined font if it is nonzero.<br />
<b>tmStruckOut</b> - Specifies a strikeout font if it is nonzero.<br />
<b>tmPitchAndFamily</b> - Specifies the pitch and family of the selected font. For details see the LOGFONT structure in post <a href="http://jalaj.net/2007/05/16/winapi-the-font-object/">WinAPI : The Font Object</a>.<br />
<b>tmCharSet</b> - Specifies the character set of the font.<br />
<b>ntmFlags</b> - Specifies whether the font is italic, underscored, outlined, bold, and so forth. May be any reasonable combination of the following values as defined below.</p>
<pre>
Const NTM_ITALIC = 1
Const NTM_BOLD = 32
Const NTM_REGULAR = 256
Const NTM_NONNEGATIVE_AC = 65536 	' Win2000/XP
Const NTM_PS_OPENTYPE = 131072	' Win2000/XP
Const NTM_TT_OPENTYPE = 262144	' Win2000/XP
Const NTM_MULTIPLEMASTER = 524288	' Win2000/XP
Const NTM_TYPE1 = 1048576 		' Win2000/XP
Const NTM_DSIG = 2097152		' Win2000/XP
</pre>
<p><b>ntmSizeEM</b> - Specifies the size of the em square for the font. This value is in notional units (that is, the units for which the font was designed).<br />
<b>ntmCellHeight</b> - Specifies the height, in notional units, of the font. This value should be compared with the value of the ntmSizeEM member.<br />
<b>ntmAvgWidth</b> - Specifies the average width of characters in the font, in notional units. This value should be compared with the value of the ntmSizeEM member.</p>
<p>The FONTSIGNATURE structure contains two members :<br />
<b>fsUsb</b> - an array of four longs, making up for 128 bits that identify upto 126 Unicode Subranges as defined in ISO 10646 standard.<br />
<b>fsCsb</b> - an array of two longs, making up for 64 bits that identifies Character sets or Code Page.</p>
<p>Next post(s) on the WinAPI functions will demonstrate practical usage of these functions...</p>
]]></content:encoded>
			<wfw:commentRss>http://jalaj.net/2007/05/23/winapi-enumerating-installed-fonts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WinAPI : DrawText &amp; DrawTextEx</title>
		<link>http://jalaj.net/2007/05/09/winapi-drawtext-drawtextex/</link>
		<comments>http://jalaj.net/2007/05/09/winapi-drawtext-drawtextex/#comments</comments>
		<pubDate>Wed, 09 May 2007 06:54:02 +0000</pubDate>
		<dc:creator>Jalaj</dc:creator>
				<category><![CDATA[Functions]]></category>
		<category><![CDATA[GDI32]]></category>
		<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[WinAPI]]></category>
		<category><![CDATA[TechPosts]]></category>

		<guid isPermaLink="false">http://jalaj.wordpress.com/2007/05/09/winapi-drawtext-drawtextex/</guid>
		<description><![CDATA[My last post on the WinAPI series was WinAPI : Displaying Text. Let's get ahead with more WinAPI functions starting with DrawText and DrawTextEx functions.


Public Declare Function DrawText Lib "user32" Alias "DrawTextA" ( _
	ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, _
	lpRect As RECT, ByVal wFormat As Long) As Long

Public Type [...]]]></description>
			<content:encoded><![CDATA[<p>My last post on the <a href="http://jalaj.net/tag/winapi/">WinAPI</a> series was <a href="http://jalaj.net/2007/03/12/winapi-displaying-text/">WinAPI : Displaying Text</a>. Let's get ahead with more WinAPI functions starting with <b>DrawText</b> and <b>DrawTextEx</b> functions.<br />
<span id="more-231"></span></p>
<pre>
Public Declare Function DrawText Lib "user32" Alias "DrawTextA" ( _
	ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, _
	lpRect As RECT, ByVal wFormat As Long) As Long

Public Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type
</pre>
<p>While the <b>TextOut</b> function required you to specify only the top-left co-ordinates to write out the text, <b>DrawText</b> requires you to specify the rectangular area where you need to draw and also expects you to specify formatting options as to how text should be aligned or so within the rectangle. The first parameter is takes is the handle to the input context, second the string that you need to print out, next the number of characters from the string to be printed out. The next two parameters are the pointer to the RECT structure and the formatting option (which may be one or more of constants defined below) respectively.</p>
<pre>
Const DT_LEFT = &amp;H0
Const DT_TOP = &amp;H0
Const DT_CENTER = &amp;H1
Const DT_RIGHT = &amp;H2
Const DT_VCENTER = &amp;H4
Const DT_BOTTOM = &amp;H8
</pre>
<p>The above constants may be used for vertical/horizontal alignment of the text (default Top-Left). Vertical alignment can be modified only in case of SingleLines (as defined below).</p>
<pre>
Const DT_WORDBREAK = &amp;H10
</pre>
<p>Using the constant above ensures that line is automatically broken between words. In absence of this constant the line would break only when encounter carriage return and line feed sequence, and all words that moved out of rectangular area being clipped.</p>
<pre>
Const DT_SINGLELINE = &amp;H20
</pre>
<p>Using constant above makes the text to display in a single line. Even the carriage return line feed sequence are not considered for moving to next line.</p>
<pre>
Const DT_EXPANDTABS = &amp;H40
Const DT_TABSTOP = &amp;H80
</pre>
<p>DT_EXPANDTABS causes Tab characters to be shown as a sequence of eight (default) space characters. This default value can be modified using constant DT_TABSTOP (am unsure of how? Inputs welcome)</p>
<pre>
Const DT_NOCLIP = &amp;H100
</pre>
<p>Constant above ensures that the words are not clipped if they extend beyond the rectangle defined.</p>
<pre>
Const DT_EXTERNALLEADING = &amp;H200
</pre>
<p>Leading is the vertical space that separates the two lines. Normally the leading as defined in the font is not considered for drawing the text by the function. Including the constant as above it to be included in drawing the text.</p>
<pre>
Const DT_CALCRECT = &amp;H400
</pre>
<p>The above constant can be used to calculate the optimum size of the rectangle that would be required to print out the text. Using this constant doesnot cause the text to be printed but instead modifies the RECT structure passed to the function appropriately.</p>
<pre>
Const DT_NOPREFIX = &amp;H800
Const DT_HIDEPREFIX = &amp;H100000	'WinXP onwards
Const DT_PREFIXONLY = &amp;H200000	'WinXP onwards
</pre>
<p>By default the <b>DrawText function</b> considers presence of and ampersand ('&amp;') as a directive to underline the character that follows, while '&amp;' itself is not drawn. In order to display '&amp;' you need to give '&amp; &amp;'. Using the constant as above turns off this nature and draws '&amp;' as it is. The other two constants that were included in WindowsXP. DT_HIDEPREFIX instructs the function to refrain from showing any underlined characters so existence of an '&amp;' which otherwise would have shown character following it as underlined (or shown itself as it is if DT_NOPREFIX used) will neither show the '&amp;' noor the underlining of the next character. DT_PREFIXONLY causes the function to display nothing other than the Underline itself (at location where the character that it underlined would have appeared.</p>
<pre>
Const DT_INTERNAL = &amp;H1000
</pre>
<p>"Uses the system font to calculate text metrics." (as described in MSDN, unsure of what it actually meant)</p>
<pre>
Const DT_EDITCONTROL = &amp;H2000
</pre>
<p>Normally for a multiline text if the rectangle is not large enough to accommodate all text a few lines moving outside the rectangle are clipped and the clipping is done without checking in case a line at the bottom is partially visible. Using this constant ensures that such partially visible lines are not shown at all.</p>
<pre>
Const DT_END_ELLIPSIS = &amp;H8000
Const DT_WORD_ELLIPSIS = &amp;H40000
Const DT_PATH_ELLIPSIS = &amp;H4000
</pre>
<p>The above three constants are useful if the string is large enough to fit into the rectangle, where it truncates the string adding ellipses '...' (at the end for the first two and in-between for the last). The three constants vary in the manner the addition of ellipses is done. For DT_END_ELLIPSIS it truncates all complete words that move out of rectangle area and adds the ellipses at the end. In this case the ellipses may not always be visible as the last word after which the ellipses occur may itself be clipped by the bounding rectangle. DT_END_ELLIPSIS ensures that the ellipses are visible even if the last word itself needs to be partially-truncated for achieving the same. DT_PATH_ELLIPSIS is useful for showing the strings containing file paths (You may find this being applied in a Anti-Virus or similar software), where it is ensured that most of the filename is kept intact and the ellipses is added in midst of the string to hide part of the folder structure.</p>
<pre>
Const DT_MODIFYSTRING = &amp;H10000
</pre>
<p>The above constant ensures that the string itself is modified to match it with that visible within the rectangle.</p>
<pre>
Const DT_RTLREADING = &amp;H20000
</pre>
<p>Useful for rendering bi-directional text in Arabic and Hebrew fonts.</p>
<pre>
Const DT_NOFULLWIDTHCHARBREAK = &amp;H80000
</pre>
<p>For Win98 onwards. Ensures that line break does not occur between Double Byte Character String (DBCS).</p>
<p><b>DrawTextEx</b> function adds one for input parameter which is a pointer to the DRAWTEXTPARAMS structure defined below allowing you to configure the Character length for a Tab, Right and Left Margin that should be left while drawing within the rectangle. All other details remain the same as with <b>DrawText</b> function.</p>
<pre>
Public Declare Function DrawTextEx Lib "user32" Alias "DrawTextExA" ( _
	ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, _
	lpRect As RECT, ByVal wFormat As Long, _
	lpDrawTextParams As DRAWTEXTPARAMS) As Long

Public Type DRAWTEXTPARAMS
	cbSize As Long
	iTabLength As Long
	iLeftMargin As Long
	iRightMargin As Long
	uiLengthDrawn As Long
End Type
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jalaj.net/2007/05/09/winapi-drawtext-drawtextex/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WinAPI : Displaying Text</title>
		<link>http://jalaj.net/2007/03/12/winapi-displaying-text/</link>
		<comments>http://jalaj.net/2007/03/12/winapi-displaying-text/#comments</comments>
		<pubDate>Mon, 12 Mar 2007 11:46:42 +0000</pubDate>
		<dc:creator>Jalaj</dc:creator>
				<category><![CDATA[Functions]]></category>
		<category><![CDATA[GDI32]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[SetTextAlign]]></category>
		<category><![CDATA[SetTextColor]]></category>
		<category><![CDATA[Text]]></category>
		<category><![CDATA[TextOut]]></category>
		<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[WinAPI]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[TechPosts]]></category>

		<guid isPermaLink="false">http://jalaj.wordpress.com/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's get on to displaying texts on a Device Context.

The most basic function for the purpose is the TextOut. The function takes handle to the device context as the first parameter. The next two parameters are the X [...]]]></description>
			<content:encoded><![CDATA[<p>After getting a feel of how Pens and Brushes are used for drawing on a Device Context, let's get on to displaying texts on a Device Context.<br />
<span id="more-169"></span><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>
]]></content:encoded>
			<wfw:commentRss>http://jalaj.net/2007/03/12/winapi-displaying-text/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
