<?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/category/technology/wtl/feed" rel="self" type="application/rss+xml" />
	<link>http://alax.info/blog</link>
	<description>// Software Production Line</description>
	<lastBuildDate>Fri, 03 Feb 2012 22:49:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>File Mappings: Virtual Memory and Virtual Address Space</title>
		<link>http://alax.info/blog/1325</link>
		<comments>http://alax.info/blog/1325#comments</comments>
		<pubDate>Thu, 15 Dec 2011 23:36:34 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[WTL]]></category>
		<category><![CDATA[32-bit]]></category>
		<category><![CDATA[CreateFileMapping]]></category>
		<category><![CDATA[file mapping]]></category>
		<category><![CDATA[MapViewOfFile]]></category>
		<category><![CDATA[RAM]]></category>
		<category><![CDATA[virtual memory]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1325</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1325" title="File Mappings: Virtual Memory and Virtual Address Space"></a>More and more applications hit the Windows limit of available address space for 32-bit applications, and the whole concept becomes more important for understanding due to necessity to work things around. A thing, which is more or less easy to &#8230;<p class="read-more"><a href="http://alax.info/blog/1325">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1325" title="File Mappings: Virtual Memory and Virtual Address Space"></a><p>More and more applications hit the Windows limit of available <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366912%28v=VS.85%29.aspx">address space</a> for 32-bit applications, and the whole concept becomes more important for understanding due to necessity to work things around.</p>
<p>A thing, which is more or less easy to understand, is that a user mode 32-bit application can address 2^32 addresses. The addresses are not directly physical RAM and the operating system is responsible for management of the mapping addresses into RAM as a part of virtual memory manager operation. Paged memory organization is <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366914%28v=VS.85%29.aspx">well documented on MSDN</a>, and the questions has been raised numerous times. An interesting question is whether a 32-bit application can effectively manage memory amounts exceeding address space limits.</p>
<p>Back in 80386 times, the systems could address megabytes of RAM in 16-bit code through <a href="http://en.wikipedia.org/wiki/EXtended_Memory_Specification#eXtended_Memory_Specification_.28XMS.29">XMS</a> and <a href="http://en.wikipedia.org/wiki/Expanded_memory">EMS</a> services. The application could access &#8220;high&#8221; memory addresses by requesting mapping portions of RAM into lower megabyte address space. In some way similar technique is also here for 32-bit applications in Windows through use of <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366556%28v=vs.85%29.aspx">file mappings</a>.</p>
<p>A regular memory backed file mapping requests Windows to reserve a memory block which becomes available for mapping into address space of one or more processes. Creating file mapping itself does not imply mapping and this leaves a great option for the owner to allocate more data than it can actually map into address space: if 32-bit process virtual address space is fundamentally constrained, the file mapping allocation space is more loosely limited by amount of physical memory and paging file. The application can allocate 2, 3, 4 and more gigabytes of memory &#8211; it just cannot still map it all together into address space and make it available simultaneously.</p>
<p>The FileMappingVirtualAddress utility does a simple thing:</p>
<ul>
<li>on startup it allocates (<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366537%28v=VS.85%29.aspx">CreateFileMapping</a>) as many 256 MB file mappings as operating system would allow, and shows it in a list</li>
<li>each time a user checks a box, the application maps (<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366761%28v=vs.85%29.aspx">MapViewOfFile</a>) corresponding file mapping into address space; unchecking a box unmaps the view</li>
<li>the caption shows currently used and maximal available virtual address space</li>
</ul>
<p><img class="alignnone size-full wp-image-1326" title="Allocated and Mapped 256 MB File Mappings" src="http://alax.info/blog/wp-content/uploads/2011/12/Image001.png" alt="" width="462" height="426" /></p>
<p>A plain 32-bit version of the application allocated 51 blocks for me (which totals in 13 GB of memory, with 8 GB physical RAM installed in the system). The allocation takes place immediately because the operating system does not actually make all this memory prepared for use &#8211; the actual pages would be allocated and ready to use on demand when the application requires them.</p>
<p><strong>The most important part made so obvious is that the 32-bit application succeeds in allocating well over 4 GB, which is maximal virtual address space it can ever get.</strong></p>
<p>The virtual address space in use is only 1641 MB and another request to map an additional section with <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366761%28v=vs.85%29.aspx">MapViewOfFile</a> would fail (the default address space limit is 2 GB) &#8211; space fragmentation make mapping unavailable earlier than we actually use the whole space, since the API would need to allocate contiguous range of addresses to satisfy the request.</p>
<p><img class="alignnone size-full wp-image-1327" title="Error Hitting Virtual Address Space Limit" src="http://alax.info/blog/wp-content/uploads/2011/12/Image002.png" alt="" width="426" height="171" /></p>
<p>32-bit application built with <a href="http://msdn.microsoft.com/en-us/library/wz223b1z%28v=VS.100%29.aspx">/LARGEADDRESSAWARE</a> parameter might manage to do more allocations: 64-bit versions of Windows provide 4 GB of addresses to 32-bit processes. 32-bit operating systems might also be extending the limit in case of <a href="http://support.microsoft.com/kb/291988">4GB RAM Tuning</a> (which would typically be 3 GB of space for a process).</p>
<p><img class="alignnone size-full wp-image-1328" title="File Mappings with /LARGEADDRESSAWARE" src="http://alax.info/blog/wp-content/uploads/2011/12/Image003.png" alt="" width="462" height="426" /></p>
<p>Finally, 64-bit build of the application is free from virtual address space limit as the limit is <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa384271%28v=VS.85%29.aspx">8 terabytes</a>. The mapping is again instantaneous because actual RAM will be supplied on first request to mapped pages only.</p>
<p><img class="alignnone size-full wp-image-1329" title="File Mappings in 64-bit Code" src="http://alax.info/blog/wp-content/uploads/2011/12/Image004.png" alt="" width="462" height="426" /></p>
<p>A binary [<a href="http://www.alax.info/svn/public/trunk/Utilities/FileMappingVirtualAddress/Win32/Release/FileMappingVirtualAddress.exe">Win32</a>, <a href="http://www.alax.info/svn/public/trunk/Utilities/FileMappingVirtualAddress/Win32/Release%20with%20Large%20Address%20Aware/FileMappingVirtualAddress.exe">Win32 with /LARGEADDRESSAWARE</a>, <a href="http://www.alax.info/svn/public/trunk/Utilities/FileMappingVirtualAddress/x64/Release/FileMappingVirtualAddress.exe">x64</a>] and partial Visual C++ .NET 2010 <a href="http://www.alax.info/trac/public/browser/trunk/Utilities/FileMappingVirtualAddress">partial source code</a> are available from SVN.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1325/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GPS Location/Coordinate Converter: Multiple Locations at Once</title>
		<link>http://alax.info/blog/1313</link>
		<comments>http://alax.info/blog/1313#comments</comments>
		<pubDate>Mon, 14 Nov 2011 18:06:26 +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[gps]]></category>
		<category><![CDATA[rally]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1313</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1313" title="GPS Location/Coordinate Converter: Multiple Locations at Once"></a>Today&#8217;s update lets you convert multiple locations at once with a single click. Here is the story behind the update and use case scenario. In rally raid sport events (so called baja), a team gets a road book for the &#8230;<p class="read-more"><a href="http://alax.info/blog/1313">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1313" title="GPS Location/Coordinate Converter: Multiple Locations at Once"></a><p>Today&#8217;s update lets you convert multiple locations at once with a single click. Here is the story behind the update and use case scenario.</p>
<p>In <a href="http://en.wikipedia.org/wiki/Rally_raid">rally raid</a> sport events (so called <em>baja</em>), a team gets a road book for the next competition day in a few hours before actual start. The GPS coordinates are printed on one of the pages of the roadbook and are not available in any electronic format.</p>
<p>There were just a few times when the organizer also uploaded a copy of a file with the coordinates and shared a link to download from, but this was rather an exception. Another alternate option was a dedicated person to upload the coordinates (they were earlier full tracks, but at some point tracks were no longer available at all) to pilots&#8217; hardware, but in a state of pre-start рфыеу and variety of GPS hardware, formats, cable etc. this created lines of people. The most one can rely on is a sheet of paper with GPS coordinates. The mistery does not end even here as you don&#8217;t know whether you are to get Degrees only, or Degrees and Minutes, or Degrees, Minutes and Seconds. Everything depends on software the organizer uses.</p>
<p><img class="alignnone size-full wp-image-1314" title="A Page with GPS Locations in Road Book " src="http://alax.info/blog/wp-content/uploads/2011/11/Scan1.jpg" alt="" width="480" height="307" /></p>
<p>As soon as you get a hard copy of this, the idea is to upload it into device as quickly as possible because there are other things to do and the time is normally 11 PM when the race is to start 7 AM next day tens of miles away from you. The time interval will be shared by uploading data, sleeping and transfer to start location.</p>
<p>The utility is here to grant extra sleep time. Since it is capable to accept various separators on the input, a convenient way is to quickly type in the text in Microsoft Excel, check the data against the hardcopy, and copy into clipboard to transfer to the utility.</p>
<p><img class="alignnone size-full wp-image-1315" title="GPS Coordinates in Microsoft Excel" src="http://alax.info/blog/wp-content/uploads/2011/11/Image001.png" alt="" width="558" height="472" /></p>
<p>A hotkey with conversion transfers data into format of interest, and single &#8220;Find and Replace&#8221; operation creates a good OziExplorer waypoint file which is good for upload onto portable navigation device.<img class="alignnone size-large wp-image-1316" title="Visual Studio with OziExplorer Waypoint Data" src="http://alax.info/blog/wp-content/uploads/2011/11/Image002-687x600.png" alt="" width="620" height="541" /></p>
<p>The whole thing take a few minutes to do with minimal routine typing in.</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>
<p>Bonus picture, rally raid Suzuki is on the way to score the victory and the rally promotional teaser:</p>
<p><a href="https://picasaweb.google.com/105209331201471192155/BajaPolygon4thRoundOfUkrainianCup2011InRallyRaidsNearNovomoskovskUkraine"><img class="alignnone" src="https://lh6.googleusercontent.com/--53JPr3B2Hw/TsD_WnIrE9I/AAAAAAAAFXo/PjmYMfS_WJI/s640/DSC04127a.jpg" alt="Rally Raid Suzuki Samurai on the Way" width="640" height="426" /></a></p>
<p><object width="640" height="360"><param name="movie" value="http://www.youtube.com/v/k-_-Re2PhQ8&#038;rel=0&#038;hl=en_US&#038;feature=player_embedded&#038;version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.youtube.com/v/k-_-Re2PhQ8&#038;rel=0&#038;hl=en_US&#038;feature=player_embedded&#038;version=3" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="360"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1313/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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: GPS Location/Coordinate Converter</title>
		<link>http://alax.info/blog/1297</link>
		<comments>http://alax.info/blog/1297#comments</comments>
		<pubDate>Wed, 12 Oct 2011 21:20:40 +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=1297</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1297" title="Utility Clearance: GPS Location/Coordinate Converter"></a>This tool came up as a result of mess around GPS coordinate formatting and variety of popular formats and notations. Some use latitude and longitude degrees, some prefer degrees and minutes with fractional part. this does not take into account &#8230;<p class="read-more"><a href="http://alax.info/blog/1297">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1297" title="Utility Clearance: GPS Location/Coordinate Converter"></a><p>This tool came up as a result of mess around GPS coordinate formatting and variety of popular formats and notations. Some use latitude and longitude degrees, some prefer degrees and minutes with fractional part. this does not take into account choices for datum and file formats.</p>
<p>For instance, both <a href="http://maps.google.com">Google Maps</a> and <a href="http://maps.yandex.ru">Yandex Maps</a> accept latitude and longitude as <strong>ll=</strong> URL parameter with the value of latitude and longitude in degrees, however Google uses latitude coming first, while Yandex prefers the opposite.</p>
<p>Recently, a rally road book contained the following formatting of track points:</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/10/Image001.png"><img class="alignnone size-large wp-image-1298" title="Rally Raid Service Book" src="http://alax.info/blog/wp-content/uploads/2011/10/Image001-800x418.png" alt="" width="620" height="323" /></a></p>
<p>Having to put a stop to the madness, this utility comes up as a handy assistant to convert and format GPS coordinates into reasonable presentation and separators.</p>
<p>The utility runs on background and monitors clipboard, and once it recognizes one of the following:</p>
<ul>
<li>GPS Point in Degrees</li>
<li>GPS Point in Degrees and Minutes</li>
<li>GPS Point in Degrees, Minutes and Seconds</li>
<li>Google Maps URL</li>
<li>Yandex Maps URL</li>
</ul>
<p>it flashes and updates its UI providing the choices of track point formatting:</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/10/Image0021.png"><img class="alignnone size-full wp-image-1299" title="GPS Point Formatting and Options" src="http://alax.info/blog/wp-content/uploads/2011/10/Image0021.png" alt="" width="778" height="248" /></a></p>
<p>The utility is trying hard to accept various separators and formats, just one thing is important to keep in mind: if you are using minutes without seconds, the fractional part of minutes should be separated by decimal point (.).</p>
<p>The utility also responds to hotkeys <em>Ctrl+Shift+F1</em>, <em>Ctrl+Shift+F2</em> etc. and copies the formatted point location back into clipboard so that one could quickly re-format editable text in another application through clipboard updates. Alternatively, it is possible to click the formatted value and place it into clipboard.</p>
<p>The utility also provides clickable hyperlinks to open Google Maps and Yandex Maps into the point of interest.</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>
<p>Note: you might need to run the tool &#8220;As Administrator&#8221; elevating UAC privileges in Vista/7 operating systems.</p>
<p>Bonus links on the topic:</p>
<ul>
<li><a href="http://boulter.com/gps/">GPS Coordinate Converter, Maps and Info</a></li>
<li><a href="http://www.benichou-software.com/index.php?option=com_content&amp;view=article&amp;id=4&amp;Itemid=2&amp;lang=en">ITN Converter</a> &#8211; converts for route file formats</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1297/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Utility Clearance: Enumerate Audio &#8216;MMDevice&#8217;s</title>
		<link>http://alax.info/blog/1279</link>
		<comments>http://alax.info/blog/1279#comments</comments>
		<pubDate>Tue, 30 Aug 2011 17:14:24 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[Audio]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[WTL]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Core Audio]]></category>
		<category><![CDATA[device]]></category>
		<category><![CDATA[IMMDevice]]></category>
		<category><![CDATA[MMDevice]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[WASAPI]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1279</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1279" title="Utility Clearance: Enumerate Audio &#039;MMDevice&#039;s"></a>The utility and code does straightforward enumeration of MMDevices (Vista+, check MSDN for MMDevice API availability), which correspond to MMDevice API, WASAPI, Core Audio API. The code itself is straightforward, with a ready to use binary to quickly lookup data &#8230;<p class="read-more"><a href="http://alax.info/blog/1279">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1279" title="Utility Clearance: Enumerate Audio &#039;MMDevice&#039;s"></a><p>The utility and code does straightforward enumeration of MMDevices (Vista+, check MSDN for <a href="http://msdn.microsoft.com/en-us/library/dd371399%28v=vs.85%29.aspx">MMDevice API availability</a>), which correspond to MMDevice API, WASAPI, Core Audio API. The code itself is straightforward, with a ready to use binary to quickly lookup data of interest:</p>
<p><img class="alignnone size-full wp-image-1280" title="Enumerate Audio Devices in Action" src="http://alax.info/blog/wp-content/uploads/2011/08/Image0012.png" alt="" width="541" height="363" /></p>
<p>The data is detailed well and in Excel-friendly format (via Copy/Paste):</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/08/Image002.png"><img class="alignnone size-large wp-image-1281" title="Enumerate Audio Device Output in Microsoft Excel" src="http://alax.info/blog/wp-content/uploads/2011/08/Image002-800x362.png" alt="" width="620" height="280" /></a></p>
<p>The code also automatically looks up for named Windows SDK constants, such as <a href="http://msdn.microsoft.com/en-us/library/dd316594%28v=vs.85%29.aspx">PKEY_Device_FriendlyName</a>:</p>
<pre>    Identifier    {0.0.1.00000000}.{4c1a7642-3f91-43e5-8fcf-b4b1e803d3f9}
    State    DEVICE_STATE_DISABLED    0x02
    Properties:
        {B3F8FA53-0004-438E-9003-51A46E139BFC}, 15    16 bytes of BLOB, DA 07 03 00 02 00 09 00 0E 00 39 00 16 00 C5 02    65
        PKEY_Device_DeviceDesc    Stereo Mix    31
        {B3F8FA53-0004-438E-9003-51A46E139BFC}, 6    Realtek High Definition Audio    31
        {B3F8FA53-0004-438E-9003-51A46E139BFC}, 2    {1}.HDAUDIO\FUNC_01&amp;VEN_10EC&amp;DEV_0888&amp;SUBSYS_80860034&amp;REV_1002\4&amp;37D44F2F&amp;0&amp;0201    31
        {83DA6326-97A6-4088-9453-A1923F573B29}, 3    oem29.inf:AzaliaManufacturerID.NTamd64.6.0:IntcAzAudModel:6.0.1.5964:hdaudio\func_01&amp;ven_10ec&amp;dev_0888    31
        PKEY_Device_BaseContainerId    {00000000-0000-0000-FFFF-FFFFFFFFFFFF}    72
        PKEY_Device_ContainerId    {00000000-0000-0000-FFFF-FFFFFFFFFFFF}    72
        PKEY_Device_EnumeratorName    HDAUDIO    31
        PKEY_AudioEndpoint_FormFactor    10    19
        PKEY_AudioEndpoint_JackSubType    {DFF21FE1-F70F-11D0-B917-00A0C9223196}    31
        PKEY_DeviceClass_IconPath    %windir%\system32\mmres.dll,-3018    31
        {840B8171-B0AD-410F-8581-CCCC0382CFEF}, 0    316 bytes of BLOB, 01 00 00 00 38 01 00 00 ... 00 00 00 00    65
        PKEY_AudioEndpoint_Association    {00000000-0000-0000-0000-000000000000}    31
        PKEY_AudioEndpoint_Supports_EventDriven_Mode    1    19
        {24DBB0FC-9311-4B3D-9CF0-18FF155639D4}, 3    0    11
        {24DBB0FC-9311-4B3D-9CF0-18FF155639D4}, 4    -1    11
        {9A82A7DB-3EBB-41B4-83BA-18B7311718FC}, 1    65536    19
        {233164C8-1B2C-4C7D-BC68-B671687A2567}, 1    {2}.\\?\hdaudio#func_01&amp;ven_10ec&amp;dev_0888&amp;subsys_80860034&amp;rev_1002#4&amp;37d44f2f&amp;0&amp;0201#{6994ad04-93ef-11d0-a3cc-00a0c9223196}\rtstereomixwave    31
        {5A9125B7-F367-4924-ACE2-0803A4A3A471}, 0    1610612916    19
        {B3F8FA53-0004-438E-9003-51A46E139BFC}, 0    3    19
<span style="color: #3366ff;"><strong>        PKEY_Device_FriendlyName    Stereo Mix (Realtek High Definition Audio)    31</strong></span>
        PKEY_DeviceInterface_FriendlyName    Realtek High Definition Audio    31
        PKEY_AudioEndpoint_GUID    {4C1A7642-3F91-43E5-8FCF-B4B1E803D3F9}    31</pre>
<p>A binary [<a href="http://www.alax.info/svn/public/trunk/Utilities/EnumerateAudioDevices/_Bin/Win32/Release/EnumerateAudioDevices.exe">Win32</a>, <a href="http://www.alax.info/svn/public/trunk/Utilities/EnumerateAudioDevices/_Bin/x64/Release/EnumerateAudioDevices.exe">x64</a>] and partial Visual C++ .NET 2010 <a href="http://www.alax.info/trac/public/browser/trunk/Utilities/EnumerateAudioDevices">source code</a> are available from SVN.</p>
<p>See also:</p>
<ul>
<li><a href="http://blogs.msdn.com/b/matthew_van_eerde/archive/2011/06/13/how-to-enumerate-audio-endpoint-immdevice-properties-on-your-system.aspx">A similar tool with source code</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/dd371400%28v=VS.85%29.aspx">IMMDeviceEnumerator::EnumAudioEndpoints</a> on MSDN</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1279/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Utility Clearance: Artificial CPU Load</title>
		<link>http://alax.info/blog/1271</link>
		<comments>http://alax.info/blog/1271#comments</comments>
		<pubDate>Thu, 25 Aug 2011 20:20:44 +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[C++]]></category>
		<category><![CDATA[cpu]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[environment]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1271</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1271" title="Utility Clearance: Artificial CPU Load"></a>The LoadCpu tool creates one or more threads to waste CPU cycles and emulate slower environment, such as for testing and troubleshooting. There has been a great deal of similar tools out there, and this one in particular is convenient/special &#8230;<p class="read-more"><a href="http://alax.info/blog/1271">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1271" title="Utility Clearance: Artificial CPU Load"></a><p>The <em>LoadCpu</em> tool creates one or more threads to waste CPU cycles and emulate slower environment, such as for testing and troubleshooting. There has been a great deal of similar tools out there, and this one in particular is convenient/special as it takes process affinity mask as a parameter.</p>
<p>That is, /a:NN defines affinity mask, e.g. 5 for 1st and 3rd CPU (two threads), and /r:MM defines [roughly] CPU load time in percent.</p>
<pre>Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\&gt;loadcpu /a:5 /r:25
System Affinity Mask: 0xff
Process Affinity Mask: 0x05
Rate: 25%</pre>
<p><img class="alignnone size-full wp-image-1272" title="Utility's CPU Load" src="http://alax.info/blog/wp-content/uploads/2011/08/Image001.png" alt="" width="566" height="391" /></p>
<p>A binary [<a href="http://alax.info/trac/public/browser/trunk/Utilities/LoadCpu/Win32/Release/LoadCpu.exe?format=raw">Win32</a>] and partial Visual C++ .NET 2010 <a href="http://alax.info/trac/public/browser/trunk/Utilities/LoadCpu">source code</a> are available from SVN.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1271/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Utility Clearance: Automatic Snapshots</title>
		<link>http://alax.info/blog/1200</link>
		<comments>http://alax.info/blog/1200#comments</comments>
		<pubDate>Fri, 13 May 2011 16:17:43 +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[automation]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[png]]></category>
		<category><![CDATA[snapshot]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1200</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1200" title="Utility Clearance: Automatic Snapshots"></a>Automatic Snapshots runs as a background application monitors clipboard. Should a new image be copied there, the utility automatically writes the image into a file. The process does not require any user interaction and is completely automatic so that &#8211; &#8230;<p class="read-more"><a href="http://alax.info/blog/1200">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1200" title="Utility Clearance: Automatic Snapshots"></a><p>Automatic Snapshots runs as a background application monitors clipboard. Should a new image be copied there, the utility automatically writes the image into a file. The process does not require any user interaction and is completely automatic so that &#8211; per <a href="http://en.wikipedia.org/wiki/Michael_Westen">Mike Westen</a>&#8216;s request &#8211; user could quickly and easily create snapshots of a multitude of windows (Alt+Print Screen) or full screen images (Print Screen) using standard hotkeys.</p>
<p><img class="alignnone size-full wp-image-1201" title="Automatic Snapshots" src="http://alax.info/blog/wp-content/uploads/2011/05/2011-05-12-23-31-36-0001-Automatic-Snapshots.png" alt="" width="522" height="397" /></p>
<p>Features:</p>
<ul>
<li>Automatic PNG compression (can be disabled via registry and enable BMP mode)</li>
<li>Reduction of color depth to create smaller PNG files</li>
<li>Asynchronous processing, the compression and file writes are on background thread to not slow foreground application</li>
<li>Application window flashes on application bar while busy and indicates the status via window caption</li>
<li>Application appends current foreground window caption to the image file name</li>
</ul>
<p>A binary [<a href="http://trac2.assembla.com/roatl-utilities/browser/trunk/AutomaticSnapshots/_Bin/Win32/Release/AutomaticSnapshots.exe?format=raw">Win32</a>, <a href="http://trac2.assembla.com/roatl-utilities/browser/trunk/AutomaticSnapshots/_Bin/x64/Release/AutomaticSnapshots.exe?format=raw">x64</a>] and Visual C++ .NET 2010 source code <a href="http://trac2.assembla.com/roatl-utilities/browser/trunk/AutomaticSnapshots/">are  available from SVN</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1200/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>How to use windowless Video Mixing Renderer Filter to show video fullscreen</title>
		<link>http://alax.info/blog/1082</link>
		<comments>http://alax.info/blog/1082#comments</comments>
		<pubDate>Fri, 09 Oct 2009 17:04:27 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[WTL]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[fullscreen]]></category>
		<category><![CDATA[IVideoWidow]]></category>
		<category><![CDATA[IVMRWindowlessControl]]></category>
		<category><![CDATA[renderer]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[VMR]]></category>
		<category><![CDATA[windowless]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1082</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1082" title="How to use windowless Video Mixing Renderer Filter to show video fullscreen"></a>The question is being asked from time to time. Everyone knows what is full screen video. Video renderers implement full screen capability since long ago through their IVideoWindow::put_FullScreenMode property, and even Filter Graph Manager exposes its own IVideoWindow interface to &#8230;<p class="read-more"><a href="http://alax.info/blog/1082">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1082" title="How to use windowless Video Mixing Renderer Filter to show video fullscreen"></a><p>The question is being asked from time to time. Everyone knows what is full screen video. Video renderers implement full screen capability since long ago through their <a href="http://msdn.microsoft.com/en-us/library/dd377320(VS.85).aspx">IVideoWindow::put_FullScreenMode</a> property, and even <a href="http://msdn.microsoft.com/en-us/library/dd375786(VS.85).aspx">Filter Graph Manager</a> exposes its own <a href="http://msdn.microsoft.com/en-us/library/dd377276%28VS.85%29.aspx">IVideoWindow</a> interface to forward calls to filter&#8217;s implementation of <a href="http://msdn.microsoft.com/en-us/library/dd377276%28VS.85%29.aspx">IVideoWindow</a> interface.</p>
<p>However, for Video Mixing Renderers, version <a href="http://msdn.microsoft.com/en-us/library/dd407343(VS.85).aspx">7</a> and <a href="http://msdn.microsoft.com/en-us/library/dd407344%28VS.85%29.aspx">9</a>, the preferred and recommended mode is windowless, where no IVideoWindow interface is available.</p>
<blockquote><p><strong>Note</strong> The <a id="ctl00_MTCS_main_ctl01" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl01',this);" href="http://msdn.microsoft.com/en-us/library/dd390536%28VS.85%29.aspx"><strong>IVMRWindowlessControl</strong></a> or <a id="ctl00_MTCS_main_ctl02" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl02',this);" href="http://msdn.microsoft.com/en-us/library/dd390537%28VS.85%29.aspx"><strong>IVMRWindowlessControl9</strong></a> interface is now preferred over <strong>IVideoWindow</strong>. For more information, see <a id="ctl00_MTCS_main_ctl03" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl03',this);" href="http://msdn.microsoft.com/en-us/library/dd407299%28VS.85%29.aspx">Using Windowless Mode</a>.</p></blockquote>
<p>So in order to implement full screen mode it takes the application to attach Video Mixing Renderer filter to a private frameless window, to its entire client area and expand the window to entire monitor area.</p>
<p>The sample project <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FullScreenWindowlessVmrSample01">FullScreenWindowlessVmrSample01</a> is illustrating this technique.</p>
<p><img class="alignnone size-full wp-image-1083" title="FullScreenWindowlessVmrSample01 Main Dialog" src="http://alax.info/blog/wp-content/uploads/2009/10/09-Image001.png" alt="FullScreenWindowlessVmrSample01 Main Dialog" width="489" height="141" /></p>
<p><span id="more-1082"></span>Main application dialog owns a special window to host renderer, implemented by CRendererDialog class.</p>
<pre>
<pre style="background: #ffffff none repeat scroll 0% 0%; color: #000000;"><span style="color: #800000; font-weight: bold;">class</span> CRendererDialog <span style="color: #800080;">:</span>
    <span style="color: #800000; font-weight: bold;">public</span> CDialogImpl<span style="color: #800080;">&lt;</span>CRendererDialog<span style="color: #800080;">&gt;</span>
<span style="color: #800080;">{</span>
<span style="color: #800000; font-weight: bold;">public</span><span style="color: #e34adc;">:</span>

    <span style="color: #800000; font-weight: bold;">enum</span> <span style="color: #800080;">{</span> IDD <span style="color: #808030;">=</span> IDD_RENDERER <span style="color: #800080;">}</span><span style="color: #800080;">;</span>

BEGIN_MSG_MAP_EX<span style="color: #808030;">(</span>CRendererDialog<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_ERASEBKGND<span style="color: #808030;">(</span><span style="color: #400000;">OnEraseBkgnd</span><span style="color: #808030;">)</span>
    MSG_WM_PAINT<span style="color: #808030;">(</span>OnPaint<span style="color: #808030;">)</span>
    MSG_WM_DISPLAYCHANGE<span style="color: #808030;">(</span>OnDisplayChange<span style="color: #808030;">)</span>
    MSG_WM_KEYDOWN<span style="color: #808030;">(</span>OnKeyDown<span style="color: #808030;">)</span>
    COMMAND_ID_HANDLER_EX<span style="color: #808030;">(</span>IDCANCEL<span style="color: #808030;">,</span> OnCancel<span style="color: #808030;">)</span>
END_MSG_MAP<span style="color: #808030;">(</span><span style="color: #808030;">)</span>

<span style="color: #800000; font-weight: bold;">private</span><span style="color: #e34adc;">:</span>
    CMainDialog<span style="color: #808030;">&amp;</span> m_Owner<span style="color: #800080;">;</span>
<span style="color: #696969;">//...</span></pre>
</pre>
<p>The dialog template does not have a caption, it has no frame and has its window rectangle equal to client area. As a result, spanning the Video Mixing Renderer to the entire client area and proper positioning of the dialog window is showing video on the entire monitor.</p>
<pre>
<pre style="background: #ffffff none repeat scroll 0% 0%; color: #000000;">ATLVERIFY<span style="color: #808030;">(</span>m_RendererDialog<span style="color: #808030;">.</span>Create<span style="color: #808030;">(</span>m_hWnd<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
ATLVERIFY<span style="color: #808030;">(</span>m_RendererDialog<span style="color: #808030;">.</span><span style="color: #400000;">MoveWindow</span><span style="color: #808030;">(</span>MonitorData<span style="color: #808030;">.</span>m_Position<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
m_RendererDialog<span style="color: #808030;">.</span><span style="color: #400000;">ShowWindow</span><span style="color: #808030;">(</span>SW_SHOWNORMAL<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
<span style="color: #696969;">// ...</span>
ATLENSURE_SUCCEEDED<span style="color: #808030;">(</span>pVmrWindowlessControl<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span>SetVideoClippingWindow<span style="color: #808030;">(</span>m_RendererDialog<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
ATLENSURE_SUCCEEDED<span style="color: #808030;">(</span>pVmrWindowlessControl<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span>SetVideoPosition<span style="color: #808030;">(</span><span style="color: #7d0045;">NULL</span><span style="color: #808030;">,</span> m_RendererDialog<span style="color: #808030;">.</span>GetVideoPosition<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></pre>
</pre>
<p>Visual C++ .NET 2008 source code is <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FullScreenWindowlessVmrSample01">available from SVN</a>, release binary <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FullScreenWindowlessVmrSample01/Release/FullScreenWindowlessVmrSample01.exe?format=raw">included</a>. The project is using ATL and <a href="http://wtl.sourceforge.net/">WTL</a> libraries.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1082/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

