<?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>Fooling Around &#187; WTL</title>
	<atom:link href="http://alax.info/blog/tag/wtl/feed" rel="self" type="application/rss+xml" />
	<link>http://alax.info/blog</link>
	<description>// Software Production Line</description>
	<lastBuildDate>Wed, 02 May 2012 15:42:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Common Controls: Versions, Compatibility, WTL</title>
		<link>http://alax.info/blog/1306</link>
		<comments>http://alax.info/blog/1306#comments</comments>
		<pubDate>Sun, 30 Oct 2011 19:55:52 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[WTL]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[compatibility]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1306</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1306" title="Common Controls: Versions, Compatibility, WTL"></a>An application appears to be not working in Windows XP in a weird way: rebar control appeared to fail showing up. Where the application is expected to look much nicer with rebar control as a container for menu (implemented as &#8230;<p class="read-more"><a href="http://alax.info/blog/1306">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1306" title="Common Controls: Versions, Compatibility, WTL"></a><p>An application appears to be not working in Windows XP in a weird way: <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb774373%28v=vs.85%29.aspx">rebar control</a> appeared to fail showing up.</p>
<p><img class="alignnone size-full wp-image-1310" title="Rebar Failed" src="http://alax.info/blog/wp-content/uploads/2011/10/Image003.png" alt="" width="640" height="238" /></p>
<p>Where the application is expected to look much nicer with rebar control as a container for menu (implemented as command bar WTL control) and toolbar with buttons:</p>
<p><img class="alignnone size-full wp-image-1309" title="Rebar Succeeded" src="http://alax.info/blog/wp-content/uploads/2011/10/Image0022.png" alt="" width="640" height="238" /></p>
<p>A WTL sample project generated by a Visual Studio wizard would never give such effect, and the bug was a combination of factors:</p>
<ol>
<li>An application built with a newer version of Windows SDK, which includes support for features (Windows Vista+ Common Controls) that are more recent than production environment (Windows XP); the application targets to Windows Vista+ environment too (<em>_WIN32_WINNT</em> &gt;= <em>0&#215;0600</em>)</li>
<li>Compatibility issues of Common Controls library</li>
<li>WTL version (7.5), which did not yet include a workaround for the problem</li>
</ol>
<p>The problem, which caused the bug directly was the <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb774393%28v=vs.85%29.aspx">REBARBANDINFO structure</a> and its use as an argument with Common Controls API. As MSDN shows, the structure was amended twice with additional fields.</p>
<p>One of the way to support multiple versions of the structure definition, and to resolve compatibility issues, is to embed structure size into structure payload. In fact, <em>REBARBANDINFO::cbSize</em> member is there exactly for this reason.</p>
<p>The application is normally filling <em>cbSize</em> with the maximal known structure size and fills the rest of the fields respectively. The API is expected to be checking <em>cbSize</em> member and be detecting API version compatibility scenarios:</p>
<ol>
<li><em>cbSize</em> holds exactly the value the API expects (that is, the maximal value known/defined to the API) &#8211; the simplest scenario where the API and the application are on the same page, both are using the same versions of the &#8220;protocol&#8221;/interface.</li>
<li><em>cbSize</em> is smaller than API can support &#8211; the API sees that it is dealing with a sort of legacy application which cannot utilize all available features, and the API acts respectively supporting the older part of the protocol, and keeping defaults or &#8220;old look&#8221; for the rest of implementation. This addresses backward compatibility: the newer API works with apps designed for older version of the API</li>
<li><em>cbSize</em> is greater then API can support &#8211; the API sees that the application is already aware of newer version API and is possibly requesting some of the missing features. The API might be ignoring the unsupported part in assumption that API evolution tool place keeping some compatibility in mind, and still do the best it can with the existing implementation. Or, the API might just fail to work.</li>
</ol>
<p>The latter item #3 is the scenario here with rebar control. The application is using Windows Vista version of <em>REBARBANDINFO</em> structure and Windows XP implementation choses to completely fail.</p>
<p>While it does not seem to be directly a bug, this attitude is definitely not developer friendly: there is no reason for the control to not work in its best and default way. Having API acting this way, each developer using the API needs to take care of the situation explicitly: whenever Windows Vista enabled application needs to be able to run in Windows XP system, the code aroundÂ <em>REBARBANDINFO</em> would look like this:</p>
<pre style="color: #000000; background: #ffffff;">REBARBANDINFO BandInformation <span style="color: #808030;">=</span> <span style="color: #800080;">{</span> <span style="color: #800000; font-weight: bold;">sizeof</span> BandInformation<span style="color: #808030;">,</span> RBBIM_LPARAM <span style="color: #800080;">}</span><span style="color: #800080;">;</span>
<span style="color: #004a43;">#</span><span style="color: #004a43;">if</span><span style="color: #004a43;"> _WIN32_WINNT </span><span style="color: #808030;">&gt;</span><span style="color: #808030;">=</span><span style="color: #004a43;"> 0x0600</span>
<span style="color: #800000; font-weight: bold;">if</span><span style="color: #808030;">(</span>GetOsVersion<span style="color: #808030;">(</span><span style="color: #808030;">)</span> <span style="color: #808030;">&lt;</span> <span style="color: #008000;">0x00060000</span> <span style="color: #808030;">|</span><span style="color: #808030;">|</span> GetCommCtrlVersion<span style="color: #808030;">(</span><span style="color: #808030;">)</span> <span style="color: #808030;">&lt;</span> <span style="color: #008000;">0x00060000</span><span style="color: #808030;">)</span> <span style="color: #696969;">// pre-Vista, Common Controls pre-6.0</span>
    BandInformation<span style="color: #808030;">.</span>cbSize <span style="color: #808030;">=</span> REBARBANDINFO_V6_SIZE<span style="color: #800080;">;</span>
<span style="color: #004a43;">#</span><span style="color: #004a43;">endif</span><span style="color: #696969;">// _WIN32_WINNT &gt;= 0x0600</span>
<span style="color: #800000; font-weight: bold;">const</span> <span style="color: #603000;">BOOL</span> bGetBandInfoResult <span style="color: #808030;">=</span> Rebar<span style="color: #808030;">.</span>GetBandInfo<span style="color: #808030;">(</span><span style="color: #008c00;">0</span><span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>BandInformation<span style="color: #808030;">)</span><span style="color: #800080;">;</span></pre>
<p>If the API was nicer to developers, the code would be plain and simple:</p>
<pre style="color: #000000; background: #ffffff;">REBARBANDINFO BandInformation <span style="color: #808030;">=</span> <span style="color: #800080;">{</span> <span style="color: #800000; font-weight: bold;">sizeof</span> BandInformation<span style="color: #808030;">,</span> RBBIM_LPARAM <span style="color: #800080;">}</span><span style="color: #800080;">;</span>
<span style="color: #800000; font-weight: bold;">const</span> <span style="color: #603000;">BOOL</span> bGetBandInfoResult <span style="color: #808030;">=</span> Rebar<span style="color: #808030;">.</span>GetBandInfo<span style="color: #808030;">(</span><span style="color: #008c00;">0</span><span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>BandInformation<span style="color: #808030;">)</span><span style="color: #800080;">;</span></pre>
<p>To address this problem, <a href="http://wtl.sourceforge.net/">WTL</a> 8.0 comes up with <em>RunTimeHelper</em> namespace and its <em>SizeOf_REBARBANDINFO</em> function. It takes care of details for the developer choosing the proper size of the structure on runtime. The code is being taken back to a simpler shape:</p>
<pre style="color: #000000; background: #ffffff;">REBARBANDINFO BandInformation <span style="color: #808030;">=</span> <span style="color: #800080;">{</span> RunTimeHelper<span style="color: #800080;">::</span>SizeOf_REBARBANDINFO<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #808030;">,</span> RBBIM_LPARAM <span style="color: #800080;">}</span><span style="color: #800080;">;</span>
<span style="color: #800000; font-weight: bold;">const</span> <span style="color: #603000;">BOOL</span> bGetBandInfoResult <span style="color: #808030;">=</span> Rebar<span style="color: #808030;">.</span>GetBandInfo<span style="color: #808030;">(</span><span style="color: #008c00;">0</span><span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>BandInformation<span style="color: #808030;">)</span><span style="color: #800080;">;</span></pre>
<p>All in all:</p>
<ul>
<li>be aware of compatibility issues (same scenario exists with other SDK structures: <em>LVGROUP</em>, <em>LVTILEINFO</em>, <em>MCHITTESTINFO</em>, <em>NONCLIENTMETRICS</em> and other).</li>
<li>use latest version of WTL to have things worked around for you where Microsoft developers were not kid enough to provide perfect API</li>
<li>be aware and take advantage of WTL&#8217;s <em>RunTimeHelper</em> class</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1306/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GPS Location/Coordinate Converter: Fractional Seconds, More Shortcuts</title>
		<link>http://alax.info/blog/1302</link>
		<comments>http://alax.info/blog/1302#comments</comments>
		<pubDate>Thu, 20 Oct 2011 17:48:42 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[WTL]]></category>
		<category><![CDATA[coordinate]]></category>
		<category><![CDATA[geolocation]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1302</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1302" title="GPS Location/Coordinate Converter: Fractional Seconds, More Shortcuts"></a>This adds a small update to the recently published GPS Location/Coordinate Converter utility: Seconds in Degrees, Minutes &#38; Seconds notation are shown and are accepted as floating point numbers More shortcuts to popular online map services (note that only Google &#8230;<p class="read-more"><a href="http://alax.info/blog/1302">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1302" title="GPS Location/Coordinate Converter: Fractional Seconds, More Shortcuts"></a><p>This adds a small update to the recently published <a title="Permalink to Utility Clearance: GPS Location/Coordinate Converter" href="../1297">GPS Location/Coordinate Converter</a> utility:</p>
<ul>
<li>Seconds in <em>Degrees, Minutes &amp; Seconds</em> notation are shown and are accepted as floating point numbers</li>
<li>More shortcuts to popular online map services (note that only Google Maps and Yandex Maps are still accepted as input via clipboard):</li>
<ul>
<li style="text-align: left;">Bing Maps</li>
<li style="text-align: left;">Yahoo Maps</li>
<li style="text-align: left;">Open Street Map</li>
<li style="text-align: left;">WikiMapia</li>
</ul>
</ul>
<p>The latter makes the tool an easy to use converted between the services for a GPS POI.</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/10/Image0011.png"><img class="alignnone size-large wp-image-1303" title="GPS Location Converter" src="http://alax.info/blog/wp-content/uploads/2011/10/Image0011-800x316.png" alt="" width="620" height="244" /></a></p>
<p>A binary [<a href="http://www.alax.info/svn/public/trunk/Utilities/GpsLocationConverter/_Bin/Release/GpsLocationConverter.exe">Win32</a>] and partial Visual C++ .NET 2010 <a href="http://www.alax.info/trac/public/browser/trunk/Utilities/GpsLocationConverter">partial source code</a> are available from SVN.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1302/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Utility Clearance: Rasterize Font</title>
		<link>http://alax.info/blog/1192</link>
		<comments>http://alax.info/blog/1192#comments</comments>
		<pubDate>Sun, 24 Apr 2011 17:05:32 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Utilities]]></category>
		<category><![CDATA[ATL]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[character]]></category>
		<category><![CDATA[font]]></category>
		<category><![CDATA[rasterize]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[ttf]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[WTL]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1192</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1192" title="Utility Clearance: Rasterize Font"></a>RasterizeFont utility takes a font on the input (such as Windows .TTF &#8211; True-Type Font) and paints individual characters into bitmaps. Utility output includes separate bitmap (.BMP) files for requested characters and C++ source code of the bimap arrays (this &#8230;<p class="read-more"><a href="http://alax.info/blog/1192">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1192" title="Utility Clearance: Rasterize Font"></a><p><img class="size-full wp-image-1193 alignleft" title="RasterizeFont Output" src="http://alax.info/blog/wp-content/uploads/2011/04/Character-005a.png" alt="" width="48" height="72" /> RasterizeFont utility takes a font on the input (such as Windows .TTF &#8211; <a href="http://en.wikipedia.org/wiki/TrueType">True-Type Font</a>) and paints individual characters into bitmaps. Utility output includes separate bitmap (.BMP) files for requested characters and C++ source code of the bimap arrays (this was included into microcontroller project).</p>
<p>A configuration .INI file defines rasterizer parameters:</p>
<pre>[General]
Width=48
Height=72
Horizontal Adjustment=1
Vertical Adjustment=0
Outline=1

[Font]
Face=Times New Roman
Height=48
Weight=1024

[Bitmaps]
PathTemplate=Character-%04x.bmp</pre>
<p>And a list of characters of interest is passed as a command line argument.</p>
<pre style="color: #000000; background: #ffffff;"><span style="color: #800000; font-weight: bold;">const</span> <span style="color: #603000;">BYTE</span> pnCharacter007a<span style="color: #808030;">[</span><span style="color: #808030;">]</span> <span style="color: #808030;">=</span> <span style="color: #696969;">// 0x007a z</span>
<span style="color: #800080;">{</span>
    <span style="color: #008000;">0x55</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x55</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x55</span><span style="color: #808030;">,</span>  <span style="color: #696969;">// 01 01 01 01 01 01 01 01 01 01 01 01 </span>
    <span style="color: #008000;">0x55</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x55</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x55</span><span style="color: #808030;">,</span>  <span style="color: #696969;">// 01 01 01 01 01 01 01 01 01 01 01 01 </span>
    <span style="color: #008000;">0x55</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x55</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x55</span><span style="color: #808030;">,</span>  <span style="color: #696969;">// 01 01 01 01 01 01 01 01 01 01 01 01 </span>
    <span style="color: #008000;">0x54</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x00</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x05</span><span style="color: #808030;">,</span>  <span style="color: #696969;">// 01 01 01 00 00 00 00 00 00 00 01 01 </span>
    <span style="color: #008000;">0x52</span><span style="color: #808030;">,</span> <span style="color: #008000;">0xaa</span><span style="color: #808030;">,</span> <span style="color: #008000;">0xa1</span><span style="color: #808030;">,</span>  <span style="color: #696969;">// 01 01 00 10 10 10 10 10 10 10 00 01 </span>
    <span style="color: #008000;">0x52</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x00</span><span style="color: #808030;">,</span> <span style="color: #008000;">0xa1</span><span style="color: #808030;">,</span>  <span style="color: #696969;">// 01 01 00 10 00 00 00 00 10 10 00 01 </span>
    <span style="color: #008000;">0x54</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x42</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x85</span><span style="color: #808030;">,</span>  <span style="color: #696969;">// 01 01 01 00 01 00 00 10 10 00 01 01 </span>
    <span style="color: #008000;">0x55</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x2a</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x15</span><span style="color: #808030;">,</span>  <span style="color: #696969;">// 01 01 01 01 00 10 10 10 00 01 01 01 </span>
    <span style="color: #008000;">0x54</span><span style="color: #808030;">,</span> <span style="color: #008000;">0xa0</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x45</span><span style="color: #808030;">,</span>  <span style="color: #696969;">// 01 01 01 00 10 10 00 00 01 00 01 01 </span>
    <span style="color: #008000;">0x52</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x80</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x21</span><span style="color: #808030;">,</span>  <span style="color: #696969;">// 01 01 00 10 10 00 00 00 00 10 00 01 </span>
    <span style="color: #008000;">0x52</span><span style="color: #808030;">,</span> <span style="color: #008000;">0xaa</span><span style="color: #808030;">,</span> <span style="color: #008000;">0xa1</span><span style="color: #808030;">,</span>  <span style="color: #696969;">// 01 01 00 10 10 10 10 10 10 10 00 01 </span>
    <span style="color: #008000;">0x54</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x00</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x05</span><span style="color: #808030;">,</span>  <span style="color: #696969;">// 01 01 01 00 00 00 00 00 00 00 01 01 </span>
    <span style="color: #008000;">0x55</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x55</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x55</span><span style="color: #808030;">,</span>  <span style="color: #696969;">// 01 01 01 01 01 01 01 01 01 01 01 01 </span>
    <span style="color: #008000;">0x55</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x55</span><span style="color: #808030;">,</span> <span style="color: #008000;">0x55</span><span style="color: #808030;">,</span>  <span style="color: #696969;">// 01 01 01 01 01 01 01 01 01 01 01 01 </span>
<span style="color: #800080;">}</span><span style="color: #800080;">;</span></pre>
<p>A binary [<a href="http://trac2.assembla.com/roatl-utilities/browser/trunk/RasterizeFont/_Bin/Win32/Release/RasterizeFont.exe?format=raw">Win32</a>] and Visual C++ .NET 2008 source code <a href="http://trac2.assembla.com/roatl-utilities/browser/trunk/RasterizeFont">are  available from SVN</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1192/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Utility Clearance: Logical Processor Information</title>
		<link>http://alax.info/blog/1188</link>
		<comments>http://alax.info/blog/1188#comments</comments>
		<pubDate>Sun, 24 Apr 2011 15:45:16 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Utilities]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[ATL]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpu]]></category>
		<category><![CDATA[GetLogicalProcessorInformation]]></category>
		<category><![CDATA[msdn]]></category>
		<category><![CDATA[processor]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[WTL]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1188</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1188" title="Utility Clearance: Logical Processor Information"></a>LogicalProcessorInformation is a fronend GUI around GetLogicalProcessorInformation API and reveals CPU configuration of the system. If you are fine tuning stuff, you might want to know what sort of CPUs are powering the applications: how many? fully featured cores or &#8230;<p class="read-more"><a href="http://alax.info/blog/1188">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1188" title="Utility Clearance: Logical Processor Information"></a><p>LogicalProcessorInformation is a fronend GUI around <a href="http://msdn.microsoft.com/en-us/library/ms683194%28VS.85%29.aspx">GetLogicalProcessorInformation</a> API and reveals CPU configuration of the system. If you are fine tuning stuff, you might want to know what sort of CPUs are powering the applications:</p>
<ul>
<li>how many?</li>
<li>fully featured cores or <a href="http://www.intel.com/info/hyperthreading/">HyperThreading</a> technology?</li>
<li>mutli-processor configuration and how exactly physical processors are distributed over affinity mask</li>
</ul>
<p><img class="alignnone size-full wp-image-1189" title="Logical Processor Information" src="http://alax.info/blog/wp-content/uploads/2011/04/Image001.png" alt="" width="520" height="396" /></p>
<p>API and the application gets you the data as a user-friendly dump of GetLogicalProcessorInformation output and a summary of records at the bottom:</p>
<p><span id="more-1188"></span></p>
<pre>Logical Processors:

Mask: 0x00000003
Relationship: RelationProcessorCore (0x0)
ProcessorCore.Flags: 0x01

Mask: 0x00000003
Relationship: RelationCache (0x2)
Cache.Level: 1
Cache.Associativity: 8
Cache.LineSize: 64 (0x40)
Cache.Size: 32768 (0x8000)
Cache.Type: CacheData (0x2)

Mask: 0x00000003
Relationship: RelationCache (0x2)
Cache.Level: 1
Cache.Associativity: 4
Cache.LineSize: 64 (0x40)
Cache.Size: 32768 (0x8000)
Cache.Type: CacheInstruction (0x1)

Mask: 0x00000003
Relationship: RelationCache (0x2)
Cache.Level: 2
Cache.Associativity: 8
Cache.LineSize: 64 (0x40)
Cache.Size: 262144 (0x40000)
Cache.Type: CacheUnified (0x0)

Mask: 0x0000000c
Relationship: RelationProcessorCore (0x0)
ProcessorCore.Flags: 0x01

...

Mask: 0x000000ff
Relationship: RelationProcessorPackage (0x3)

...

Mask: 0x000000ff
Relationship: RelationNumaNode (0x1)
NumaNode.NodeNumber: 0x0

Record Count per Relationship:
 RelationProcessorCore (0x0): 4
 RelationNumaNode (0x1): 1
 RelationCache (0x2): 13
 RelationProcessorPackage (0x3): 1
 RelationGroup (0x4): 0</pre>
<p>A binary [<a href="http://trac2.assembla.com/roatl-utilities/browser/trunk/LogicalProcessorInformation/_Bin/Win32/Release/LogicalProcessorInformation.exe?format=raw">Win32</a>, <a href="http://trac2.assembla.com/roatl-utilities/browser/trunk/LogicalProcessorInformation/_Bin/x64/Release/LogicalProcessorInformation.exe?format=raw">x64</a>] and Visual C++ .NET 2010 source code <a href="http://trac2.assembla.com/roatl-utilities/browser/trunk/LogicalProcessorInformation">are  available from SVN</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1188/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>You cannot remove RBBS_NOGRIPPER flag from rebar band</title>
		<link>http://alax.info/blog/1187</link>
		<comments>http://alax.info/blog/1187#comments</comments>
		<pubDate>Thu, 31 Mar 2011 16:28:12 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Source]]></category>
		<category><![CDATA[WTL]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[rebar]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1187</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1187" title="You cannot remove RBBS_NOGRIPPER flag from rebar band"></a>It is as stupid as it sounds: you can add RBBS_NOGRIPPER flag to a rebar band to implement &#8220;lock controls&#8221; feature, but as soon as you start removing it &#8211; you miserably fail. A related thread on WTL group is &#8230;<p class="read-more"><a href="http://alax.info/blog/1187">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1187" title="You cannot remove RBBS_NOGRIPPER flag from rebar band"></a><p>It is as stupid as it sounds: you can add RBBS_NOGRIPPER flag to a rebar band to implement &#8220;lock controls&#8221; feature, but as soon as you start removing it &#8211; you miserably fail.</p>
<p><a href="http://tech.dir.groups.yahoo.com/group/wtl/message/13979">A related thread on WTL group</a> is dated year 2006. You can find the same dated 2003. Now it&#8217;s 2011 and it&#8217;s still here.</p>
<p>OK, it might be some bug in controlling code etc, but here is <a href="http://msdn.microsoft.com/en-us/library/bb773165%28VS.85%29.aspx">Control Spy 2.0</a>. Here you go:</p>
<ul>
<li>rebar</li>
<li><a href="http://msdn.microsoft.com/en-us/library/bb774451%28VS.85%29.aspx">RB_GETBANDINFO</a>, <a href="http://msdn.microsoft.com/en-us/library/bb774393%28VS.85%29.aspx">RBBIM_STYLE</a></li>
<li>add RBBS_NOGRIPPER, Send</li>
<li>remove RBBS_NOGRIPPER, Send</li>
<li>ouch!</li>
</ul>
<p>WTL does a cool trick to fool the bastard:</p>
<pre style="color: #000000; background: #ffffff;"><span style="color: #800000; font-weight: bold;">void</span> LockBands<span style="color: #808030;">(</span><span style="color: #800000; font-weight: bold;">bool</span> bLock<span style="color: #808030;">)</span>
<span style="color: #800080;">{</span>
    <span style="color: #800000; font-weight: bold;">int</span> nBandCount <span style="color: #808030;">=</span> GetBandCount<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800000; font-weight: bold;">for</span><span style="color: #808030;">(</span><span style="color: #800000; font-weight: bold;">int</span> i <span style="color: #808030;">=</span><span style="color: #008c00;">0</span><span style="color: #800080;">;</span> i <span style="color: #808030;">&lt;</span> nBandCount<span style="color: #800080;">;</span> i<span style="color: #808030;">+</span><span style="color: #808030;">+</span><span style="color: #808030;">)</span>
    <span style="color: #800080;">{</span>
        REBARBANDINFO rbbi <span style="color: #808030;">=</span> <span style="color: #800080;">{</span> RunTimeHelper<span style="color: #800080;">::</span>SizeOf_REBARBANDINFO<span style="color: #808030;">(</span><span style="color: #808030;">)</span> <span style="color: #800080;">}</span><span style="color: #800080;">;</span>
        rbbi<span style="color: #808030;">.</span>fMask <span style="color: #808030;">=</span> RBBIM_STYLE<span style="color: #800080;">;</span>
        <span style="color: #603000;">BOOL</span> bRet <span style="color: #808030;">=</span> GetBandInfo<span style="color: #808030;">(</span>i<span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>rbbi<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        ATLASSERT<span style="color: #808030;">(</span>bRet<span style="color: #808030;">)</span><span style="color: #800080;">;</span>

        <span style="color: #800000; font-weight: bold;">if</span><span style="color: #808030;">(</span><span style="color: #808030;">(</span>rbbi<span style="color: #808030;">.</span>fStyle <span style="color: #808030;">&amp;</span> RBBS_GRIPPERALWAYS<span style="color: #808030;">)</span> <span style="color: #808030;">=</span><span style="color: #808030;">=</span> <span style="color: #008c00;">0</span><span style="color: #808030;">)</span>
        <span style="color: #800080;">{</span>
            rbbi<span style="color: #808030;">.</span>fStyle <span style="color: #808030;">|</span><span style="color: #808030;">=</span> RBBS_GRIPPERALWAYS<span style="color: #800080;">;</span>
            bRet <span style="color: #808030;">=</span> SetBandInfo<span style="color: #808030;">(</span>i<span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>rbbi<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
            ATLASSERT<span style="color: #808030;">(</span>bRet<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
            rbbi<span style="color: #808030;">.</span>fStyle <span style="color: #808030;">&amp;</span><span style="color: #808030;">=</span> <span style="color: #808030;">~</span>RBBS_GRIPPERALWAYS<span style="color: #800080;">;</span>
        <span style="color: #800080;">}</span>
        <span style="color: #800000; font-weight: bold;">if</span><span style="color: #808030;">(</span>bLock<span style="color: #808030;">)</span>
            rbbi<span style="color: #808030;">.</span>fStyle <span style="color: #808030;">|</span><span style="color: #808030;">=</span> RBBS_NOGRIPPER<span style="color: #800080;">;</span>
        <span style="color: #800000; font-weight: bold;">else</span>
            rbbi<span style="color: #808030;">.</span>fStyle <span style="color: #808030;">&amp;</span><span style="color: #808030;">=</span> <span style="color: #808030;">~</span>RBBS_NOGRIPPER<span style="color: #800080;">;</span>

        bRet <span style="color: #808030;">=</span> SetBandInfo<span style="color: #808030;">(</span>i<span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>rbbi<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        ATLASSERT<span style="color: #808030;">(</span>bRet<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800080;">}</span>
<span style="color: #800080;">}</span></pre>
<p>Pretty cool and works&#8230; if you have one rebar only. If you have another one in the same window (e.g. mine is at bottom) &#8211; you fail again.</p>
<p>A nasty workaround is to nudge hosting window by resizing it, followed by a full cycle of internal layout updates:</p>
<pre style='color:#000000;background:#ffffff;'><span style='color:#603000; '>CRect</span> Position<span style='color:#800080; '>;</span>
ATLVERIFY<span style='color:#808030; '>(</span><span style='color:#400000; '>GetWindowRect</span><span style='color:#808030; '>(</span>Position<span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
Position<span style='color:#808030; '>.</span>bottom<span style='color:#808030; '>+</span><span style='color:#808030; '>+</span><span style='color:#800080; '>;</span>
ATLVERIFY<span style='color:#808030; '>(</span><span style='color:#400000; '>MoveWindow</span><span style='color:#808030; '>(</span>Position<span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
Position<span style='color:#808030; '>.</span>bottom<span style='color:#808030; '>-</span><span style='color:#808030; '>-</span><span style='color:#800080; '>;</span>
ATLVERIFY<span style='color:#808030; '>(</span><span style='color:#400000; '>MoveWindow</span><span style='color:#808030; '>(</span>Position<span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1187/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ProcessSnapshot: Create process minidump for port-mortem debugging</title>
		<link>http://alax.info/blog/1119</link>
		<comments>http://alax.info/blog/1119#comments</comments>
		<pubDate>Wed, 24 Mar 2010 22:17:42 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[.DMP]]></category>
		<category><![CDATA[ATL]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[minidump]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[process]]></category>
		<category><![CDATA[snapshot]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[WTL]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1119</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1119" title="ProcessSnapshot: Create process minidump for port-mortem debugging"></a>ProcessSnapshot is a utility to take a snapshot of process call stacks, and the snapshot taken is written into a human friendly text file. Additionally to this, the utility has been given a capability to create process minidump files, on &#8230;<p class="read-more"><a href="http://alax.info/blog/1119">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1119" title="ProcessSnapshot: Create process minidump for port-mortem debugging"></a><p><a href="http://alax.info/blog/665">ProcessSnapshot</a> is a utility to take a snapshot of process call stacks, and the snapshot taken is written into a human friendly text file.</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2010/03/24-Image001.png"><img class="alignnone size-medium wp-image-1120" title="ProcessSnapshot is taking process minidump files" src="http://alax.info/blog/wp-content/uploads/2010/03/24-Image001-320x189.png" alt="ProcessSnapshot is taking process minidump files" width="320" height="189" /></a></p>
<p>Additionally to this, the utility has been given a capability to create process <a href="http://msdn.microsoft.com/en-us/library/ms680369%28VS.85%29.aspx">minidump files</a>, on user request. The minidump files can be used with debugger to analyze the context of the process using feature rich debug environment, esp. Microsoft Visual Studio. To create a minidump for a process, check a corresponding box and press &#8220;Take a Dump&#8221; button. A file named &#8220;&lt;process-image-name&gt; &#8211; &lt;date&gt; &lt;time&gt;.dmp&#8221; will be created in the directory of the utility executable.</p>
<p>See also:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/ms680369%28VS.85%29.aspx">Minidump Files (MSDN)</a></li>
<li><a href="http://support.microsoft.com/kb/315263">How to read the small memory dump files that Windows creates for debugging</a></li>
<li><a href="http://www.codeproject.com/KB/debug/postmortemdebug_standalone1.aspx">Post-Mortem Debugging Your Application with Minidumps and Visual Studio .NET</a></li>
<li><a href="http://www.pchell.com/support/minidumps.shtml">How to View Windows Minidump Files</a></li>
</ul>
<p>A binary [<a href="http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/ProcessSnapshot/Win32/Release/ProcessSnapshot.exe?format=raw">Win32</a>, <a href="http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/ProcessSnapshot/x64/Release/ProcessSnapshot.exe?format=raw">x64</a>] and partial Visual C++ .NET 2008 source code <a href="http://trac2.assembla.com/roatl-utilities/browser/trunk/ProcessSnapshot/Release/ProcessSnapshot.exe">are  available from SVN</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1119/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>YV12, Extended Video Renderer Strides, Private DMO and more</title>
		<link>http://alax.info/blog/893</link>
		<comments>http://alax.info/blog/893#comments</comments>
		<pubDate>Wed, 01 Apr 2009 07:48:45 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[WTL]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[DMO]]></category>
		<category><![CDATA[stride]]></category>
		<category><![CDATA[VMR]]></category>
		<category><![CDATA[wrapper]]></category>
		<category><![CDATA[YV12]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=893</guid>
		<description><![CDATA[<a href="http://alax.info/blog/893" title="YV12, Extended Video Renderer Strides, Private DMO and more"></a>Recently it was the time to sort out an issue with a video DMO, which outputs YV12 video and in the same time is capable of supporting extended video strides in order to efficiently make a direct connection to Video &#8230;<p class="read-more"><a href="http://alax.info/blog/893">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/893" title="YV12, Extended Video Renderer Strides, Private DMO and more"></a><p>Recently it was the time to sort out an issue with a video <a href="http://msdn.microsoft.com/en-us/library/dd375512(VS.85).aspx">DMO</a>, which outputs <a href="http://fourcc.org/yuv.php#YV12">YV12</a> video and in the same time is capable of supporting <a href="http://msdn.microsoft.com/en-us/library/dd388799(VS.85).aspx">extended video strides</a> in order to efficiently make a direct connection to <a href="http://msdn.microsoft.com/en-us/library/dd407343(VS.85).aspx">Video Mixing Renderer Filters</a>.</p>
<p>From past experience, I already knew that some bugs are definitely involved but their effect was yet unexplored. For a testbed application, I took good old <a href="http://alax.info/blog/551">FrameRateSample02</a> application, which generates multiple video feeds and routes it to video renderers:</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2009/04/01-image001.png"><img class="alignnone size-full wp-image-894" title="FrameRateSample02 Application with New Choices" src="http://alax.info/blog/wp-content/uploads/2009/04/01-image001.png" alt="FrameRateSample02 Application with New Choices" width="539" height="317" /></a></p>
<p>With new source video choices the application is capable of constructing filter graphs that use a private DMO (that is hosted inside the executable) wrapped with <a href="http://msdn.microsoft.com/en-us/library/dd375519(VS.85).aspx">DMO Wrapper Filter</a>, with a graph topology shown below:</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2009/04/01-image002.png"><img class="alignnone size-medium wp-image-895" title="Filter Graph with a Private DMO" src="http://alax.info/blog/wp-content/uploads/2009/04/01-image002-300x172.png" alt="Filter Graph with a Private DMO" width="300" height="172" /></a></p>
<p><span id="more-893"></span>The DMO does not do any processing, except support for extended strides while copying original data into buffer streamed to video renderer. Extended strides for a planar YUV format is a bit tricky. Are they supported at all? Yes, they are and video renderer might still request an extended stride and in which case origial MxN video needs to be copied into (M+P)xN buffer. Unlike packed pixel format, unused space is distributed in a bit different way but still very much similarly: output buffer is still a regular  (M+P)xN rectangle, where the effective picture of size MxN should be copied into top left corner.</p>
<p>The problem I was aware of from past experience showed up immediately once the filters connected. After a dynamic format change initiated by the VMR, the filters report different connection media types. <a href="http://msdn.microsoft.com/en-us/library/dd375519(VS.85).aspx">DMO Wrapper Filter</a> still shows original connection time connection media type, while <a href="http://msdn.microsoft.com/en-us/library/dd407343(VS.85).aspx">Video Mixing Renderer Filter</a> shows media type it switched to.</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2009/04/01-image003.png"><img class="alignnone size-medium wp-image-896" title="Media Type Mismatch" src="http://alax.info/blog/wp-content/uploads/2009/04/01-image003-300x241.png" alt="Media Type Mismatch" width="300" height="241" /></a></p>
<p>This looks like <a href="http://msdn.microsoft.com/en-us/library/dd375519(VS.85).aspx">DMO Wrapper Filter</a> bug, but was yet to check if it still handles the new media type properly and passes the format change to the underlying DMO object. Taking into consideration the extent DMOs are used by <a href="http://microsoft.com">Microsoft</a>, it had to, thought I never met this in the <a href="http://msdn.microsoft.com">MSDN</a> documentation.</p>
<p>Further debugging revealed that <a href="http://msdn.microsoft.com/en-us/library/dd375519(VS.85).aspx">DMO Wrapper Filter</a> does handle the media type change and forward it to the DMO through <a href="http://msdn.microsoft.com/en-us/library/dd406963(VS.85).aspx">IMediaObject::SetOutputType</a> method. This happens when DMO already received its first input, and immediately before following <a href="http://msdn.microsoft.com/en-us/library/dd406960(VS.85).aspx">IMediaObject::ProcessOutput</a> method call:</p>
<pre>rodmo.h(293) : CMediaObjectT&lt;class CVideoDmo&gt;::AllocateStreamingResources: ...
rodshow.h(2716) : CBaseFilterT&lt;class CMainDialog::CSourceFilter&gt;::Pause: ...
rodshow.h(2722) : CBaseFilterT&lt;class CMainDialog::CSourceFilter&gt;::Pause: m_State 0
rodshow.h(2730) : CBaseFilterT&lt;class CMainDialog::CSourceFilter&gt;::Pause: m_State 1
rodshow.h(2784) : CBaseFilterT&lt;class CMainDialog::CSourceFilter&gt;::GetState: nTimeout 0
rodmo.h(679) : CSimpleMediaObjectT&lt;class CVideoDmo,1&gt;::GetInputStatus: nInputStreamIndex 0
<span style="color: #ff0000;"><strong>rodmo.h(702) : CSimpleMediaObjectT&lt;class CVideoDmo,1&gt;::ProcessInput: nInputStreamIndex 0, nFlags 0x1
rodmo.h(527) : CSimpleMediaObjectT&lt;class CVideoDmo,1&gt;::SetOutputType: nOutputStreamIndex 0, nFlags 0x0</strong>
</span>rodmo.h(727) : CSimpleMediaObjectT&lt;class CVideoDmo,1&gt;::ProcessOutput: nFlags 0x1, nOutputBufferCount 1</pre>
<p>So, the media type change is handled and the problem is only limited to reporting wrong (original) media type off the wrapper filter output pin.</p>
<p>Investigation of filter connection however brought up another interesting fact, memory allocator properties:</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2009/04/01-image004.png"><img class="alignnone size-medium wp-image-897" title="Memory Allocator Properties" src="http://alax.info/blog/wp-content/uploads/2009/04/01-image004-300x241.png" alt="Memory Allocator Properties" width="300" height="241" /></a></p>
<p>As the filters switched to a new media type, with extended strides, the memory allocator should obviously have been updated accordingly, in order to support larger buffer. However current <a href="http://msdn.microsoft.com/en-us/library/dd373419(VS.85).aspx">memory allocator properties</a> indicate old buffer size of 460,800 bytes, while new media type assumes 737,280 buffer size at the very least. The samples are however streamed fine, so the issue is also limited to incorrectly reported size.</p>
<p>This memory allocator is managed by the <a href="http://msdn.microsoft.com/en-us/library/dd407343(VS.85).aspx">Video Mixing Renderer Filter</a>, so the problem seems to be relating to it.</p>
<p>Good news however was that video was streamed and displayed correctly.</p>
<p>One thing that deserves special attention is making a DMO private. I <a href="http://alax.info/blog/674">already wrote another post on private DMOs</a> some time ago, and this time the sample shows even a better way in case one does not need the DMO available for <a href="http://msdn.microsoft.com/en-us/library/dd390342(VS.85).aspx">Intelligent Connect</a> (in which case <a href="http://msdn.microsoft.com/en-us/library/dd375491.aspx">DMORegister</a> call along with administrative privileges will be required),  just for a private instantiation. DMO is typically created by <a href="http://msdn.microsoft.com/en-us/library/ms686615.aspx">CoCreateInstance</a> from inside the <a href="http://msdn.microsoft.com/en-us/library/dd375519(VS.85).aspx">DMO Wrapper Filter</a>, e.g. using <a href="http://msdn.microsoft.com/en-us/library/dd406849(VS.85).aspx">IDMOWrapperFilter::Init</a> method, so it is necessary to either register COM class, or&#8230; just register its class object for the process using <a href="http://msdn.microsoft.com/en-us/library/ms693407.aspx">CoRegisterClassObject</a>.</p>
<p>There is no need for direct usage of API since ATL already wrapped the calls and we are to take advantage of what is already available. First of all, the DMO class requires certain CLSID, because we don&#8217;t have one typically declared in IDL. A good place for attaching CLSID is class declaration and <a href="http://msdn.microsoft.com/en-us/library/dabb5z75.aspx">__declspec keyword</a>:</p>
<pre><span style="color: #800000; font-weight: bold;">class</span> <span style="color: #800000; font-weight: bold;">__declspec</span><span style="color: #808030;">(</span>uuid<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">88B976BE-EEE6-45b1-A21B-42A941DF8819</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span> ATL_NO_VTABLE CVideoDmo <span style="color: #800080;">:</span>
    <span style="color: #800000; font-weight: bold;">public</span> CComObjectRootEx<span style="color: #800080;">&lt;</span>CComMultiThreadModelNoCS<span style="color: #800080;">&gt;</span><span style="color: #808030;">,</span>
    <span style="color: #800000; font-weight: bold;">public</span> CComCoClass<span style="color: #800080;">&lt;</span>CVideoDmo<span style="color: #800080;">&gt;</span><span style="color: #808030;">,</span>
    <span style="color: #800000; font-weight: bold;">public</span> CSimpleMediaObjectT<span style="color: #800080;">&lt;</span>CVideoDmo<span style="color: #808030;">,</span> <span style="color: #008c00;">1</span><span style="color: #800080;">&gt;</span>
<span style="color: #800080;">{</span></pre>
<p>Further a COM class is typically referenced into module&#8217;s object map byan <a href="http://msdn.microsoft.com/en-us/library/exx3wywe.aspx">OBJECT_ENTRY_AUTO</a> macro:</p>
<pre><span class="Comment"><span class="Comment">//</span>OBJECT_ENTRY_AUTO(__uuidof(VideoDmo), CVideoDmo</span>)</pre>
<p>But we don&#8217;t need this this time as we don&#8217;t need standard COM registration for the class. We will register its class object manually and temporarily, at the time of DMO initialization:</p>
<pre>CComQIPtr<span style="color: #800080;">&lt;</span>IBaseFilter<span style="color: #800080;">&gt;</span> pBaseFilter<span style="color: #800080;">;</span>
CVideoDmo<span style="color: #808030;">*</span> pVideoDmo<span style="color: #800080;">;</span>
<span style="color: #800080;">{</span>
    BEGIN_OBJECT_MAP<span style="color: #808030;">(</span>g_pObjectMap<span style="color: #808030;">)</span>
        OBJECT_ENTRY<span style="color: #808030;">(</span><span style="color: #800000; font-weight: bold;">__uuidof</span><span style="color: #808030;">(</span>CVideoDmo<span style="color: #808030;">)</span><span style="color: #808030;">,</span> CVideoDmo<span style="color: #808030;">)</span>
    END_OBJECT_MAP<span style="color: #808030;">(</span><span style="color: #808030;">)</span>
    ATLASSERT<span style="color: #808030;">(</span>DIM<span style="color: #808030;">(</span>g_pObjectMap<span style="color: #808030;">)</span> <span style="color: #808030;">=</span><span style="color: #808030;">=</span> <span style="color: #008c00;">2</span> <span style="color: #808030;">&amp;</span><span style="color: #808030;">&amp;</span> <span style="color: #808030;">!</span>g_pObjectMap<span style="color: #808030;">[</span><span style="color: #008c00;">1</span><span style="color: #808030;">]</span><span style="color: #808030;">.</span>pclsid<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    ATLENSURE_SUCCEEDED<span style="color: #808030;">(</span>g_pObjectMap<span style="color: #808030;">[</span><span style="color: #008c00;">0</span><span style="color: #808030;">]</span><span style="color: #808030;">.</span>RegisterClassObject<span style="color: #808030;">(</span>CLSCTX_INPROC_SERVER<span style="color: #808030;">,</span> REGCLS_SINGLEUSE<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    _ATLTRY
    <span style="color: #800080;">{</span>
        CComPtr<span style="color: #800080;">&lt;</span>IDMOWrapperFilter<span style="color: #800080;">&gt;</span> pDmoWrapperFilter <span style="color: #808030;">=</span> ConstructDmoWrappedFilter<span style="color: #808030;">(</span><span style="color: #800000; font-weight: bold;">__uuidof</span><span style="color: #808030;">(</span>CVideoDmo<span style="color: #808030;">)</span><span style="color: #808030;">,</span> CVideoDmo<span style="color: #800080;">::</span>GetCategory<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        pBaseFilter <span style="color: #808030;">=</span> pDmoWrapperFilter<span style="color: #800080;">;</span>
        ATLENSURE_THROW<span style="color: #808030;">(</span>pBaseFilter<span style="color: #808030;">,</span> E_NOINTERFACE<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        CComQIPtr<span style="color: #800080;">&lt;</span>IMediaObject<span style="color: #800080;">&gt;</span> pMediaObject <span style="color: #808030;">=</span> pDmoWrapperFilter<span style="color: #800080;">;</span>
        ATLENSURE_THROW<span style="color: #808030;">(</span>pMediaObject<span style="color: #808030;">,</span> E_NOINTERFACE<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        pVideoDmo <span style="color: #808030;">=</span> <span style="color: #800000; font-weight: bold;">static_cast</span><span style="color: #800080;">&lt;</span>CVideoDmo<span style="color: #808030;">*</span><span style="color: #800080;">&gt;</span><span style="color: #808030;">(</span><span style="color: #808030;">(</span>IMediaObject<span style="color: #808030;">*</span><span style="color: #808030;">)</span> pMediaObject<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800080;">}</span>
    _ATLCATCHALL<span style="color: #808030;">(</span><span style="color: #808030;">)</span>
    <span style="color: #800080;">{</span>
        ATLVERIFY<span style="color: #808030;">(</span>SUCCEEDED<span style="color: #808030;">(</span>g_pObjectMap<span style="color: #808030;">[</span><span style="color: #008c00;">0</span><span style="color: #808030;">]</span><span style="color: #808030;">.</span>RevokeClassObject<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        _ATLRETHROW<span style="color: #800080;">;</span>
    <span style="color: #800080;">}</span>
    ATLVERIFY<span style="color: #808030;">(</span>SUCCEEDED<span style="color: #808030;">(</span>g_pObjectMap<span style="color: #808030;">[</span><span style="color: #008c00;">0</span><span style="color: #808030;">]</span><span style="color: #808030;">.</span>RevokeClassObject<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
<span style="color: #800080;">}</span>
pVideoDmo<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span>Initialize<span style="color: #808030;">(</span>CDmoMediaType<span style="color: #808030;">(</span>m_pMediaType<span style="color: #808030;">)</span><span style="color: #808030;">,</span> CopyYv12MediaBuffer<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
ATLENSURE_SUCCEEDED<span style="color: #808030;">(</span>pGraphBuilder<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span>AddFilter<span style="color: #808030;">(</span>pBaseFilter<span style="color: #808030;">,</span> CStringW<span style="color: #808030;">(</span>_T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">Pass-Through DMO</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
ATLENSURE_SUCCEEDED<span style="color: #808030;">(</span>pGraphBuilder<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span>Connect<span style="color: #808030;">(</span>pOutputPin<span style="color: #808030;">,</span> _FilterGraphHelper<span style="color: #800080;">::</span>GetFilterPin<span style="color: #808030;">(</span>pBaseFilter<span style="color: #808030;">,</span> PINDIR_INPUT<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
pOutputPin <span style="color: #808030;">=</span> _FilterGraphHelper<span style="color: #800080;">::</span>GetFilterPin<span style="color: #808030;">(</span>pBaseFilter<span style="color: #808030;">,</span> PINDIR_OUTPUT<span style="color: #808030;">)</span></pre>
<p>What is being done in the code snippet above is:</p>
<ul>
<li>local object map with a single <a href="http://msdn.microsoft.com/en-us/library/0f31291x.aspx">OBJECT_ENTRY</a> item to have ATL manage class object registration/revokation for us</li>
<li>registration of a private class/CLSID</li>
<li>instantiation and initialization of a <a href="http://msdn.microsoft.com/en-us/library/dd375519(VS.85).aspx">DMO Wrapper Filter</a> which is to pick up our class</li>
<li>cast back to native C++ pointer for easy further access (a private interface would be more accurate here)</li>
<li>revokation for CLSID</li>
</ul>
<p>For information, the interfaces queried from the DMO:</p>
<pre style="background: #ffffff none repeat scroll 0% 0%; color: #000000;">Find all <span style="color: #800000;">"</span><span style="color: #0000e6;">CVideoDmo::InternalQueryInterface</span><span style="color: #800000;">"</span><span style="color: #808030;">,</span> Hidden<span style="color: #808030;">,</span> Find Results <span style="color: #008c00;">1</span><span style="color: #808030;">,</span> Current Document
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IMediaObject<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x00000000</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IDMOQualityControl<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IDMOVideoOutputOptimizations<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IMediaObject<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x00000000</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IWMGetSecureChannel<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IAMOpenProgress<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IAMDeviceRemoval<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IDirectVobSub<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IDirectVobSub<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IWMCodecAMVideoAccelerator<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IDirectVobSub<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IWMCodecAMVideoAccelerator<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IWMCodecAMVideoAccelerator<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IMediaSeeking<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IMediaPosition<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IAMFilterMiscFlags<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IVideoWindow<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IBasicAudio<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IAMFilterMiscFlags<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IKsPropertySet<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IReferenceClock<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IWMCodecAMVideoAccelerator<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IAMDeviceRemoval<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
CVideoDmo<span style="color: #800080;">::</span>InternalQueryInterface<span style="color: #800080;">:</span> Interface IAMOpenProgress<span style="color: #808030;">,</span> Result <span style="color: #008000;">0x80004002</span>
Matching lines<span style="color: #800080;">:</span> <span style="color: #008c00;">24</span></pre>
<p>A Visual C++ .NET 2008 source code <a rel="nofollow" href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FrameRateSample02">is available from SVN</a>. Additional files will be required to compile, but <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FrameRateSample02/Release/FrameRateSample02.exe?format=raw">binary</a> is also incuded.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/893/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>MediaTools: Tone Source Filter to generate reference audio feed, dual Audio Source Filter and Virtual Audio Capture Device</title>
		<link>http://alax.info/blog/859</link>
		<comments>http://alax.info/blog/859#comments</comments>
		<pubDate>Sat, 28 Feb 2009 09:40:19 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[Audio]]></category>
		<category><![CDATA[Media Tools]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[WTL]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[capture]]></category>
		<category><![CDATA[device]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[PCM]]></category>
		<category><![CDATA[tone]]></category>
		<category><![CDATA[virtual]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=859</guid>
		<description><![CDATA[<a href="http://alax.info/blog/859" title="MediaTools: Tone Source Filter to generate reference audio feed, dual Audio Source Filter and Virtual Audio Capture Device"></a>In order to obtain a reference audio source and especially useful for debugging purposes, including: audio input device unrelated to physical device, to avoid conditions when device is already in use by someone else non-zero audio signal which is independent &#8230;<p class="read-more"><a href="http://alax.info/blog/859">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/859" title="MediaTools: Tone Source Filter to generate reference audio feed, dual Audio Source Filter and Virtual Audio Capture Device"></a><p>In order to obtain a reference audio source and especially useful for debugging purposes, including:</p>
<ul>
<li>audio input device unrelated to physical device, to avoid conditions when device is already in use by someone else</li>
<li>non-zero audio signal which is independent of certain speaker or broadcasting service, including one that makes capture, transmission or rendering issues easily perceptible by human</li>
<li>configurable to provide different audio media types, including through well known DirectShow interfaces, such as <a href="http://msdn.microsoft.com/en-us/library/dd319784(VS.85).aspx">IAMStreamConfig</a></li>
<li>configurable to present in system as both regular <a href="http://msdn.microsoft.com/en-us/library/dd375464(VS.85).aspx">DirectShow Filter</a>, and as an <a href="http://msdn.microsoft.com/en-us/library/dd375655(VS.85).aspx">Audio Capture Source</a> which can be enumerated by applications</li>
<li>to be able to check how exactly other applications are accessing and configuring audio capture source</li>
</ul>
<p>I added a new filter to the Media Tools library, a Tone Source Filter. The filter generates <a href="http://en.wikipedia.org/wiki/Pulse-code_modulation">PCM Audio</a> data, either infinite sine waveform, or interrupted signal  of requested parameters:</p>
<p><img class="alignnone size-full wp-image-863" title="Tone Source Filter General Property Page" src="http://alax.info/blog/wp-content/uploads/2009/02/27-image011.png" alt="Tone Source Filter General Property Page" width="370" height="428" /></p>
<p>The filter accepts connection on <a href="http://en.wikipedia.org/wiki/Pulse-code_modulation">PCM</a> media types with flexible sampling rates in range 8 KHz through 200 KHz, 8-bit audio and 1 channel. Media type is also configurable through or, if not configured this way, the first enumerated media type off the Output pin is also configurable through property page and/or persistent setting accessible via private IDispatch derived interface property.</p>
<p><img class="alignnone size-full wp-image-864" title="Tone Source Filter Prefered Format Property Page" src="http://alax.info/blog/wp-content/uploads/2009/02/27-image012.png" alt="Tone Source Filter Prefered Format Property Page" width="370" height="427" /></p>
<p>Additionally, the filter may configured as a system-wide available <a href="http://msdn.microsoft.com/en-us/library/ms783347(VS.85).aspx">audio input device</a>, such as for example available to <a href="http://videolan.org">VLC Media Player</a> or <a href="http://sourceforge.net/projects/guliverkli/">Media Player Classic</a>:</p>
<p><img class="alignnone size-full wp-image-865" title="VLC Media Player's Option to use Tone Source Filter based device" src="http://alax.info/blog/wp-content/uploads/2009/02/27-image013.png" alt="VLC Media Player's Option to use Tone Source Filter based device" width="528" height="352" /></p>
<p>In order to configure the filter as such device, the library exports function <em>DoToneSourceFilterDevicePropertySheetModal</em>, which can be called using <em>rundll32</em> utility (<em>&#8220;rundll32 Acquisition.dll,DoToneSourceFilterDevicePropertySheetModal&#8221;</em> from command line):</p>
<p><img class="alignnone size-full wp-image-866" title="Devices Property Page" src="http://alax.info/blog/wp-content/uploads/2009/02/27-image014.png" alt="Devices Property Page" width="367" height="426" /></p>
<p>A partial Visual C++ .NET 2008 source code is <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/Extended7zShell">available from SVN</a>, release binary <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/MediaTools/_Bin/Release%20Trace/Acquisition.dll?format=raw">included</a>.</p>
<h2>File and Class Summary</h2>
<h3>Acqusition.dll</h3>
<p>Acqusition.dll (<a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/MediaTools/_Bin/Release%20Trace/Acquisition.dll?format=raw">download</a>) hosts the following classes:</p>
<ul>
<li>DirectShow Filters
<ul>
<li><span style="text-decoration: underline;">Tone Source Filter</span>, to generate reference/debug audio data</li>
</ul>
</li>
</ul>
<h2>Class Overview</h2>
<h3>Tone Source Filter</h3>
<p>The filter generates uninterrupted or interrupted reference sine waveform in form of PCM audio data.</p>
<ul>
<li>Filter Executable: Acquisition.dll</li>
<li>Filter CLSID: __uuidof(ToneSourceFilter) {8002935A-B2EC-40ef-968C-E0358E5DED10}</li>
<li>Filter Property Page CLSID: __uuidof(ToneSourceFilterGeneralPropertyPage), {EBD8ABB2-6DD3-4c54-A7F1-9FE4DA283EDF}, ToneSourceFilterPreferedFormatPropertyPage, {EE224187-4FA3-4c3f-9D5D-492694CCFEB7}</li>
<li>Filter Merit: <a href="http://msdn.microsoft.com/en-us/library/ms787275%28VS.85%29.aspx">MERIT_DO_NOT_USE</a></li>
<li>Filter Category: <a href="http://msdn.microsoft.com/en-us/library/ms783347%28VS.85%29.aspx">CLSID_LegacyAmFilterCategory</a> (also configurable as <a href="http://msdn.microsoft.com/en-us/library/ms783347(VS.85).aspx">CLSID_AudioInputDeviceCategory</a>)</li>
<li>Filter Interfaces: <a href="http://msdn.microsoft.com/en-us/library/ms682273%28VS.85%29.aspx">IPersistStreamInit</a>, <a href="http://msdn.microsoft.com/en-us/library/ms690091%28VS.85%29.aspx">IPersistStream</a>, <a href="http://msdn.microsoft.com/en-us/library/ms695217%28VS.85%29.aspx">ISpecifyPropertyPages</a>, <a href="http://msdn.microsoft.com/en-us/library/aa768205(VS.85).aspx">IPersistPropertyBag</a>, <a href="http://msdn.microsoft.com/en-us/library/ms784601%28VS.85%29.aspx">IBaseFilter</a>, <a href="http://msdn.microsoft.com/en-us/library/ms785914%28VS.85%29.aspx">IMediaFilter</a>, <a href="http://msdn.microsoft.com/en-us/library/ms688695%28VS.85%29.aspx">IPersist</a>, <a href="http://msdn.microsoft.com/en-us/library/ms784083%28VS.85%29.aspx">IAMovieSetup</a>, <a href="http://msdn.microsoft.com/en-us/library/ms783950%28VS.85%29.aspx">IAMFilterMiscFlags</a>, IToneSourceFilter, <a href="http://msdn.microsoft.com/en-us/library/ms221608.aspx">IDispatch</a></li>
<li>Filter Pins: single ouput pin (Ouput)</li>
<li>Output Pin Media Types: MEDIATYPE_Audio/MEDIASUBTYPE_PCM</li>
<li>Output Pin Interfaces: <a href="http://msdn.microsoft.com/en-us/library/ms786565%28VS.85%29.aspx">IPin</a>, <a href="http://msdn.microsoft.com/en-us/library/ms786054%28VS.85%29.aspx">IMemInputPin</a>, <a href="http://msdn.microsoft.com/en-us/library/dd319764(VS.85).aspx">IAMPushSource</a>, <a href="http://msdn.microsoft.com/en-us/library/dd389383(VS.85).aspx">IAMLatency</a>, <a href="http://msdn.microsoft.com/en-us/library/dd389142(VS.85).aspx">IAMBufferNegotiation</a>, <a href="http://msdn.microsoft.com/en-us/library/bb174586(VS.85).aspx">IKsPropertySet</a>, <a href="http://msdn.microsoft.com/en-us/library/dd319784(VS.85).aspx">IAMStreamConfig</a></li>
</ul>
<h4>Remarks</h4>
<p>The hosting library (DLL) exposes <em>DoToneSourceFilterDevicePropertySheetModal</em> function which provides GUI to configure the filter as one or more audio capture source device, which can be enumerated by <a href="http://msdn.microsoft.com/en-us/library/dd407180(VS.85).aspx">System Device Enumerator</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/859/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MediaTools: HTTP Stream File Renderer Filter and more</title>
		<link>http://alax.info/blog/817</link>
		<comments>http://alax.info/blog/817#comments</comments>
		<pubDate>Sat, 14 Feb 2009 18:08:53 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[Media Tools]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[WTL]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[camera]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[JPEG]]></category>
		<category><![CDATA[M-JPEG]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=817</guid>
		<description><![CDATA[<a href="http://alax.info/blog/817" title="MediaTools: HTTP Stream File Renderer Filter and more"></a>In order to better troubleshoot network cameras and other devices, I added a new DirectShow filter to write HTTP response headers and body into a single file, one file (actually a pairs of files, the second file contains UTF-8 formatted &#8230;<p class="read-more"><a href="http://alax.info/blog/817">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/817" title="MediaTools: HTTP Stream File Renderer Filter and more"></a><p>In order to better troubleshoot network cameras and other devices, I added a new DirectShow filter to write HTTP response headers and body into a single file, one file (actually a pairs of files, the second file contains UTF-8 formatted HTTP response headers) per HTTP response.</p>
<p>While troubleshootting <a href="http://ijg.org">JPEG</a> artefact issue with I used the following graph:</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2009/02/14-image001.png"><img class="alignnone size-medium wp-image-818" title="HTTP Stream File Renderer Filter in Filter Graph" src="http://alax.info/blog/wp-content/uploads/2009/02/14-image001-300x188.png" alt="HTTP Stream File Renderer Filter in Filter Graph" width="300" height="188" /></a></p>
<p>which started <a href="http://en.wikipedia.org/wiki/Motion_JPEG#M-JPEG_over_HTTP">M-JPEG</a> streaming from a camera and had entire stream written into <em>Response-01586228-0001-0001-Headers.txt</em> (Headers) and <em>Response-01586228-0001-0001.dat</em> (Data) files, while parsed JPEG frames were also written into individual files and were available for comparison.</p>
<p>Other changes include:</p>
<ul>
<li>new HTTP Stream File Renderer Filter (details are below)</li>
<li>attachable media types on internally used memory allocators, which enable filters to effectively reagree media types in running state</li>
<li>workaround for <a href="http://panasonic.co.jp/pcc/products/en/netwkcam/lineup/bl-c140/index.html">Panasonic BL-C140</a> camera (may be also helpful for other models), details <a href="http://alax.info/blog/741/comment-page-1#comment-5669">here</a></li>
</ul>
<p>There also seems to be a bug in <a href="http://www.intel.com/cd/software/products/asmo-na/eng/302910.htm">Intel IPP 6.0</a> JPEG decoder that leaves bottom right image block incorrectly decoded, only when a sequence of images is decoded and the frame is not the first in the sequence.</p>
<p>A partial Visual C++ .NET 2008 source code is <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/Extended7zShell">available from SVN</a>, release binary <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/MediaTools/_Bin/Release Trace/Acquisition.dll?format=raw">included</a>.</p>
<p><span id="more-817"></span></p>
<h2>File and Class Summary</h2>
<h3>Acqusition.dll</h3>
<p>Acqusition.dll (<a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/MediaTools/_Bin/Release Trace/Acquisition.dll?format=raw">download</a>) hosts the following classes:</p>
<ul>
<li>DirectShow Filters
<ul>
<li><span style="text-decoration: underline;">HTTP Stream File Renderer Filter</span>, to write raw HTTP response headers and data into files</li>
</ul>
</li>
</ul>
<h2>Class Overview</h2>
<h3>HTTP Stream File Renderer Filter</h3>
<p>The filter renders input stream of one or more HTTP responses and write HTTP response headers and data into files, per HTTP response, into provided directory.</p>
<ul>
<li>Filter Executable: Acquisition.dll</li>
<li>Filter CLSID: __uuidof(HttpStreamFileRendererFilter) {B02FDAEF-E851-4380-82D6-04772E33675D}</li>
<li>Filter Property Page CLSID: __uuidof(HttpStreamFileRendererFilterDirectoryPropertyPage), {FAF31D20-842A-46b4-B6F8-E410FB0188A5}</li>
<li>Filter Merit: <a href="http://msdn.microsoft.com/en-us/library/ms787275(VS.85).aspx">MERIT_DO_NOT_USE</a></li>
<li>Filter Category: <a href="http://msdn.microsoft.com/en-us/library/ms783347(VS.85).aspx">CLSID_LegacyAmFilterCategory</a></li>
<li>Filter Interfaces: <a href="http://msdn.microsoft.com/en-us/library/ms682273(VS.85).aspx">IPersistStreamInit</a>, <a href="http://msdn.microsoft.com/en-us/library/ms690091(VS.85).aspx">IPersistStream</a>, <a href="http://msdn.microsoft.com/en-us/library/ms695217(VS.85).aspx">ISpecifyPropertyPages</a>, <a href="http://msdn.microsoft.com/en-us/library/ms784601(VS.85).aspx">IBaseFilter</a>, <a href="http://msdn.microsoft.com/en-us/library/ms785914(VS.85).aspx">IMediaFilter</a>, <a href="http://msdn.microsoft.com/en-us/library/ms688695(VS.85).aspx">IPersist</a>, <a href="http://msdn.microsoft.com/en-us/library/ms683857.aspx"></a><a href="http://msdn.microsoft.com/en-us/library/ms784083(VS.85).aspx">IAMovieSetup</a>, <a href="http://msdn.microsoft.com/en-us/library/ms783950(VS.85).aspx">IAMFilterMiscFlags</a>, IHttpStreamFileRendererFilter, <a href="http://msdn.microsoft.com/en-us/library/ms221608.aspx">IDispatch</a>, <a href="http://msdn.microsoft.com/en-us/library/ms785712.aspx">IFileSinkFilter2</a> (not available in graphedt.exe process), <a href="http://msdn.microsoft.com/en-us/library/ms785715(VS.85).aspx">IFileSinkFilter</a> (not available in graphedt.exe process)</li>
<li>Filter Pins: single input pin (Input)</li>
<li>Input Pin Media Types: MEDIATYPE_Stream/MEDIASUBTYPE_NULL</li>
<li>Input Pin Interfaces: <a href="http://msdn.microsoft.com/en-us/library/ms786565(VS.85).aspx">IPin</a>, <a href="http://msdn.microsoft.com/en-us/library/ms786054(VS.85).aspx">IMemInputPin</a></li>
</ul>
<h4>Remarks</h4>
<p>None.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/817/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The easiest yet user-friendly WTL way to Minimize Application to System Tray Icon</title>
		<link>http://alax.info/blog/771</link>
		<comments>http://alax.info/blog/771#comments</comments>
		<pubDate>Wed, 21 Jan 2009 07:56:26 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[WTL]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=771</guid>
		<description><![CDATA[<a href="http://alax.info/blog/771" title="The easiest yet user-friendly WTL way to Minimize Application to System Tray Icon"></a>A good old task to easily minimize to system tray icon to not clog the application bar and without too much thinking about it. How To with WTL? The key points are: manage NOTIFYICONDATA structure (obviously!), where non-zero .cbSize will &#8230;<p class="read-more"><a href="http://alax.info/blog/771">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/771" title="The easiest yet user-friendly WTL way to Minimize Application to System Tray Icon"></a><p>A good old task to easily minimize to system tray icon to not clog the application bar and without too much thinking about it. How To with WTL?</p>
<p>The key points are:</p>
<ul>
<li>manage <a href="http://msdn.microsoft.com/en-us/library/bb773352(VS.85).aspx">NOTIFYICONDATA</a> structure (obviously!), where non-zero .cbSize will be an indication of created icon</li>
<li>create an icon in <a href="http://msdn.microsoft.com/en-us/library/ms646360.aspx">WM_SYSCOMMAND</a>/SC_MINIMIZE handler and hide instead default minimization</li>
<li>handle icon&#8217;s <a href="http://msdn.microsoft.com/en-us/library/ms645606(VS.85).aspx">WM_LBUTTONDBLCLK</a> to restore and <a href="http://msdn.microsoft.com/en-us/library/ms646243(VS.85).aspx">WM_RBUTTONUP</a> to pop up a menu</li>
<li>use default dialog menu to avoid having private one, handle SC_RESTORE and SC_CLOSE system commands to restore and close from system tray icon popup menu</li>
</ul>
<p><a href="http://alax.info/blog/wp-content/uploads/2009/01/21-image001.png"><img class="alignnone size-medium wp-image-772" title="System Tray Menu Icon Menu" src="http://alax.info/blog/wp-content/uploads/2009/01/21-image001-300x170.png" alt="" width="300" height="170" /></a></p>
<p>Relevant source code from application main window (dialog) class:</p>
<p><span id="more-771"></span></p>
<pre style="background: #ffffff none repeat scroll 0% 0%; color: #000000;"><span style="font-weight: bold; color: #800000;">class</span> CMainDialog <span style="color: #800080;">:</span>
<span style="color: #808030;">.</span><span style="color: #808030;">.</span><span style="color: #808030;">.</span>
<span style="color: #800080;">{</span>
<span style="font-weight: bold; color: #800000;">public</span><span style="color: #e34adc;">:</span>

BEGIN_MSG_MAP_EX<span style="color: #808030;">(</span>CMainDialog<span style="color: #808030;">)</span>
<span style="color: #808030;">.</span><span style="color: #808030;">.</span><span style="color: #808030;">.</span>
    MSG_WM_INITDIALOG<span style="color: #808030;">(</span>OnInitDialog<span style="color: #808030;">)</span>
    MSG_WM_DESTROY<span style="color: #808030;">(</span>OnDestroy<span style="color: #808030;">)</span>
    MSG_WM_SYSCOMMAND<span style="color: #808030;">(</span>OnSysCommand<span style="color: #808030;">)</span>
    MESSAGE_HANDLER_EX<span style="color: #808030;">(</span>WM_SYSTEMTRAYICON<span style="color: #808030;">,</span> OnSystemTrayIcon<span style="color: #808030;">)</span>
    COMMAND_ID_HANDLER_EX<span style="color: #808030;">(</span>SC_RESTORE<span style="color: #808030;">,</span> OnScRestore<span style="color: #808030;">)</span>
    COMMAND_ID_HANDLER_EX<span style="color: #808030;">(</span>SC_CLOSE<span style="color: #808030;">,</span> OnScClose<span style="color: #808030;">)</span>
<span style="color: #808030;">.</span><span style="color: #808030;">.</span><span style="color: #808030;">.</span>
END_MSG_MAP<span style="color: #808030;">(</span><span style="color: #808030;">)</span>
<span style="color: #808030;">.</span><span style="color: #808030;">.</span><span style="color: #808030;">.</span>
    <span style="font-weight: bold; color: #800000;">enum</span>
    <span style="color: #800080;">{</span>
        WM_FIRST <span style="color: #808030;">=</span> WM_APP<span style="color: #808030;">,</span>
        WM_SYSTEMTRAYICON<span style="color: #808030;">,</span>
    <span style="color: #800080;">}</span><span style="color: #800080;">;</span>
<span style="color: #808030;">.</span><span style="color: #808030;">.</span><span style="color: #808030;">.</span>
<span style="font-weight: bold; color: #800000;">private</span><span style="color: #e34adc;">:</span>
    <span style="color: #603000;">NOTIFYICONDATA</span> m_NotifyIconData<span style="color: #800080;">;</span>
<span style="color: #808030;">.</span><span style="color: #808030;">.</span><span style="color: #808030;">.</span>
<span style="font-weight: bold; color: #800000;">public</span><span style="color: #e34adc;">:</span>
<span style="color: #696969;">// CMainDialog</span>
    CMainDialog<span style="color: #808030;">(</span><span style="color: #808030;">)</span> <span style="font-weight: bold; color: #800000;">throw</span><span style="color: #808030;">(</span><span style="color: #808030;">)</span>
    <span style="color: #800080;">{</span>
        <span style="color: #400000;">ZeroMemory</span><span style="color: #808030;">(</span><span style="color: #808030;">&amp;</span>m_NotifyIconData<span style="color: #808030;">,</span> <span style="font-weight: bold; color: #800000;">sizeof</span> m_NotifyIconData<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        <span style="color: #808030;">.</span><span style="color: #808030;">.</span><span style="color: #808030;">.</span>
    <span style="color: #800080;">}</span>

<span style="color: #696969;">// Window message handlers</span>
    <span style="color: #603000;">LRESULT</span> OnInitDialog<span style="color: #808030;">(</span><span style="color: #603000;">HWND</span><span style="color: #808030;">,</span> <span style="color: #603000;">LPARAM</span><span style="color: #808030;">)</span>
    <span style="color: #800080;">{</span>
        <span style="color: #400000;">ZeroMemory</span><span style="color: #808030;">(</span><span style="color: #808030;">&amp;</span>m_NotifyIconData<span style="color: #808030;">,</span> <span style="font-weight: bold; color: #800000;">sizeof</span> m_NotifyIconData<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        <span style="color: #808030;">.</span><span style="color: #808030;">.</span><span style="color: #808030;">.</span>
    <span style="color: #800080;">}</span>
    <span style="color: #603000;">LRESULT</span> OnDestroy<span style="color: #808030;">(</span><span style="color: #808030;">)</span>
    <span style="color: #800080;">{</span>
        <span style="font-weight: bold; color: #800000;">if</span><span style="color: #808030;">(</span>m_NotifyIconData<span style="color: #808030;">.</span>cbSize<span style="color: #808030;">)</span>
        <span style="color: #800080;">{</span>
            <span style="color: #400000;">Shell_NotifyIcon</span><span style="color: #808030;">(</span><span style="color: #7d0045;">NIM_DELETE</span><span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>m_NotifyIconData<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
            <span style="color: #400000;">ZeroMemory</span><span style="color: #808030;">(</span><span style="color: #808030;">&amp;</span>m_NotifyIconData<span style="color: #808030;">,</span> <span style="font-weight: bold; color: #800000;">sizeof</span> m_NotifyIconData<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        <span style="color: #800080;">}</span>
        <span style="color: #808030;">.</span><span style="color: #808030;">.</span><span style="color: #808030;">.</span>
    <span style="color: #800080;">}</span>
    <span style="color: #603000;">LRESULT</span> OnSysCommand<span style="color: #808030;">(</span><span style="color: #603000;">UINT</span> nCommand<span style="color: #808030;">,</span> <span style="color: #603000;">CPoint</span><span style="color: #808030;">)</span>
    <span style="color: #800080;">{</span>
        <span style="font-weight: bold; color: #800000;">switch</span><span style="color: #808030;">(</span>nCommand<span style="color: #808030;">)</span>
        <span style="color: #800080;">{</span>
        <span style="font-weight: bold; color: #800000;">case </span><span style="color: #7d0045;">SC_MINIMIZE</span><span style="color: #e34adc;">:</span>
            <span style="font-weight: bold; color: #800000;">if</span><span style="color: #808030;">(</span><span style="color: #808030;">!</span>m_NotifyIconData<span style="color: #808030;">.</span>cbSize<span style="color: #808030;">)</span>
            <span style="color: #800080;">{</span>
                m_NotifyIconData<span style="color: #808030;">.</span>cbSize <span style="color: #808030;">=</span> NOTIFYICONDATAA_V1_SIZE<span style="color: #800080;">;</span>
                m_NotifyIconData<span style="color: #808030;">.</span>hWnd <span style="color: #808030;">=</span> m_hWnd<span style="color: #800080;">;</span>
                m_NotifyIconData<span style="color: #808030;">.</span>uID <span style="color: #808030;">=</span> <span style="color: #008c00;">1</span><span style="color: #800080;">;</span>
                m_NotifyIconData<span style="color: #808030;">.</span>uFlags <span style="color: #808030;">=</span> NIF_ICON <span style="color: #808030;">|</span> NIF_MESSAGE <span style="color: #808030;">|</span> NIF_TIP<span style="color: #800080;">;</span>
                m_NotifyIconData<span style="color: #808030;">.</span>uCallbackMessage <span style="color: #808030;">=</span> WM_SYSTEMTRAYICON<span style="color: #800080;">;</span>
                m_NotifyIconData<span style="color: #808030;">.</span>hIcon <span style="color: #808030;">=</span> AtlLoadIconImage<span style="color: #808030;">(</span>IDI_MODULE<span style="color: #808030;">,</span> LR_DEFAULTCOLOR<span style="color: #808030;">,</span> <span style="color: #400000;">GetSystemMetrics</span><span style="color: #808030;">(</span>SM_CXSMICON<span style="color: #808030;">)</span><span style="color: #808030;">,</span> <span style="color: #400000;">GetSystemMetrics</span><span style="color: #808030;">(</span>SM_CYSMICON<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
                <span style="color: #603000;">CString</span> sWindowText<span style="color: #800080;">;</span>
                <span style="color: #400000;">GetWindowText</span><span style="color: #808030;">(</span>sWindowText<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
                _tcscpy_s<span style="color: #808030;">(</span>m_NotifyIconData<span style="color: #808030;">.</span>szTip<span style="color: #808030;">,</span> sWindowText<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
                <span style="font-weight: bold; color: #800000;">if</span><span style="color: #808030;">(</span><span style="color: #808030;">!</span><span style="color: #400000;">Shell_NotifyIcon</span><span style="color: #808030;">(</span><span style="color: #7d0045;">NIM_ADD</span><span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>m_NotifyIconData<span style="color: #808030;">)</span><span style="color: #808030;">)</span>
                <span style="color: #800080;">{</span>
                    SetMsgHandled<span style="color: #808030;">(</span>FALSE<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
                    <span style="font-weight: bold; color: #800000;">return</span> <span style="color: #008c00;">0</span><span style="color: #800080;">;</span>
                <span style="color: #800080;">}</span>
            <span style="color: #800080;">}</span>
            <span style="color: #400000;">ShowWindow</span><span style="color: #808030;">(</span>SW_HIDE<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
            <span style="font-weight: bold; color: #800000;">break</span><span style="color: #800080;">;</span>
        <span style="color: #808030;">.</span><span style="color: #808030;">.</span><span style="color: #808030;">.</span>
<span style="color: #e34adc;">        </span><span style="font-weight: bold; color: #800000;">default</span><span style="color: #e34adc;">:</span>
            SetMsgHandled<span style="color: #808030;">(</span>FALSE<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        <span style="color: #800080;">}</span>
        <span style="font-weight: bold; color: #800000;">return</span> <span style="color: #008c00;">0</span><span style="color: #800080;">;</span>
    <span style="color: #800080;">}</span>
    <span style="color: #603000;">LRESULT</span> OnSystemTrayIcon<span style="color: #808030;">(</span><span style="color: #603000;">UINT</span><span style="color: #808030;">,</span> <span style="color: #603000;">WPARAM</span> wParam<span style="color: #808030;">,</span> <span style="color: #603000;">LPARAM</span> lParam<span style="color: #808030;">)</span>
    <span style="color: #800080;">{</span>
        ATLASSERT<span style="color: #808030;">(</span>wParam <span style="color: #808030;">=</span><span style="color: #808030;">=</span> <span style="color: #008c00;">1</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        <span style="font-weight: bold; color: #800000;">switch</span><span style="color: #808030;">(</span>lParam<span style="color: #808030;">)</span>
        <span style="color: #800080;">{</span>
        <span style="font-weight: bold; color: #800000;">case </span><span style="color: #7d0045;">WM_LBUTTONDBLCLK</span><span style="color: #e34adc;">:</span>
            <span style="color: #400000;">SendMessage</span><span style="color: #808030;">(</span><span style="color: #7d0045;">WM_COMMAND</span><span style="color: #808030;">,</span> SC_RESTORE<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
            <span style="font-weight: bold; color: #800000;">break</span><span style="color: #800080;">;</span>
        <span style="font-weight: bold; color: #800000;">case </span><span style="color: #7d0045;">WM_RBUTTONUP</span><span style="color: #e34adc;">:</span>
            <span style="color: #800080;">{</span>
                <span style="color: #400000;">SetForegroundWindow</span><span style="color: #808030;">(</span>m_hWnd<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
                CMenuHandle Menu <span style="color: #808030;">=</span> <span style="color: #400000;">GetSystemMenu</span><span style="color: #808030;">(</span>FALSE<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
                Menu<span style="color: #808030;">.</span><span style="color: #400000;">EnableMenuItem</span><span style="color: #808030;">(</span>SC_RESTORE<span style="color: #808030;">,</span> MF_BYCOMMAND <span style="color: #808030;">|</span> MF_ENABLED<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
                Menu<span style="color: #808030;">.</span><span style="color: #400000;">EnableMenuItem</span><span style="color: #808030;">(</span>SC_MOVE<span style="color: #808030;">,</span> MF_BYCOMMAND <span style="color: #808030;">|</span> MF_GRAYED<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
                Menu<span style="color: #808030;">.</span><span style="color: #400000;">EnableMenuItem</span><span style="color: #808030;">(</span>SC_SIZE<span style="color: #808030;">,</span> MF_BYCOMMAND <span style="color: #808030;">|</span> MF_GRAYED<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
                Menu<span style="color: #808030;">.</span><span style="color: #400000;">EnableMenuItem</span><span style="color: #808030;">(</span>SC_MINIMIZE<span style="color: #808030;">,</span> MF_BYCOMMAND <span style="color: #808030;">|</span> MF_GRAYED<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
                Menu<span style="color: #808030;">.</span><span style="color: #400000;">EnableMenuItem</span><span style="color: #808030;">(</span>SC_MAXIMIZE<span style="color: #808030;">,</span> MF_BYCOMMAND <span style="color: #808030;">|</span> MF_GRAYED<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
                Menu<span style="color: #808030;">.</span><span style="color: #400000;">EnableMenuItem</span><span style="color: #808030;">(</span>SC_CLOSE<span style="color: #808030;">,</span> MF_BYCOMMAND <span style="color: #808030;">|</span> MF_ENABLED<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
                <span style="color: #603000;">CPoint</span> Position<span style="color: #800080;">;</span>
                ATLVERIFY<span style="color: #808030;">(</span><span style="color: #400000;">GetCursorPos</span><span style="color: #808030;">(</span><span style="color: #808030;">&amp;</span>Position<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
                Menu<span style="color: #808030;">.</span><span style="color: #400000;">TrackPopupMenu</span><span style="color: #808030;">(</span>TPM_LEFTALIGN <span style="color: #808030;">|</span> TPM_BOTTOMALIGN<span style="color: #808030;">,</span> Position<span style="color: #808030;">.</span>x<span style="color: #808030;">,</span> Position<span style="color: #808030;">.</span>y<span style="color: #808030;">,</span> m_hWnd<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
            <span style="color: #800080;">}</span>
            <span style="font-weight: bold; color: #800000;">break</span><span style="color: #800080;">;</span>
        <span style="color: #800080;">}</span>
        <span style="font-weight: bold; color: #800000;">return</span> <span style="color: #008c00;">0</span><span style="color: #800080;">;</span>
    <span style="color: #800080;">}</span>
    <span style="color: #603000;">LRESULT</span> OnScRestore<span style="color: #808030;">(</span><span style="color: #603000;">UINT</span><span style="color: #808030;">,</span> <span style="color: #603000;">INT</span><span style="color: #808030;">,</span> <span style="color: #603000;">HWND</span><span style="color: #808030;">)</span>
    <span style="color: #800080;">{</span>
        <span style="font-weight: bold; color: #800000;">if</span><span style="color: #808030;">(</span>m_NotifyIconData<span style="color: #808030;">.</span>cbSize<span style="color: #808030;">)</span>
        <span style="color: #800080;">{</span>
            <span style="color: #400000;">Shell_NotifyIcon</span><span style="color: #808030;">(</span><span style="color: #7d0045;">NIM_DELETE</span><span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>m_NotifyIconData<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
            <span style="color: #400000;">ZeroMemory</span><span style="color: #808030;">(</span><span style="color: #808030;">&amp;</span>m_NotifyIconData<span style="color: #808030;">,</span> <span style="font-weight: bold; color: #800000;">sizeof</span> m_NotifyIconData<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        <span style="color: #800080;">}</span>
        <span style="color: #400000;">ShowWindow</span><span style="color: #808030;">(</span>SW_SHOW<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        <span style="color: #400000;">BringWindowToTop</span><span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        <span style="font-weight: bold; color: #800000;">return</span> <span style="color: #008c00;">0</span><span style="color: #800080;">;</span>
    <span style="color: #800080;">}</span>
    <span style="color: #603000;">LRESULT</span> OnScClose<span style="color: #808030;">(</span><span style="color: #603000;">UINT</span><span style="color: #808030;">,</span> <span style="color: #603000;">INT</span><span style="color: #808030;">,</span> <span style="color: #603000;">HWND</span><span style="color: #808030;">)</span>
    <span style="color: #800080;">{</span>
        <span style="color: #400000;">PostMessage</span><span style="color: #808030;">(</span><span style="color: #7d0045;">WM_COMMAND</span><span style="color: #808030;">,</span> IDCANCEL<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        <span style="font-weight: bold; color: #800000;">return</span> <span style="color: #008c00;">0</span><span style="color: #800080;">;</span>
    <span style="color: #800080;">}</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/771/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

