<?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>Reflections of my thoughts... &#187; Windows 7</title>
	<atom:link href="http://codereflect.com/category/windows-7/feed/" rel="self" type="application/rss+xml" />
	<link>http://codereflect.com</link>
	<description>on programming tips and trending topics...</description>
	<lastBuildDate>Wed, 07 Dec 2011 18:18:37 +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>How to set Windows 7 Navigation Pane like Windows XP Explore View?</title>
		<link>http://codereflect.com/2011/08/18/how-to-restore-windows-7-navigation-pane-like-windows-xp-explore-view/</link>
		<comments>http://codereflect.com/2011/08/18/how-to-restore-windows-7-navigation-pane-like-windows-xp-explore-view/#comments</comments>
		<pubDate>Thu, 18 Aug 2011 10:30:00 +0000</pubDate>
		<dc:creator>@sarat</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Explorer]]></category>

		<guid isPermaLink="false">http://codereflect.com/?p=1681</guid>
		<description><![CDATA[While we&#8217;re navigating back and forth between files, the old Windows XP Explorer view is quite helpful. In Windows 7, Navigation pane appear by default but it won&#8217;t expand to the current folder by default. Rather they made address bar intractable by click-able folder names to enable better navigation. But it&#8217;s not really handy when [...]]]></description>
			<content:encoded><![CDATA[<p>While we&#8217;re navigating back and forth between files, the old Windows XP Explorer view is quite helpful. In Windows 7, Navigation pane appear by default but it won&#8217;t expand to the current folder by default. Rather they made address bar intractable by click-able folder names to enable better navigation. But it&#8217;s not really handy when I wanted to navigate back and forth quite frequently.</p>
<p><div id="attachment_1683" class="wp-caption alignnone" style="width: 247px"><a href="http://codereflect.com/assets/NavigationPane.jpg"><img class="size-full wp-image-1683" title="NavigationPane [Taken From Microsoft.com]" src="http://codereflect.com/assets/NavigationPane.jpg" alt="" width="237" height="451" /></a><p class="wp-caption-text">Image Taken From Microsoft.com</p></div>You can easily restore it from Explorer options. Go Tools-&gt;Options. Under the Folder Options dialog box, click the General tab, and then do one or both of the following:</p>
<ul>
<li>To show all the folders on your computer in the navigation pane, including your personal folder, select the Show all folders check box, and then click OK.</li>
<li>To automatically expand the navigation pane to the folder that&#8217;s selected in the folder window, select the Automatically expand to current folder check box, and then click OK.</li>
</ul>
<p><a href="http://codereflect.com/assets/FolderOptions.png"><img class="alignnone size-full wp-image-1682" title="Folder Options" src="http://codereflect.com/assets/FolderOptions.png" alt="" width="396" height="481" /></a></p>
<p>Mind that this may reduce your system performance if you&#8217;re working with network drives or clear-case views.</p>
]]></content:encoded>
			<wfw:commentRss>http://codereflect.com/2011/08/18/how-to-restore-windows-7-navigation-pane-like-windows-xp-explore-view/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What you can do if Windows Startup repair fail to repair your bootsector?</title>
		<link>http://codereflect.com/2011/05/22/what-you-can-do-if-windows-startup-repair-fail-to-repair-your-bootsector/</link>
		<comments>http://codereflect.com/2011/05/22/what-you-can-do-if-windows-startup-repair-fail-to-repair-your-bootsector/#comments</comments>
		<pubDate>Sun, 22 May 2011 12:40:27 +0000</pubDate>
		<dc:creator>@sarat</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Boot]]></category>
		<category><![CDATA[grub]]></category>
		<category><![CDATA[Startup repair]]></category>
		<category><![CDATA[troubleshooting]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Windows Vista]]></category>

		<guid isPermaLink="false">http://codereflect.com/?p=1431</guid>
		<description><![CDATA[It was painful time with Ubuntu and Windows Dual Boot Information. With my foolish thoughts I removed the native Linux Partition where I had installed Ubuntu Linux 10.04. Also I removed the boot sector. Then I decided to install 11.04 under Windows Partition itself. Just installed Ubuntu and rebooted to finish the installation. Yea it [...]]]></description>
			<content:encoded><![CDATA[<p>It was painful time with Ubuntu and Windows Dual Boot Information. With my foolish thoughts I removed the native Linux Partition where I had installed Ubuntu Linux 10.04. Also I removed the boot sector. Then I decided to install 11.04 under Windows Partition itself. Just installed Ubuntu and rebooted to finish the installation. Yea it was gone. It displayed a grub rescue command prompt and I was in blues.</p>
<p>Somehow I managed to get the Windows 7 boot USB to repair my startup for Windows. Again it had happened. The Master Boot Record wasn&#8217;t promptly recognized by Windows. It says no problems at all with your Windows Installation. What&#8217;s next. I have tried several options to like Fixing the MBR with command line and exporting and importing the boot record and importing it again to corrupt the MBR and tried the repair again. No ways! </p>
<p>Finally how I had to recreate the MBR. How do we do that? (BTW, do this at your own risk. Don&#8217;t blame me later)</p>
<p>1. Insert your bootable DVD/USB or Startup repair disc to your computer.<br />
2. Choose Recovery options.<br />
3. Click on Startup Repair and check if it works.</p>
<p>If doesn&#8217;t work</p>
<p>4. Open the command window and enter the following commands </p>
<pre>
bootrec.exe /fixmbr
bootsect.exe /nt60 all /force
bootrec.exe /rebuildbcd
</pre>
<p>Now you&#8217;re done. Reboot your PC and see if it works. Under Windows Vista, you will have to change to X:\boot\ folder to access bootrec and bootsect executable. </p>
]]></content:encoded>
			<wfw:commentRss>http://codereflect.com/2011/05/22/what-you-can-do-if-windows-startup-repair-fail-to-repair-your-bootsector/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Ribbon Editor to design the Ribbon for your application</title>
		<link>http://codereflect.com/2011/02/08/using-ribbon-editor-to-design-the-ribbon-for-your-application/</link>
		<comments>http://codereflect.com/2011/02/08/using-ribbon-editor-to-design-the-ribbon-for-your-application/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 12:36:48 +0000</pubDate>
		<dc:creator>@sarat</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[Visual C++]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[2010]]></category>
		<category><![CDATA[designer]]></category>
		<category><![CDATA[MFC]]></category>
		<category><![CDATA[ribbon]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://codereflect.com/?p=1410</guid>
		<description><![CDATA[Visual Studio 2010 has integrated the new Ribbon Designer for MFC Applications. Previously I blogged about integrating ribbon with the MFC application and adding even handlers to get the notifications. But the developer must visualize the ribbon while scripting the ribbon code. But using the new Ribbon Designer, we can design ribbons designer, just like [...]]]></description>
			<content:encoded><![CDATA[<p>Visual Studio 2010 has integrated the new Ribbon Designer for MFC Applications. Previously I blogged about integrating ribbon with the MFC application and adding even handlers to get the notifications. But the developer must visualize the ribbon while scripting the ribbon code. But using the new Ribbon Designer, we can design ribbons designer, just like the menu designer.</p>
<p><img alt="" src="http://i.msdn.microsoft.com/dynimg/IC338676.png" class="alignnone" width="332" height="310" /><br />
Please check the following links to explore more.<br />
<a href="http://codereflect.com/2009/06/30/windows-7-ribbon-how-to-integrate-a-simple-ribbon-to-your-mfc-application-part-1/">How to integrate a simple ribbon with your MFC Application?</a><br />
<a href="http://codereflect.com/2009/07/02/windows-7-ribbon-part-2-how-handle-ribbon-control-events/">How to handle Ribbon Control Events?</a><br />
<a href="http://msdn.microsoft.com/en-us/library/ee354408.aspx">Ribbon designer (MSDN)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://codereflect.com/2011/02/08/using-ribbon-editor-to-design-the-ribbon-for-your-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get known folder path (Windows Vista/7)?</title>
		<link>http://codereflect.com/2011/01/21/how-to-get-known-folder-path-windows-vista7/</link>
		<comments>http://codereflect.com/2011/01/21/how-to-get-known-folder-path-windows-vista7/#comments</comments>
		<pubDate>Fri, 21 Jan 2011 11:38:41 +0000</pubDate>
		<dc:creator>@sarat</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows Vsita]]></category>
		<category><![CDATA[Windows XP]]></category>

		<guid isPermaLink="false">http://codereflect.com/?p=1397</guid>
		<description><![CDATA[Windows Vista and above supports independent software vendors (ISV) to add support for custom known folder locations. Previously a fixed set of IDs were provided to use with SHGetFolderPath, SHGetFolderLocation and SHSetFolderPath APIs. For adding this flexibility, the known file APIs has been rename and designed with COM Interfaces. New Shell APIs and COM Interfaces [...]]]></description>
			<content:encoded><![CDATA[<div>Windows Vista and above supports independent software vendors (ISV) to add support for custom known folder locations. Previously a fixed set of IDs were provided to use with SHGetFolderPath, SHGetFolderLocation and SHSetFolderPath APIs.<br />
For adding this flexibility, the known file APIs has been rename and designed with COM Interfaces.<br />
New Shell APIs and COM Interfaces are introduced to replace the old Shell APIs</p>
<table>
<colgroup></colgroup>
<tbody>
<tr>
<td>New Function</td>
<td>Replaces</td>
<td>COM Equivalent</td>
</tr>
<tr>
<td><a href="http://msdn.microsoft.com/en-us/library/bb762188(v=vs.85).aspx">SHGetKnownFolderPath</a></td>
<td><a href="http://msdn.microsoft.com/en-us/library/bb762181(v=vs.85).aspx">SHGetFolderPath</a></td>
<td><a href="http://msdn.microsoft.com/en-us/library/bb761762(v=vs.85).aspx">IKnownFolder::GetPath</a></td>
</tr>
<tr>
<td><a href="http://msdn.microsoft.com/en-us/library/bb762187(v=vs.85).aspx">SHGetKnownFolderIDList</a></td>
<td><a href="http://msdn.microsoft.com/en-us/library/bb762180(v=vs.85).aspx">SHGetFolderLocation</a></td>
<td><a href="http://msdn.microsoft.com/en-us/library/bb761760(v=vs.85).aspx">IKnownFolder::GetIDList</a></td>
</tr>
<tr>
<td><a href="http://msdn.microsoft.com/en-us/library/bb762249(v=vs.85).aspx">SHSetKnownFolderPath</a></td>
<td><a href="http://msdn.microsoft.com/en-us/library/bb762247(v=vs.85).aspx">SHSetFolderPath</a></td>
<td><a href="http://msdn.microsoft.com/en-us/library/bb761770(v=vs.85).aspx">IKnownFolder::SetPath</a></td>
</tr>
</tbody>
</table>
<p>Old APIs were using <a href="http://msdn.microsoft.com/en-us/library/bb762494(v=vs.85).aspx">CSIDL </a>for representing the known location identifier. This has been replaced by <a href="http://msdn.microsoft.com/en-us/library/dd378457(v=vs.85).aspx">KNOWFOLDERID</a>. However Windows Vista and 7 still supports CSIDL and associated APIs for compatibility reasons. The new applications has to use the new APIs or COM Interface. When using both COM/New Shell API, you’ve to ensure that CoTaskMemFree function is called to release the output resources. Otherwise memory leak may occur. Also don’t call any other memory release function like free or delete operator. It may cause undefined behavior</p>
<h2>How to Enumerate All Known Folders?</h2>
<pre>
void EnumerateAllKnownFolders(CStringArray&amp; strArray)
{
	CStringArray strPathRet;
	IKnownFolderManager* pkfm = NULL;
	HRESULT hr = CoCreateInstance(CLSID_KnownFolderManager, NULL,
		CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&amp;pkfm));

	if( SUCCEEDED(hr))
	{
		KNOWNFOLDERID* rfid;
		UINT uCount = 0;

		if( FAILED( pkfm-&gt;GetFolderIds( &amp;rfid, &amp;uCount )))
			return;

		for (UINT uIdx = 0; uIdx &lt; uCount; ++uIdx )
		{
			IKnownFolder* pFolder;
			pkfm-&gt;GetFolder( rfid[uIdx], &amp;pFolder );
			LPWSTR szPath;
			pFolder-&gt;GetPath(0, &amp;szPath );
			strArray.Add( szPath );
			CoTaskMemFree( szPath );
			pFolder-&gt;Release();
		}

		CoTaskMemFree( rfid );
		pkfm-&gt;Release();
	}
}
</pre>
<h2>How to get the path of a specific known folder using new COM Interface?</h2>
<pre>
CString GetKnownFolderIDCOM( KNOWNFOLDERID rfid )
{
	CString strPathRet;
	LPWSTR szPath;
	IKnownFolderManager* pkfm = NULL;
	HRESULT hr = CoCreateInstance(CLSID_KnownFolderManager, NULL,
		CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&amp;pkfm));

	if( SUCCEEDED(hr))
	{
		IKnownFolder* pFolder;
		pkfm-&gt;GetFolder( rfid, &amp;pFolder );

		pFolder-&gt;GetPath(0, &amp;szPath );
		strPathRet = szPath;
		CoTaskMemFree( szPath );
		pFolder-&gt;Release();
	}
	pkfm-&gt;Release();
	return strPathRet;
}
</pre>
<h2>How to get path of a specific known folder Shell API?</h2>
<pre>
CString GetKnownPathShell( KNOWNFOLDERID rfid )
{
	CString strPath;
	LPWSTR szPath;
	SHGetKnownFolderPath( rfid, 0, 0, &amp;szPath );
	strPath = szPath;
	CoTaskMemFree( szPath );
	return strPath;
}
</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://codereflect.com/2011/01/21/how-to-get-known-folder-path-windows-vista7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Registry Virtualization</title>
		<link>http://codereflect.com/2011/01/10/windows-registry-virtualization/</link>
		<comments>http://codereflect.com/2011/01/10/windows-registry-virtualization/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 16:18:30 +0000</pubDate>
		<dc:creator>@sarat</dc:creator>
				<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Win32]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows Vista]]></category>

		<guid isPermaLink="false">http://codereflect.com/2011/01/10/windows-registry-virtualization/</guid>
		<description><![CDATA[Registry virtualization is implemented in Windows Vista and 7 for providing application support for legacy applications. The legacy application (till Windows XP) runs in administrator privilege by default which enables the crappy applications to access the sensitive system area without user knowledge. UAC is the solution introduced to defend this kind of attacks. By default [...]]]></description>
			<content:encoded><![CDATA[<p>Registry virtualization is implemented in Windows Vista and 7 for providing application support for legacy applications. The legacy application (till Windows XP) runs in administrator privilege by default which enables the crappy applications to access the sensitive system area without user knowledge. UAC is the solution introduced to defend this kind of attacks. By default the applications will be launched in user privileged mode and the application can request user if it requires to have elevated privilege.</p>
<p>Registry Virtualization emulates the HKEY_LOCAL_MACHINE\Software write operations under HKEY_USER\&lt;User SID&gt;_Classes\VirtualStore\Machine\Software path.</p>
<p>Open Registry Virtualization – If the application doesn’t have enough privilege to open a specific key, the virtualized key will be opened with maximum privilege.</p>
<p>Write Registry Virtualization – If the application doesn’t have enough privilege to write to the specified location, the write operation will be performed under virtual store path.</p>
<p>Read Registry Virtualization – System provides a merged copy of information from Virtual store and the original global store together.</p>
<p>Virtualization is provided for </p>
<ul>
<li>32 bit interactive process</li>
<li>Keys in HKEY_LOCAL_MACHINE\Software</li>
<li>Keys that an administrator write to (if the application doesn’t have privilege)</li>
</ul>
<p>Virtualization is disabled for </p>
<ul>
<li>64 bit processes</li>
<li>Processes which doesn’t have GUI (e.g Services)</li>
<li>Process that impersonate a user</li>
<li>Kernel mode processes such as drivers</li>
<li>Process that has specified requestedExecutionLevel in their manifest</li>
<li>Keys and subkeys of HKEY_LOCAL_MACHINE\Software\Classes, HKEY_LOCAL_MACHINE\Software\Microsoft\Windows, and HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT.</li>
</ul>
<p>The applications which required to run under Windows Vista and 7 must follow the UAC guidelines and should not use registry to store the applications information. Microsoft may stop supporting this feature in the upcoming versions of Windows. So keep your applications compatible with the latest platform.</p>
<p>See more</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/aa965884(v=vs.85).aspx" target="_blank">Registry Virtualization</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/aa480150.aspx" target="_blank">UAC Developer Guide</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://codereflect.com/2011/01/10/windows-registry-virtualization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to query twitter public status using LINQ to XML (C#)?</title>
		<link>http://codereflect.com/2010/10/12/how-to-query-twitter-public-status-using-linq-to-xml-using-c/</link>
		<comments>http://codereflect.com/2010/10/12/how-to-query-twitter-public-status-using-linq-to-xml-using-c/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 15:53:19 +0000</pubDate>
		<dc:creator>@sarat</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C Sharp]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Codeproject]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Windows Phone 7]]></category>
		<category><![CDATA[wpf]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Wp7]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://codereflect.com/2010/10/12/how-to-query-twitter-public-status-using-linq-to-xml-using-c/</guid>
		<description><![CDATA[Here’s a handy way to query twitter public timelines and status easily using C#. This code can be used in your Silverlight, WPF applications. Twitter user timeline can be accessed from http://api.twitter.com/version/statuses/user_timeline.format The format suffix supports following formats – XML, JSON, RSS and ATOM. Optional parameters can also be specified in the URL like screen_name, [...]]]></description>
			<content:encoded><![CDATA[<p> Here’s a handy way to query twitter public timelines and status easily using C#. This code can be used in your Silverlight, WPF applications.</p>
<p>Twitter user timeline can be accessed from </p>
<p><tt><a href="http://api.twitter.com/version/statuses/user_timeline.format">http://api.twitter.com/<em>version</em>/statuses/user_timeline.<em>format</em></a></tt></p>
<p>The format suffix supports following formats – XML, JSON, RSS and ATOM. </p>
<p>Optional parameters can also be specified in the URL like screen_name, user_id, count (must be less than 200) etc.</p>
<p>For e.g to access my twitter timeline, the URL can be formed as below</p>
<p><tt><a href="http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=sarat">http://api.twitter.com/<em>1</em>/statuses/user_timeline.<em>xml?screen_name=sarat</em></a></tt></p>
<p><a href="http://dev.twitter.com/doc/get/statuses/user_timeline" target="_blank">You can find more information about this in the twitter API documentation.</a></p>
<p>Similarly you can access public timeline as follows. The supported formats are same. <a href="http://dev.twitter.com/doc/get/statuses/public_timeline" target="_blank">Check Twitter Documentation</a></p>
<p><tt>http://api.twitter.com/<em>version</em>/statuses/public_timeline.<em>format</em></tt></p>
<p>Now how we access the client, there are several methods to access and parse an XML stream in the .NET environment. Let’s go for LINQ to XML, which is the easiest and flexible way. </p>
<p>A basic twitter stream is having the following structure. You can easily generate this using xsd tool available in the .NET framework tools. Just give the XML path generate the schema definition file. Note that the several information associated with the tweet is hidden under the scrollbars.</p>
<p><a href="http://codereflect.com/wp-content/uploads/2010/10/image4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://codereflect.com/wp-content/uploads/2010/10/image_thumb4.png" width="473" height="412" /></a> </p>
<p>Note that we’re going to access using public data querying, there’s no twitter API is ursed. The reason why we’re going for LINQ to XML is, syndication classes are not supported in all environments even it’s safe to use and forcefully add. For e.g. in Windows Phone 7 environment, Syndication classes are not supported. We can forcefully add assembly and use it, but by default it’s filtered out.</p>
<p>WebClient is the easiest way to query a request in several forms. </p>
<p>Declare the Tweets class with required information. You can contain any information which is available in a tweet/user. Ultimately it you who ultimately decide what you want to show. Here for this example, taking only minimum set of information. User name, profile image and tweet.</p>
<pre>
public class Tweet
    {
        public string UserName { get; set; }
        public string Message { get; set; }
        public string ImageSrc { get; set; }
    }
</pre>
<p>Make the request,</p>
<pre>
WebClient twitterAccess = new WebClient();
            twitterAccess.DownloadStringCompleted +=new DownloadStringCompletedEventHandler(twitterAccess_DownloadStringCompleted);
            twitterAccess.DownloadStringAsync( new Uri( &quot;http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=&quot; + twitterUser.Text ));
</pre>
<p>Note that the request is asychronous and the thread will not be blocked until we receive the result.</p>
<p>XElement is the fundamental class helps us to process the downloaded string and query the required information. The data will be dynamically queried and made into class. This is done for each result of query within the entire string downloaded. </p>
<pre>
void twitterAccess_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs args )
        {
            try
            {
                XElement xmlTweets = XElement.Parse(args.Result);
                listboxTweets.ItemsSource = from tweet in xmlTweets.Descendants(&quot;status&quot;)
                                            select new Tweet
                                            {
                                                ImageSrc = tweet.Element(&quot;user&quot;).Element(&quot;profile_image_url&quot;).Value,
                                                Message = tweet.Element(&quot;text&quot;).Value,
                                                UserName = tweet.Element(&quot;user&quot;).Element(&quot;screen_name&quot;).Value
                                            };

            }
            catch
            {
                MessageBox.Show(&quot;Error downloading tweets&quot;);
            }

        }
</pre>
<p>The query is simple and straight forward.The query is made for the descendants of under “status” which is depicted in the above figure. the result will be put on “tweet” from which we can query the further subnodes of an XML. Note that the result of query generates an array Tweet instances which can be used as the item source for data for visuallization. You can use it in your own way. In this example, this set for the data source of an listbox.</p>
<p>ImageSrc, Message and UserName are the properties of the Tweet class and this can be used in the ItemTemplate of ListBox to Visualize them. The resultant XAML may appear as below</p>
<pre>
&lt;ListBox x:Name=&quot;listboxTweets&quot; Margin=&quot;12,74,13,17&quot; ItemsSource=&quot;{Binding ''}&quot;&gt;
        		&lt;ListBox.ItemTemplate&gt;
               		&lt;DataTemplate&gt;
               			&lt;StackPanel Orientation=&quot;Horizontal&quot; Height=&quot;150&quot; Margin=&quot;0,0,7,0&quot; Width=&quot;480&quot;&gt;
               				&lt;Image Source=&quot;{Binding ImageSrc}&quot; Height=&quot;73&quot; Width=&quot;73&quot; VerticalAlignment=&quot;Top&quot; Margin=&quot;0,10,8,0&quot;/&gt;
               				&lt;StackPanel Orientation=&quot;Vertical&quot; Width=&quot;376&quot; HorizontalAlignment=&quot;Right&quot;&gt;
								&lt;TextBlock Text=&quot;{Binding UserName}&quot; Foreground=&quot;IndianRed&quot; FontSize=&quot;28&quot; Margin=&quot;5, 0, 0, 0&quot;/&gt;
		               			&lt;TextBlock Text=&quot;{Binding Message}&quot; TextWrapping=&quot;Wrap&quot; Margin=&quot;5,0,0,0&quot;/&gt;
							&lt;/StackPanel&gt;
						&lt;/StackPanel&gt;
			   		&lt;/DataTemplate&gt;
			   &lt;/ListBox.ItemTemplate&gt;
			&lt;/ListBox&gt;
</pre>
<p>The data binding is simple. We&#8217;re defining how an item should be rendered inside the list box using the ItemTemplate speification. You can find more information on data template in MSDN. PS: When you define the class, please make sure Data Binding class is declared as public otherwise no data will be displayed in the listbox. Also make sure that you&#8217;re declaring properties (with get;set;) instead of fields (member variables) It&#8217;s simple isn&#8217;t it? <a href="http://msdn.microsoft.com/en-us/library/ms752347.aspx" target="_blank">Check MSDN to know more about data binding of Silverlight/WPF applications</a>. Here&#8217;s the Windows Phone 7 Application which displays the tweets from my time line.&#160; </p>
<p><a href="http://codereflect.com/wp-content/uploads/2010/10/image5.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://codereflect.com/wp-content/uploads/2010/10/image_thumb5.png" width="132" height="244" /></a></p>
<p>I&#8217;m not posting the entire project because it&#8217;s just in the development stage. Only intended to explain the core part of the code. Have a nice time with querying tweets.</p>
]]></content:encoded>
			<wfw:commentRss>http://codereflect.com/2010/10/12/how-to-query-twitter-public-status-using-linq-to-xml-using-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Programming Windows Phone 7 &#8211; Hello World</title>
		<link>http://codereflect.com/2010/10/09/programming-windows-phone-7-hello-world/</link>
		<comments>http://codereflect.com/2010/10/09/programming-windows-phone-7-hello-world/#comments</comments>
		<pubDate>Sat, 09 Oct 2010 10:56:06 +0000</pubDate>
		<dc:creator>@sarat</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C Sharp]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Codeproject]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Windows Phone 7]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[Wp7]]></category>
		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://codereflect.com/2010/10/09/programming-windows-phone-7-hello-world/</guid>
		<description><![CDATA[I was really excited about to see the upcoming release of Windows Phone 7. This is truly a great answer from Microsoft to the rest of world. Apple iOS which is currently the most popular mobile platform, Google Android, BlackBerry etc. were taking pace with the new technologies and Microsoft was still battling to find [...]]]></description>
			<content:encoded><![CDATA[<p>I was really excited about to see the upcoming release of Windows Phone 7. This is truly a great answer from Microsoft to the rest of world. Apple iOS which is currently the most popular mobile platform, Google Android, BlackBerry etc. were taking pace with the new technologies and Microsoft was still battling to find a space in the mobile world. Of course Windows Mobile operating system was popular some time before but the smart phones were not really popular and on aging, the platform itself being outdated in front of other new age platforms. </p>
<p>All programs for Windows Phone 7 can be written in .NET managed code. Currently C# is the only programming language supported. The tools for Windows Phone 7 can be <a href="http://developer.windowsphone.com/">freely downloaded from Windows Phone 7 website</a>. It includes</p>
<ul>
<li>Visual Studio 2010 Express Edition </li>
<li>XNA Game Studio 4.0 </li>
<li>On Screen Phone Emulator </li>
</ul>
<p>Windows Phone 7 can be programmed mainly using XNA FrameWorks and the popular Silverlight platform. XNA is used for high performance games (usually 3D games) and Silverlight is usually used for the 2D graphical applications. </p>
<p>Windows Phone 7 contains the stripped down version of Silverlight 3. Microsoft has avoided the silverlight features which are not really compatible with the Windows Phone 7 platform. The animations for the programs can be down using the <a href="http://www.microsoft.com/expression/">Microsoft Expression Blend</a> </p>
<p>Ultimately it comes to programmer’s responsibility to choose which platform should be used for programming Windows Phone 7 application. </p>
<p>Windows Phone 7 contains the Azure services to access the cloud service. One of the examples are XBox Live (runs on cloud). Programs are location aware and can access data through bing, social networking websites etc. </p>
<p>Windows Phone 7 features Multi-Touch screen with 3 navigation buttons. Back (like the back button in the browser. This will terminate the application),&#160; Start button (to navigate to home screen), Search. Currently the native resolution of a Windows Phone hardware is 400&#215;800. Also 320&#215;480 resolution screen is expected. The hardware component features </p>
</p>
<ul>
<li>Wi-Fi </li>
<li>Camera </li>
<li>Accelerometer &#8211; to detect the movement of the phone </li>
<li>GPS based Location </li>
<li>Vibration (programmable) </li>
<li>FM Radio </li>
<li>Push notifications </li>
</ul>
<p>Once after <a href="http://developer.windowsphone.com/windows-phone-7/">downloading the tools</a>, you can either start programming in the Visual Studio Express Edition or Visual Studio 2010 (if it’s already installed). </p>
<p>Here I’m demonstrating a basic Windows Phone 7 application in Silverlight. The code is only tested in Simulator not on any real hardware.</p>
<p>Create the new project using the Wizard</p>
<p><a href="http://codereflect.com/wp-content/uploads/2010/10/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://codereflect.com/wp-content/uploads/2010/10/image_thumb.png" width="640" height="419" /></a></p>
<p>The basic layouts will automatically be created using the XAML and corresponding C# source will also be created. Notice that the standard controls available in the Windows phone 7 is not similar to the controls available in Windows. They’re transparent and designed for the phone. The entire theme is based on black. You can simply start debugging/execute the code using the emulator available. It’s better not to close the emulator Windows frequently as it may take time to start it up. The program will automatically deployed and starts in the emulator.</p>
<p>The user actions like home screen, back button, search etc will end up the application by default. The application must manage itself to restore the previous state if necessary on quit.On startup Windows phone 7 emulator will ask for the basic setup. It’s very easy to set it up and this is a one time process. The emulator can be used for changing the orientation between portrait and landscape. The buttons are available on the right top corner of the emulator window on hovering the mouse.</p>
<p>The demo application loads the posts from this blog and display it, whlie tap on the post titles listed, the article will be loaded on webBrower.</p>
<p>The layout and controls are as follows</p>
<p><a href="http://codereflect.com/wp-content/uploads/2010/10/image1.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://codereflect.com/wp-content/uploads/2010/10/image_thumb1.png" width="338" height="547" /></a> </p>
<h3>Loading the feed items</h3>
<p>The silverlight application had put lot of restrictions in accessing the APIs and resources of other websites. Loading news feed (RSS/Atom) is not really painful using the C# code. Silverlight supports asynchronous read operations for web requests. SyndicationFeed class is not supported supported bu default. Basically it’s safe to add this assembly to the project (System.ServiceModel.Syndication,dll) You can browse to Windows SDK folder, locate and add the same assembly in the “Client” folder</p>
<pre>
private void buttonRefresh_Click(object sender, RoutedEventArgs e)
{
    // Load the feed items
    LoadFeedItems();
}

private void LoadFeedItems()
{
    // Asynchronously load the feed content.
    WebClient client = new WebClient();
    Uri address = new Uri(&amp;quot;http://feeds.feedburner.com/sharingmythoughts&amp;quot;);
    client.OpenReadCompleted += client_openReadComplete;
    // Add the callback on completion
    client.OpenReadAsync(address);
    webBrowser.Visibility = Visibility.Collapsed;
    buttonBack.Visibility = Visibility.Collapsed;

}
private void client_openReadComplete(object sender, OpenReadCompletedEventArgs args)
{
    try
    {
        listBoxPosts.Items.Clear();
        // try to load the result in the XML reader.
        // Exception may occur if the request is failed
        XmlReader reader = XmlReader.Create(args.Result);

        // Syndication Feed is not supported by default.
        // It's safe to add this assembly.
        SyndicationFeed feed = SyndicationFeed.Load(reader);
        Items = feed.Items.ToArray();
        foreach (SyndicationItem e in Items)
            listBoxPosts.Items.Add(e.Title.Text);
    }
    catch
    {
        MessageBox.Show(&amp;quot;Error downloading feed&amp;quot;);
    }

}
</pre>
<h3>Navigate to the base URL on tapping</h3>
<pre>
private void OnTapItem(object sender, MouseButtonEventArgs e)
{
    if (listBoxPosts.SelectedIndex &gt;= 0)
    {
        buttonRefresh.Visibility = Visibility.Collapsed;
        buttonBack.Visibility = Visibility.Visible;
        webBrowser.Visibility = Visibility.Visible;
        Uri address = new Uri(Items[listBoxPosts.SelectedIndex].Id);
        webBrowser.Navigate(address);
    }
}
</pre>
<p>The mobile theme I’ve enabled for this blog is not really working well. The WPTouch theme I installed seems not really identifying Windows Phone 7 user agent string. (Amazingly it works well when I load using Intenet Explorer App in the Phone 7). </p>
<h3>Adding support for Orientation</h3>
<p>By default, the wizard creates application with Portrait Orientation. The page content will not be arranged according to the current orientation if we don’t add support for it. Change the orientation to Portrait/Landscape/PortraitOrLandscape in the XAML file</p>
<pre>
SupportedOrientations=&quot;PortraitOrLandscape&quot; Orientation=&quot;Portrait&quot;
</pre>
<h3>Handling Orientation Events</h3>
<p>It’s possible to override OnOrientationChanged function do if we need to manage something else other than the default orientation change support implemented in the base class. For the simple applications using controls, we can use the standard alignment surppot provided by the grids and panels. The controls will be perfectly aligned according the vertical and horizontal settings of the controls.</p>
<pre>
&lt;Grid x:Name=&quot;ContentPanel&quot; Grid.Row=&quot;1&quot; Margin=&quot;12,0,12,0&quot;&gt;
    &lt;ListBox Margin=&quot;0&quot; x:Name=&quot;listBoxPosts&quot; MouseLeftButtonUp=&quot;OnTapItem&quot; /&gt;
    &lt;phone:WebBrowser Margin=&quot;0&quot; x:Name=&quot;webBrowser&quot; /&gt;
&lt;/Grid&gt;
&lt;Button Content=&quot;Refresh&quot; Height=&quot;71&quot; HorizontalAlignment=&quot;Right&quot; Margin=&quot;320,145,0,0&quot; x:Name=&quot;buttonRefresh&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;160&quot; Click=&quot;buttonRefresh_Click&quot; /&gt;
&lt;Button Content=&quot;Back&quot; Height=&quot;71&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;0,145,0,0&quot; x:Name=&quot;buttonBack&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;160&quot; Click=&quot;buttonBack_Click&quot; /&gt;
</pre>
<p>Override the OnOrientationChanged if more flexibility is necessary</p>
<pre>
protected override void OnOrientationChanged(OrientationChangedEventArgs args)
{
    // do your code. If base is not called, then the orientation will not be changed
    base.OnOrientationChanged(args);
}
</pre>
<h3>Portrait Orientation</h3>
<p><a href="http://codereflect.com/wp-content/uploads/2010/10/image2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://codereflect.com/wp-content/uploads/2010/10/image_thumb2.png" width="384" height="714" /></a></p>
<p>&#160;</p>
<h3>Landscape Orientation</h3>
<p><a href="http://codereflect.com/wp-content/uploads/2010/10/image3.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://codereflect.com/wp-content/uploads/2010/10/image_thumb3.png" width="713" height="384" /></a> </p>
<h3>Putting it all together</h3>
<p><a href="http://github.com/codereflect/Windows-Phone-7/tree/master/SilverLightWP7Demo/">Download the source from GIT Hub</a></p>
<p><H2> Closing note </H2></p>
<p>I feel Windows Phone 7 is a solid platform. It uses the modern programming languages and technologies. C# is one of the most popular language and it’s expressive. The Apple’s iOS platform is truly a solid and great foundation but the object C has a slight learning curve. It’s obvious because it’s my father’s programming language, not mine. But Apple made the platform truly solid and cash cow for the developers. So nobody really care it’s his father’s or his. <img src='http://codereflect.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Microsoft has chosen right technologies for Windows Phone 7 is proven and popular. XNA, Silverlight with C# will surely give edge for Microsoft to get a pace on their platform. Also the developer tools are easy to work and available for free.</p>
<p>Charles Petzold is working for a free version of book for Programming Windows Phone 7 which is expected to out soon. Apple has a definite documentation, video tutorials and lot more stuffs to help the developers. The MSDN documentation is slightly noisy with too many languages technologies. Even if we check the documentation for silverlight, some of the functionalities may not work under Windows Phone 7. Hopefully we can see lot of good stuffs in MSDN and Channel 9 for Windows Phone 7( Channel 9 offer <a href="http://channel9.msdn.com/learn/courses/WP7TrainingKit/" target="_blank">Windows Phone 7 Training Kit now</a>). Now I’m exploring more about deploying the phone applications. See you son.</p>
]]></content:encoded>
			<wfw:commentRss>http://codereflect.com/2010/10/09/programming-windows-phone-7-hello-world/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Getting Processor architecture in x86 and x64 bit platform.</title>
		<link>http://codereflect.com/2010/10/09/getting-processor-architecture-in-x86-and-x64-bit-platform/</link>
		<comments>http://codereflect.com/2010/10/09/getting-processor-architecture-in-x86-and-x64-bit-platform/#comments</comments>
		<pubDate>Sat, 09 Oct 2010 02:02:25 +0000</pubDate>
		<dc:creator>@sarat</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[Codeproject]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[processor architecture]]></category>
		<category><![CDATA[Win32]]></category>
		<category><![CDATA[Windows Vista]]></category>
		<category><![CDATA[Windows XP]]></category>
		<category><![CDATA[x86. x64]]></category>

		<guid isPermaLink="false">http://codereflect.com/2010/10/09/getting-processor-architecture-in-x86-and-x64-bit-platform/</guid>
		<description><![CDATA[GetSystemInfo provides the basic system information and processor architecture of the underlying platform. This API can be used successfully in both x64 and x86 platform. But, under 64-bit WIndows, we can run 32 bit Applications( WOW64). If a WOW64 process call GetSystemInfo API, it will return the processor architecture as x86. Of course it should [...]]]></description>
			<content:encoded><![CDATA[<p>GetSystemInfo provides the basic system information and processor architecture of the underlying platform. This API can be used successfully in both x64 and x86 platform. But, under 64-bit WIndows, we can run 32 bit Applications( WOW64). If a WOW64 process call GetSystemInfo API, it will return the processor architecture as x86. Of course it should be the way, this API act otherwise there could compatibility problems may arise and application could act weird and show undefined behavior.</p>
<p>If the WOW64 process want to know the original platform it’s running, it must call GetNativeSystemInfo. When we’ve to use this? I’ve a realworld example. When we spawn process explorer (procexp.exe, it realize the underlying platform and create another exe procexp64.exe (64bit version) to iterate all process information in the system. Note that the GetNativeSystemInfo need to be called only if you 32bit application wants to run under 64 bit platform and need to care about the true underlying platform. In all other cases, call GetSystemInfo, which works across platforms uniquely. See the snippet below</p>
<pre>
#include "stdafx.h"
#include <Windows.h>

void displayPrcessorInfo( SYSTEM_INFO &#038;stInfo )
{
        switch( stInfo.wProcessorArchitecture )
        {
        case PROCESSOR_ARCHITECTURE_INTEL:
                printf( "Processor Architecture: Intel x86\n");
                break;
        case PROCESSOR_ARCHITECTURE_IA64:
                printf( "Processor Type: Intel x64\n");
                break;
        case PROCESSOR_ARCHITECTURE_AMD64:
                printf( "Processor Type: AMD 64\n");
                break;
        default:
                printf( "Unknown processor architecture\n");
        }
}

int _tmain(int argc, _TCHAR* argv[])
{
        SYSTEM_INFO stInfo;
        GetSystemInfo( &#038;stInfo );
        displayPrcessorInfo(stInfo);

        GetNativeSystemInfo( &#038;stInfo );
        displayPrcessorInfo(stInfo);
        return 0;
}
</pre>
<p>To know more about the different processor architecture in abstract level, please do <a href="http://codereflect.com/2007/06/12/flavours-of-64-bit-amd64-ia64-and-x64/" target="_blank">check one of my previous posts</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://codereflect.com/2010/10/09/getting-processor-architecture-in-x86-and-x64-bit-platform/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flicker free drawing in Windows 7/Vista</title>
		<link>http://codereflect.com/2010/09/29/flicker-free-drawing-in-windows-7vista/</link>
		<comments>http://codereflect.com/2010/09/29/flicker-free-drawing-in-windows-7vista/#comments</comments>
		<pubDate>Wed, 29 Sep 2010 15:40:05 +0000</pubDate>
		<dc:creator>@sarat</dc:creator>
				<category><![CDATA[softwares]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Aero]]></category>
		<category><![CDATA[Windows Vista]]></category>

		<guid isPermaLink="false">http://codereflect.com/2010/09/29/flicker-free-drawing-in-windows-7vista/</guid>
		<description><![CDATA[In Windows 2000 and Windows XP we can use WS_EX_COMPOSITED window style to avoid flickering in drawing the windows. These versions of Windows are not providing any default double buffering support for applications for flicker free drawing. WS_EX_COMPOSITED is an additional option provided by Windows to have double buffering feature. Even before that, people used [...]]]></description>
			<content:encoded><![CDATA[<p>In Windows 2000 and Windows XP we can use WS_EX_COMPOSITED window style to avoid flickering in drawing the windows. These versions of Windows are not providing any default double buffering support for applications for flicker free drawing. WS_EX_COMPOSITED is an additional option provided by Windows to have double buffering feature. Even before that, people used to employ MemoryDC based double buffering techniques. Even still people use the same. The whole drawing is ridirected to a bitmaps and this bitmap will be mapped directly to the Window client area. The BitBlt operation is really fast. You can see plenty of reusable memDC implementation on googling</p>
<p>But even if this parameter isn’t given the Windows under Windows 7 draws without much flickering. Why? (If you haven’t tried the WS_EX_COMPOSITED style, just create the Window using WS_EX_COMPOSITED style or call ModifyStyleEx( hWnd, 0, WS_EX_COMPOSITED, 0 ); in the Initialization routine).</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://codereflect.com/wp-content/uploads/2010/09/image17.png" width="616" height="364" /> </p>
<p>In Windows 7, the <a href="http://msdn.microsoft.com/en-us/library/aa969540.aspx" target="_blank">Desktop Window Manager (DWM)</a> manages all the Windows running in the system. DWM uses GPU available in the system. When Windows Aero is enabled, the entire desktop area is a Direct3D surface. All drawing operations made by Windows are sent directly to the offline buffer for rendering. DWM will swap this buffer to screen whenever required. Thus by default all Window operations are done through double buffering. This architecture is quite different in prior versions of Windows, where all the operations are redirected to the main screen(buffer).</p>
<p>To explain a bit more detailed, the Window itself being mapped as texture on the screen, the way this texture appeared is controlled through shader programs. Like Window transition effects are implemented through shaders. The shaders are small programs which can control the coordinates and pixels being displayed.</p>
<p>Since the desktop itself a 3D surface, DWM has access to all the Windows displayed on the screen. This it can effortlessly implement the new features like, aero peak, flip 3D etc. The double buffering is also provided by DWM during Window movement, repainting etc. for flicker free drawing.</p>
<p>The DWM double buffering methods are sometimes not compatible with real-time graphics applications and games. In this case, DWM will not do window compositing so the application can gain the desired performance and no overheads of DWM implemented double buffering.</p>
<p>DWM also employs efficient rendering techniques called culling to avoid displaying the WIndows which are not visible in the screen (minimized, small windows hidden behind other windows etc). But we can’t flickering will never happen under Windows 7. The high refreshing rate application may still cause flickering. These kind of applications must use Windows Native Double buffering support provided. I already have covered <a href="http://codereflect.com/2008/11/04/double-buffering-helpers-in-windows-vista/" target="_blank">about double buffering and double buffering helpers introducing since Windows Vista in separate blog post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://codereflect.com/2010/09/29/flicker-free-drawing-in-windows-7vista/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to restrict Window Movement?</title>
		<link>http://codereflect.com/2010/09/16/how-to-restrict-window-movement/</link>
		<comments>http://codereflect.com/2010/09/16/how-to-restrict-window-movement/#comments</comments>
		<pubDate>Thu, 16 Sep 2010 14:44:36 +0000</pubDate>
		<dc:creator>@sarat</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Visual C++]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[MFC]]></category>
		<category><![CDATA[Win32]]></category>
		<category><![CDATA[Windows Vista]]></category>
		<category><![CDATA[Windows XP]]></category>

		<guid isPermaLink="false">http://codereflect.com/2010/09/16/how-to-restrict-window-movement/</guid>
		<description><![CDATA[This is beginner level post. How we can make a Window immovable? Roughly we’ve two methods to do this. Method #1. Handle the NCHITTEST message and ignore while user click on the caption area (Titlebar). This method doesn’t work well in Windows 7/Vista if Aero is enabled. This method works with any type of Window [...]]]></description>
			<content:encoded><![CDATA[<p>This is beginner level post. How we can make a Window immovable?</p>
<p>Roughly we’ve two methods to do this.</p>
<p><strong>Method #1</strong>. Handle the NCHITTEST message and ignore while user click on the caption area (Titlebar). This method doesn’t work well in Windows 7/Vista if Aero is enabled. This method works with any type of Window having titlebar. The disadvantage of this method is , the user will still able to move using keyboard, if system menu is available.</p>
<p>&#160;</p>
<pre>
LRESULT CMoveWindowSampleDlg::OnNcHitTest(CPoint point)
{
    UINT nHitTest = CDialogEx::OnNcHitTest(point);

    if( HTCAPTION == nHitTest )
        nHitTest = HTNOWHERE;

    return nHitTest;
}</pre>
<p><strong>Method #2</strong> – Remove the Move command from System Menu (Works with windows having system menu stle (WS_SYSMENU) ). The the Move command in the system menu will be removed in this case. Windows will internally disable the movement of this kind of Windows. </p>
<pre>
BOOL CMoveWindowSampleDlg::OnInitDialog()
{
    CDialogEx::OnInitDialog();

    CMenu* pSysMenu = GetSystemMenu(FALSE);

    if (pSysMenu != NULL)
    {
        pSysMenu-&gt;RemoveMenu( SC_MOVE, MF_BYCOMMAND );
       }
...

       return TRUE;
}
</pre>
<p>PS: Using method 2, this is the same method we use to disable the close button of a Window. For disabling a menu/titlebar button. Call EnableMenu function with relevant parameters.</p>
]]></content:encoded>
			<wfw:commentRss>http://codereflect.com/2010/09/16/how-to-restrict-window-movement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

