<?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; Visual Studio 2010</title>
	<atom:link href="http://codereflect.com/category/visual-studio-2010/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>Graphics Debugging in Visual Studio 2011</title>
		<link>http://codereflect.com/2011/11/09/graphics-debugging-in-visual-studio-2011/</link>
		<comments>http://codereflect.com/2011/11/09/graphics-debugging-in-visual-studio-2011/#comments</comments>
		<pubDate>Wed, 09 Nov 2011 17:35:49 +0000</pubDate>
		<dc:creator>@sarat</dc:creator>
				<category><![CDATA[direct2D]]></category>
		<category><![CDATA[Visual C++]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[Visual Studio 2011]]></category>
		<category><![CDATA[D2D]]></category>
		<category><![CDATA[D3D]]></category>
		<category><![CDATA[links]]></category>

		<guid isPermaLink="false">http://codereflect.com/?p=1776</guid>
		<description><![CDATA[Metro style games and graphics-intensive apps present a huge opportunity for developers on new devices such as tablets. The primary API for accessing the full power of the underlying graphics hardware on Windows is DirectX 11 (including Direct3D and Direct2D). One of the most significant innovations we have brought to Visual Studio 11 is a series of tools for assisting [...]]]></description>
			<content:encoded><![CDATA[<p>Metro style games and graphics-intensive apps present a huge opportunity for developers on new devices such as tablets. The primary API for accessing the full power of the underlying graphics hardware on Windows is <strong>DirectX 11</strong> (including <strong>Direct3D</strong> and <strong>Direct2D</strong>).</p>
<p>One of the most significant innovations we have brought to Visual Studio 11 is a series of tools for assisting you in developing Direct3D games. We made a quick video of some of these features on Channel9 (<a href="http://channel9.msdn.com/posts/Visual-Studio-vNext-DirectX-11-Development-Experience" target="_blank">link</a>). In this post, I will walk through our debugging &amp; diagnostics support for D3D.</p>
<p>The new <strong>Graphics Debugger</strong> in Visual Studio is a debugging and analysis tool that captures detailed information from a Direct3D application as it executes. You can use it to:</p>
<ul>
<li>Capture rendered frames for later inspection and analysis.</li>
<li>View DirectX events and their effects on the application.</li>
<li>View 3D meshes before and after vertex shader transformations.</li>
<li>Discover which DirectX events contribute to the color of a specific pixel.</li>
<li>Jump directly to the location in source code for a particular DirectX call</li>
</ul>
<div><strong><a href="http://blogs.msdn.com/b/vcblog/archive/2011/11/08/10235150.aspx" target="_blank">Read more from Visual C++ Team Blog </a></strong></div>
<div><img class="alignnone" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-69-metablogapi/7713.image27_5F00_thumb_5F00_210F27F9.png" alt="" width="644" height="370" /></div>
]]></content:encoded>
			<wfw:commentRss>http://codereflect.com/2011/11/09/graphics-debugging-in-visual-studio-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to resolve Visual Studio warning &#8220;The project location is not trusted&#8221; on mapped network drives?</title>
		<link>http://codereflect.com/2011/08/03/how-to-resolve-visual-studio-warning-the-project-location-is-not-trusted-on-mapped-network-drives/</link>
		<comments>http://codereflect.com/2011/08/03/how-to-resolve-visual-studio-warning-the-project-location-is-not-trusted-on-mapped-network-drives/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 05:34:01 +0000</pubDate>
		<dc:creator>@sarat</dc:creator>
				<category><![CDATA[Clearcase]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[caspol]]></category>
		<category><![CDATA[clearcase]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[Security settings]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://codereflect.com/?p=1649</guid>
		<description><![CDATA[You might have seen the above warning when you open a Visual Studio solution on a mapped network drive. This especially appears when you work with clearcase mapped network drives. Find for caspol.exe in your Windows\Microsoft.NET\Framework folder. C:\Windows\Microsoft.NET\Framework\v2.0.50727\CasPol.exe -m -pp off -cg 1.2 FullTrust This will grant full trust to local intranet code group. Note [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://codereflect.com/assets/Untrusted.png"><img src="http://codereflect.com/assets/Untrusted.png" alt="" title="Untrusted Project Location" width="492" height="263" class="alignnone size-full wp-image-1650" /></a></p>
<p>You might have seen the above warning when you open a Visual Studio solution on a mapped network drive. This especially appears when you work with clearcase mapped network drives. </p>
<p>Find for <a href="http://msdn.microsoft.com/en-us/library/cb6t8dtz%28v=vs.80%29.aspx">caspol.exe </a>in your Windows\Microsoft.NET\Framework folder.</p>
<pre>C:\Windows\Microsoft.NET\Framework\v2.0.50727\CasPol.exe -m -pp off -cg 1.2 FullTrust</pre>
<p>This will grant full trust to local intranet code group. Note that caspol tool will apply the security settings for 3.0, 3.5 as well though it&#8217;s coming with .NET 2.0</p>
]]></content:encoded>
			<wfw:commentRss>http://codereflect.com/2011/08/03/how-to-resolve-visual-studio-warning-the-project-location-is-not-trusted-on-mapped-network-drives/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to save Icon as bitmap?</title>
		<link>http://codereflect.com/2011/05/05/how-to-save-icon-as-bitmap/</link>
		<comments>http://codereflect.com/2011/05/05/how-to-save-icon-as-bitmap/#comments</comments>
		<pubDate>Thu, 05 May 2011 12:06:55 +0000</pubDate>
		<dc:creator>@sarat</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Visual C++]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[bitmap]]></category>
		<category><![CDATA[icon]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[tweak]]></category>

		<guid isPermaLink="false">http://codereflect.com/?p=1428</guid>
		<description><![CDATA[Icons are being a bit mysterious comparing to bitmaps. Now how we can save and icon to bitmap. There are several methods to do this. Here&#8217;s a simple tweak to save it using memory DC. void SaveBitmapToFile( BYTE* pBitmapBits, LONG lWidth, LONG lHeight,WORD wBitsPerPixel, LPCTSTR lpszFileName ) { BITMAPINFOHEADER bmpInfoHeader = {0}; // Set the [...]]]></description>
			<content:encoded><![CDATA[<p>Icons are being a bit mysterious comparing to bitmaps. Now how we can save and icon to bitmap. There are several methods to do this. Here&#8217;s a simple tweak to save it using memory DC.</p>
<pre>
void SaveBitmapToFile( BYTE* pBitmapBits, LONG lWidth, LONG lHeight,WORD wBitsPerPixel, LPCTSTR lpszFileName )
{
    BITMAPINFOHEADER bmpInfoHeader = {0};
    // Set the size
    bmpInfoHeader.biSize = sizeof(BITMAPINFOHEADER);
    // Bit count
    bmpInfoHeader.biBitCount = wBitsPerPixel;
    // Use all colors
    bmpInfoHeader.biClrImportant = 0;
    // Use as many colors according to bits per pixel
    bmpInfoHeader.biClrUsed = 0;
    // Store as un Compressed
    bmpInfoHeader.biCompression = BI_RGB;
    // Set the height in pixels
    bmpInfoHeader.biHeight = lHeight;
    // Width of the Image in pixels
    bmpInfoHeader.biWidth = lWidth;
    // Default number of planes
    bmpInfoHeader.biPlanes = 1;
    // Calculate the image size in bytes
    bmpInfoHeader.biSizeImage = lWidth* lHeight * (wBitsPerPixel/8);

    BITMAPFILEHEADER bfh = {0};
    // This value should be values of BM letters i.e 0x4D42
    // 0x4D = M 0×42 = B storing in reverse order to match with endian
    bfh.bfType=0x4D42;
    /* or
    bfh.bfType = ‘B’+(‘M’ &lt;&lt; 8);
    // &lt;&lt;8 used to shift ‘M’ to end
    */
    // Offset to the RGBQUAD
    bfh.bfOffBits = sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER);
    // Total size of image including size of headers
    bfh.bfSize = bfh.bfOffBits + bmpInfoHeader.biSizeImage;
    // Create the file in disk to write
    HANDLE hFile = CreateFile( lpszFileName,GENERIC_WRITE, 0,NULL,

                               CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL);

    if( !hFile ) // return if error opening file
    {
        return;
    }

    DWORD dwWritten = 0;
    // Write the File header
    WriteFile( hFile, &amp;bfh, sizeof(bfh), &amp;dwWritten , NULL );
    // Write the bitmap info header
    WriteFile( hFile, &amp;bmpInfoHeader, sizeof(bmpInfoHeader), &amp;dwWritten, NULL );
    // Write the RGB Data
    WriteFile( hFile, pBitmapBits, bmpInfoHeader.biSizeImage, &amp;dwWritten, NULL );
    // Close the file handle
    CloseHandle( hFile );
}

void CLoadIconSampleDlg::OnBnClickedButtonSaveIcon()
{
	// Loading resource from DLL.
	HMODULE h = LoadLibrary( L&quot;myresource.dll&quot; );

	if( !h )
	{
		MessageBox( L&quot;Failed to load library&quot; );
		return;
	}

	INT id = GetDlgItemInt( IDC_EDIT1 );
	m_hLoadedIcon = LoadIcon( (HINSTANCE) h , MAKEINTRESOURCE( id ) );

	CBitmap bmpSave;
	CClientDC dc(this);
	bmpSave.CreateCompatibleBitmap( &amp;dc, 32, 32 );

	CDC dcMem;
	dcMem.CreateCompatibleDC( &amp;dc );
	dcMem.SelectObject( &amp;bmpSave );
	dcMem.DrawIcon( 0, 0, m_hLoadedIcon );

	BITMAP bmpInfo;
	bmpSave.GetBitmap( &amp;bmpInfo );

	int size = bmpInfo.bmHeight* bmpInfo.bmWidth * (bmpInfo.bmBitsPixel / 8 );
	unsigned char* pBytes = new unsigned char[size];
	bmpSave.GetBitmapBits( size, pBytes );
	SaveBitmapToFile( pBytes, 32, 32, bmpInfo.bmBitsPixel, _T( &quot;C:\\temp\\temp.bmp&quot; ));
	delete []pBytes;

	FreeLibrary( h );
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://codereflect.com/2011/05/05/how-to-save-icon-as-bitmap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>const to data and pointer</title>
		<link>http://codereflect.com/2011/02/23/const-to-data-and-pointer/</link>
		<comments>http://codereflect.com/2011/02/23/const-to-data-and-pointer/#comments</comments>
		<pubDate>Wed, 23 Feb 2011 08:57:52 +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>

		<guid isPermaLink="false">http://codereflect.com/?p=1424</guid>
		<description><![CDATA[This is a fundamental thing that every C++ programmers must know. const to data This is the simplest form of pointer definition that we always do. const int* data3 = arr2; // Const to data data3[0] = 55;  // ERROR: Data can't be changed data3 = arr1;    // Success:  Can't change the pointer to somewhere [...]]]></description>
			<content:encoded><![CDATA[<p>This is a fundamental thing that every C++ programmers must know.</p>
<h2>const to data</h2>
<p>This is the simplest form of pointer definition that we always do.</p>
<pre>
const int* data3 = arr2; // Const to data
data3[0] = 55;  // ERROR: Data can't be changed
data3 = arr1;    // Success:  Can't change the pointer to somewhere else
</pre>
<p>Here the data is can’t changed using data3 pointer. but the pointer itself can be modified and can point to some other location.</p>
<p>Usually  we don’t care even if pass the pointer to some function and that  pointer changes to some other location, as the function parameters  points to same location but the pointer is a copy of actual parameter.  But things may go different if we wrongly pass reference to function  parameters even it’s const. So we’ve to take care this while designing  the interfaces.</p>
<pre>
void Foo(  LPCTSTR&amp; lpszValue )
{
	lpszValue = _T( &quot;codereflect.com&quot; );
}

int _tmain(int argc, _TCHAR* argv[])
{
	LPCTSTR sz = NULL;
	Foo(sz);
	_tprintf( sz );
	return 0;
}
</pre>
<h2>const to pointer</h2>
<p>In this form of usage, the pointer can’t be changed to some location but the data can be changed.</p>
<pre>
int* const data2 = arr2; // const to pointer
data2 = arr1;    // Can't change the pointer to somewhere else
data2[0] = 55;  // SUCCESS: Data can be changed
</pre>
<h2>const to both data and pointer</h2>
<p>This is the goodness of both <img src='http://codereflect.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . The most secure pointer.</p>
<pre>
const int* const data1 = arr1; // Const to both pointer and data
data1 = arr2;    // ERROR: can't change the pointer
data1[0] = 100; // ERROR: can't change the data
</pre>
]]></content:encoded>
			<wfw:commentRss>http://codereflect.com/2011/02/23/const-to-data-and-pointer/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 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>
		<item>
		<title>Visual Studio 2010 &#8211; Productivity tools</title>
		<link>http://codereflect.com/2010/08/11/visual-studio-2010-productivity-tools/</link>
		<comments>http://codereflect.com/2010/08/11/visual-studio-2010-productivity-tools/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 17:22:25 +0000</pubDate>
		<dc:creator>@sarat</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C Sharp]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[Visual C++]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[Extensibility]]></category>
		<category><![CDATA[Productivity Tools]]></category>

		<guid isPermaLink="false">http://codereflect.com/2010/08/11/visual-studio-2010-productivity-tools/</guid>
		<description><![CDATA[Most of the Visual Studio Developers are familiar with Visual Assist X developer tool. It has really nifty features for improving the productivity. It may not be too detailed refactoring facilities or so flexible features as other tools provides like DevExpress but as a whole all we like this tool. But only one problem, it’s [...]]]></description>
			<content:encoded><![CDATA[<p>Most of the Visual Studio Developers are familiar with Visual Assist X developer tool. It has really nifty features for improving the productivity. It may not be too detailed refactoring facilities or so flexible features as other tools provides like DevExpress but as a whole all we like this tool. But only one problem, it’s a paid software.</p>
<p>Visual Studio IDE is consistently getting improved over the versions but still some of the feature are missing like Symbol Search, file search within the IDE until Visual Studio 2010. It’s really important while managing large projects. The best thing in the Visual Studio 2010, is the <a href="http://msdn.microsoft.com/en-us/vstudio/vextend.aspx" target="_blank">extensibility SDK</a>. It’s far more flexible and prominent comparing to it’s predecessors.</p>
<p>Microsoft has created a really helpful site to host the useful tools for Visual Studio created by developers across the world. Even Microsoft has created some really cool tools for Visual Studio which is freely available in <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/" target="_blank">Visual Studio Gallery</a>.</p>
<p>Productivity tools are one of best extensions available. It contains a bunch of features to improve your Visual Studio 2010 experience. You can download it from <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/d0d33361-18e2-46c0-8ff2-4adea1e34fef?SRC=Home" target="_blank">Visual Studio Gallery</a>. The features can be simply enabled and disabled through Tools-&gt;Option menu.</p>
<p><a href="http://codereflect.com/wp-content/uploads/2010/08/image.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/08/image_thumb.png" width="619" height="360" /></a> </p>
<p>Let’s have a quick look into the features. Each options are described well in their home page itself. Let’s skim through the features anyway. This contains only the features I handpicked from the whole features available. You can see the entire features the home page itself. The descriptions and screenshots are given same as the extension&#8217;s homepage.</p>
<p><strong>Solution Navigator</strong><strong>&#160; (<a href="http://blogs.msdn.com/b/visualstudio/archive/2010/07/20/solution-navigator-blog-post.aspx">More Info</a>)</strong></p>
<p><a href="http://codereflect.com/wp-content/uploads/2010/08/image1.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/08/image_thumb1.png" width="341" height="430" /></a> </p>
<p>This is one of the best feature.</p>
<ul>
<li>Expand code files to navigate to its classes, expand classes to navigate to their members, and so on (C# and VB only) </li>
<li>Search your solution, all the way down to class members </li>
<li>Filter your solution or projects to see just opened files, unsaved files, and so on </li>
<li>View related information about classes and members (such as references or callers/callees for C#) </li>
<li>Preview images by hovering over them, or preview rich information by hovering over code item</li>
</ul>
<p>Solution Navigator also provides interactive tooltips in C# and VB code (replacing the default “quick info” tooltips) that give you the same kind of data, but right at your fingertips.&#160; In addition to getting the tooltips on hover, you can: </p>
<ul>
<li>Press Ctrl+1 to open a relevant tooltip at the current cursor location </li>
<li>Press Ctrl+2 to quickly navigate to any class/member in the current source file</li>
</ul>
<p><strong></strong></p>
<p><strong>Ctrl + Click Go To Definition</strong>    <br />This extension gives the editor a web browser by adding clickable hyperlinks to symbols in your code as you hold down the Ctrl key.</p>
<p><strong>Align Assignments</strong>    <br />This extension is useful for making your code a little more readable by aligning the assignments when you type Ctrl+Alt+] such that it takes this:    <br /><img alt="" src="http://i3.visualstudiogallery.msdn.microsoft.com/en-us/d0d33361-18e2-46c0-8ff2-4adea1e34fef/image/file/32145/0/align1.bmp" width="224" height="89" />    <br />And turns it into this:    <br /><img alt="" src="http://i1.visualstudiogallery.msdn.microsoft.com/en-us/d0d33361-18e2-46c0-8ff2-4adea1e34fef/image/file/32146/0/align2.bmp" width="235" height="84" />    <br /><em>Please note:</em> This may conflict with your formatting settings. E.g. in C# you will need to disable: Tools-&gt;Options-&gt;Text Editor-&gt;C#-&gt;Formatting-&gt;Spacing-&gt;&quot;Ignore spaces in declaration statements&quot;</p>
<p><strong>Triple Click</strong>    <br />It’s never been easier to select a line of code from the mouse by simple triple-clicking anywhere on the line. </p>
<p><strong>Highlight Current Line</strong>    <br />As the resolution of monitors increases, it’s becoming more difficult to find the caret in the code editor.&#160; The highlight current line extension makes it easy to find the caret by highlighting the line that the caret is on in the editor.&#160; You can even configure the default colour by changing the setting for “Current Line (Extension)” and “Current Line Inactive (Extension)” in Tools Options Fonts &amp; Colors. </p>
<p><strong>HTML Copy (<a href="http://blogs.msdn.com/b/kirillosenkov/archive/2010/06/07/copy-code-in-html-format-with-visual-studio-2010.aspx">More Info</a>)</strong>    <br />This extension provides support for the HTML Clipboard format when cutting or copying code from the editor.&#160; This means that you’ll no longer have to go fix up the formatting of your code when you paste it into a TFS bug form or any other HTML based control. </p>
<p><strong>Colorized Parameter Help</strong>    <br />This extension improves consistency with the editor by applying syntax highlighting to the contents of the Parameter Help window for C# &amp;VB.    <br />Please note: Syntax highlighting colors can be customized using the display items prefixed with “Signature Help” in the “Fonts and Colors” menu.</p>
<p><strong>Tab Well UI </strong>    <br />This extension allows you to completely customize the behavior of your document tabs from the Productivity Power Tools Options: See <a href="http://blogs.msdn.com/b/visualstudio/archive/2010/06/10/document-well-2010-plus.aspx">More Info</a></p>
<p><strong>Auto Brace Completion     <br /></strong>Automatic Brace Completion improves the productivity of writing code by automatically inserting the closing code construct when the opening construct is typed for VB &amp; C#.&#160; More specifically, this extension:</p>
<ul>
<li>Supports the following constructs: (), {}, [], &lt;&gt;, “”, and ‘’.&#160; </li>
<li>Allows you to press &lt;TAB&gt; to navigate past the next enclosing brace </li>
<li>Allows you to automatically complete a statement in C# by inserting the closing semi-colon and moving you to the next line with SHIFT + ENTER</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://codereflect.com/2010/08/11/visual-studio-2010-productivity-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programming Direct2D – Part 1</title>
		<link>http://codereflect.com/2010/07/19/programming-direct2d-part-1/</link>
		<comments>http://codereflect.com/2010/07/19/programming-direct2d-part-1/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 15:00:05 +0000</pubDate>
		<dc:creator>@sarat</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Codeproject]]></category>
		<category><![CDATA[Visual C++]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://codereflect.com/?p=1209</guid>
		<description><![CDATA[Most of the native Windows Programmers are familiar with GDI, the graphics API provided under Windows. GDI is widely used in windows applications. Later, Microsoft had introduced class-based, better services through GDI+ under Windows. Both Native programmers and Managed developers are making use of GDI/GDI+ classes and APIs. But GDI was too old and was [...]]]></description>
			<content:encoded><![CDATA[<p>Most of the native Windows Programmers are familiar with GDI, the graphics API provided under Windows. GDI is widely used in windows applications. Later, Microsoft had introduced class-based, better services through GDI+ under Windows. Both Native programmers and Managed developers are making use of GDI/GDI+ classes and APIs.</p>
<p>But GDI was too old and was introduced with the initial versions of the Windows and over the time the capabilities of graphics hardware has grown and so does the demand for creating Visually Rich UI. With Windows 7, Microsoft has introduced a totally revamped 2D graphics subsystem called <strong><a href="http://msdn.microsoft.com/en-us/library/dd370990(VS.85).aspx" target="_blank">Direct2D</a></strong> based on their prominent Direct3D platform to create high quality 2D rendering. If you know or not, <a href="http://windows.microsoft.com/en-us/windows-vista/products/features/productivity">Windows Aero</a> system is already taking advantage of graphics hardware since Windows Vista. This is supposed to replace the GDI APIs in the coming years. Direct2D is not only available under Windows 7 but Microsoft has made it available in Window Vista with the latest service pack upgrade.</p>
<p>The major advantages of the Direct2D APIs are it&#8217;s hardware accelerated and provides high quality 2D rendering. It enables the user to create visually rich applications by paying less effort, when comparing to conventional APIs .</p>
<p>GDI uses Pixel graphics but Direct2D can supports vector graphics as well, in which mathematical formulas are used to draw the lines and curves. Vector graphics provides high quality rendering independent of resolution of the device, while the pixelated graphics has dependency with resolution which may results in choppy graphics.</p>
<p>Most of the GDI APIs are not using anti-aliasing and transparency. Ofcrouse there are functions to do so but always there&#8217;s programming cost for taking advantage of these features. Also if we apply  transparency and anti-aliasing, the computations are done using CPU. Direct2D can take advantage of graphics hardware and delegate the computationally intensive tasks to <a href="http://en.wikipedia.org/wiki/Graphics_processing_unit">GPU</a>.</p>
<p><img src="http://codereflect.com/wp-content/uploads/2010/07/071910_1523_Programming11.png" alt="" /></p>
<p>Direct2D built on top of Direct3D components. The layered architecture is described below</p>
<p><img src="http://codereflect.com/wp-content/uploads/2010/07/071910_1523_Programming21.png" alt="" /></p>
<p>You can see the underlying layers are Direct3D which make use of DXGI(DirectX Graphics Infrastructure), which manages the low level graphics related tasks that are independent of DirectX graphics runtime. DXGI provides common framework for graphics components. Simultaneously a high performance software rasterizer is available when the hardware acceleration is not possible. Another advantage of Direct2D API is, it&#8217;s using lightweight COM. It&#8217;s almost like simple C++ class. No BSTRS, COM Variants, Interfaces, Apartments etc.</p>
<p>Let&#8217;s start analyzing a simple Direct2D Program</p>
<p>There are 3 main components inevitable for enabling D2D rendering your application.</p>
<ul>
<li>A rendering Window and its handle (HWND)</li>
<li><a href="http://msdn.microsoft.com/en-us/library/dd371246(VS.85).aspx">ID2D1Factory</a> object to create the Direct2D resources</li>
<li><a href="http://msdn.microsoft.com/en-us/library/dd371461(VS.85).aspx">ID2D1HwndRenderTarget</a> object to draw the scene on the window.</li>
</ul>
<p>The below example provides steps for enabling Direct2D Rendering in your MFC Application. It&#8217;s hard to describe the parameters of all APIs. Please refer them in MSDN.</p>
<p><img src="http://codereflect.com/wp-content/uploads/2010/07/071910_1523_Programming31.png" alt="" /></p>
<h2>Create your Window</h2>
<p>Here I&#8217;m taking a dialog based application for rendering. The functions and messages may change if you&#8217;re using any other type of applications like SDI or MDI. No need to reinvent the wheel, allow the wizard to create your main dialog.</p>
<h2>Prepare your Rendering Engine</h2>
<p>Let&#8217;s delegate all the rendering tasks to another class instead of managing everything in the dialog class. I call this class as Direct2DHandler.</p>
<p>The Direct2DHandler declaration goes like below and it exposes the following functions.</p>
<pre>
#pragma once
#include &lt;d2d1.h&gt;
#include &lt;d2d1helper.h&gt;

class Direct2DHandler
{
public:
	Direct2DHandler( HWND hWnd ); // ctor
	~Direct2DHandler(void); // dtor
	HRESULT Initialize(); // Initialize the rendering
	HRESULT OnRender(); // Called from OnPaint function
	void OnResize(UINT width, UINT height);

private:
	HRESULT CreateDeviceResources(); // Create resources for drawing
	void DiscardDeviceResources(); // Release resources for drawing

private:

	HWND					m_hWnd;
	ID2D1Factory*			m_pDirect2dFactory;
	ID2D1HwndRenderTarget*	m_pRenderTarget;
	ID2D1SolidColorBrush*	m_pLightSlateGrayBrush;
	ID2D1LinearGradientBrush* m_pLinearGradientBrush;
};
</pre>
<h3>The constructor</h3>
<p>does nothing other than calling CoInitialize() function and initialize the member variables( mostly to NULL).</p>
<h3>The Initialize function</h3>
<p>creates the Direct2D factor object, which similar the HDC (context variable) in GDI.</p>
<pre>
HRESULT Direct2DHandler::Initialize()
{
    HRESULT hr = S_OK;

    // Create a Direct2D factory.
    hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &amp;m_pDirect2dFactory);

    return hr;
}
</pre>
<p><strong>OnResize</strong></p>
<p>function handles the rendering area for the render target. We will be using whole window area in this example.<span style="font-family: Consolas; font-size: 9pt;"><br />
</span></p>
<pre>
void Direct2DHandler::OnResize(UINT width, UINT height)
{
    if (m_pRenderTarget)
    {
        // Note: This method can fail, but it's okay to ignore the
        // error here, because the error will be returned again
        // the next time EndDraw is called.
        m_pRenderTarget-&gt;Resize(D2D1::SizeU(width, height));
    }
}
</pre>
<h3>OnRender</h3>
<p>function does the following</p>
<ol>
<li>Create the device resource for drawing (if not created)</li>
<li>Render the scene to the Window</li>
<li>Release the resources if error occurred</li>
</ol>
<p>If you&#8217;re experienced 3D programming probably you might be knowing about the role of matrix and how the affects the rendering object. The matrix can be used for representing the objects coordinates system. We can apply rotation, translation (movement) etc (collectively called transformation). on a matrix and this can be used for specifying how object must be rendered. Here we&#8217;re using <span style="font-family: Consolas; font-size: 9pt;">D2D1::Matrix3x2F::Identity() </span>helper function which creates an identity matrix(object will be rendered at origin without any transformation)</p>
<p><span style="font-family: Consolas; font-size: 9pt;"> m_pRenderTarget-&gt;<a href="http://msdn.microsoft.com/en-us/library/dd742857(VS.85).aspx">SetTransform</a>(D2D1::Matrix3x2F::Identity());<br />
</span></p>
<p>We can clear the rendering area with a default color (as the dialog background filled with some default color according to Window&#8217;s theme. Here I selected white color</p>
<p><span style="font-family: Consolas; font-size: 9pt;"> m_pRenderTarget-&gt;Clear(D2D1::ColorF(D2D1::ColorF::White));<br />
</span></p>
<p>The important thing is, whatever you draw for the scene must be done between BeginDraw() and EndDraw() APIs. The other part of this code is simply straight forward and you can easily grasp it. See the source below.</p>
<pre>
HRESULT Direct2DHandler::OnRender()
{
	HRESULT hr = S_OK;

	hr = CreateDeviceResources();

	if (SUCCEEDED(hr))
	{
		m_pRenderTarget-&gt;BeginDraw();
		m_pRenderTarget-&gt;SetTransform(D2D1::Matrix3x2F::Identity());
		m_pRenderTarget-&gt;Clear(D2D1::ColorF(D2D1::ColorF::White));
		D2D1_SIZE_F rtSize = m_pRenderTarget-&gt;GetSize();
		// Draw a grid background.
		int width = static_cast&lt;int&gt;(rtSize.width);
		int height = static_cast&lt;int&gt;(rtSize.height);

		// Draw two rectangles.
		D2D1_RECT_F rectangle1 = D2D1::RectF(
			rtSize.width/2 - 50.0f,
			rtSize.height/2 - 50.0f,
			rtSize.width/2 + 50.0f,
			rtSize.height/2 + 50.0f
			);

		D2D1_RECT_F rectangle2 = D2D1::RectF(
			rtSize.width/2 - 100.0f,
			rtSize.height/2 - 100.0f,
			rtSize.width/2 + 100.0f,
			rtSize.height/2 + 100.0f
			);

		// Draw the outline of a rectangle.
		m_pRenderTarget-&gt;FillRectangle(&amp;rectangle2, m_pLinearGradientBrush);

		// Draw a filled rectangle.
		m_pRenderTarget-&gt;FillRectangle(&amp;rectangle1, m_pLightSlateGrayBrush);

		hr = m_pRenderTarget-&gt;EndDraw();

	}
	if (hr == D2DERR_RECREATE_TARGET)
	{
		hr = S_OK;
		DiscardDeviceResources();
	}
	return hr;
}
</pre>
<p><strong>CreateDeviceResources</strong></p>
<p>is slightly a lengthy function to initialize the required resources for rendering, like we create pens, brushes, bitmaps etc. Here mainly I&#8217;m creating a light colored solid brush and linear gradient brush to render as depicted in above picture. The comments are inlined and please read it along with the code. It will be interesting to learn about gradient brushes. If you&#8217;ve created a gradient brush in photoshop things will be far more easy. We can put stop spots to controls the end of gradients also line can be used for representing flow and angle for the gradient. Simple isn&#8217;t it? Like we create a normal gradient. See the code below.</p>
<pre>
HRESULT Direct2DHandler::CreateDeviceResources()
{
    HRESULT hr = S_OK;

    if (!m_pRenderTarget)
    {
        RECT rc;
        GetClientRect(m_hWnd, &amp;rc);

        D2D1_SIZE_U size = D2D1::SizeU(
            rc.right - rc.left,
            rc.bottom - rc.top
            );

        // Create a Direct2D render target.
        hr = m_pDirect2dFactory-&gt;CreateHwndRenderTarget(
            D2D1::RenderTargetProperties(),
            D2D1::HwndRenderTargetProperties(m_hWnd, size),
            &amp;m_pRenderTarget
            );

        if (SUCCEEDED(hr))
        {
            // Create a gray brush.
            hr = m_pRenderTarget-&gt;CreateSolidColorBrush(
                D2D1::ColorF(D2D1::ColorF::LightSlateGray),
                &amp;m_pLightSlateGrayBrush
                );
        }

		// Create an array of gradient stops to put in the gradient stop
		// collection that will be used in the gradient brush.
		ID2D1GradientStopCollection *pGradientStops = NULL;

		D2D1_GRADIENT_STOP gradientStops[2];
		gradientStops[0].color = D2D1::ColorF(D2D1::ColorF::Maroon, 1);
		gradientStops[0].position = 0.0f;
		gradientStops[1].color = D2D1::ColorF(D2D1::ColorF::Red, 1);
		gradientStops[1].position = 1.0f;
		// Create the ID2D1GradientStopCollection from a previously
		// declared array of D2D1_GRADIENT_STOP structs.
		hr = m_pRenderTarget-&gt;CreateGradientStopCollection(
			gradientStops,
			2,
			D2D1_GAMMA_2_2,
			D2D1_EXTEND_MODE_CLAMP,
			&amp;pGradientStops
			);
		// The line that determines the direction of the gradient starts at
		// the upper-left corner of the square and ends at the lower-right corner.

		if (SUCCEEDED(hr))
		{
			hr = m_pRenderTarget-&gt;CreateLinearGradientBrush(
				D2D1::LinearGradientBrushProperties(
				D2D1::Point2F(0, 0),
				D2D1::Point2F(300, 300)),
				pGradientStops,
				&amp;m_pLinearGradientBrush
				);
		}

    }

    return hr;
}
</pre>
<h3>DiscardDeviceResources</h3>
<p>Just releases the allocated resouces. It simply uses helper macro SafeRelease described below the code.</p>
<pre>
void Direct2DHandler::DiscardDeviceResources()
{
    SafeRelease(&amp;m_pRenderTarget);
    SafeRelease(&amp;m_pLightSlateGrayBrush);
    SafeRelease(&amp;m_pLinearGradientBrush);
}

template&lt;class Interface&gt;
inline void SafeRelease(
    Interface **ppInterfaceToRelease
    )
{
    if (*ppInterfaceToRelease != NULL)
    {
        (*ppInterfaceToRelease)-&gt;Release();

        (*ppInterfaceToRelease) = NULL;
    }
}
</pre>
<p><strong>Initializing Rendering in Dialog class</strong></p>
<p>In the</p>
<h3>OnInitDialog function,</h3>
<p>allocate memory for the Direct2DHandler class and Initialize it. You can call this from OnCreate function as well but ensure that there&#8217;s a valid Window handle is there.</p>
<pre>
m_pRender = new Direct2DHandler( m_hWnd );
m_pRender-&gt;Initialize();
</pre>
<h3>Disable Default Background Drawing</h3>
<p>Disable the default OnErasBkgrnd function because it may cause flickering while drawing. Also we&#8217;re occupying full client area in the dialog and the background is clearing is OnRender function itself.</p>
<pre>
BOOL CDirect2DDemoDlg::OnEraseBkgnd(CDC* pDC)
{
    return FALSE;//CDialogEx::OnEraseBkgnd(pDC);
}
</pre>
<h3>OnSize (WM_SIZE)</h3>
<p>function handles the Window size events. It will resize render target according to the Window Size.</p>
<pre>
void CDirect2DDemoDlg::OnSize(UINT nType, int cx, int cy)
{
    CDialogEx::OnSize(nType, cx, cy);
    if( m_pRender )
        m_pRender-&gt;OnResize( cx, cy );
}
</pre>
<h3>OnPaint function</h3>
<p>calls OnRender function of Direct2DHandler to draw the scene.</p>
<pre>
void CDirect2DDemoDlg::OnPaint()
{
    if (IsIconic())
    {
        // code for handling when window is minimized. Check original CPP file attached.
    }
    else
    {
        // CDialogEx::OnPaint(); no need to call this.
        if( m_pRender )
            m_pRender-&gt;OnRender();
    }
}
</pre>
<h3>Linking</h3>
<p>The Application must link to d2d1.lib through project settings or using #pragma comment( lib, &#8220;d2d1.lib&#8221; ) in the source file</p>
<h3> d2d1helper </h3>
<p>d2d1helper.h contains some useful functions to help the drawing. See the header for more details.</p>
<p>OK that&#8217;s the basics of creating Direct2D rendering for your Windows Application. Go ahead with the attached source code.</p>
<p>The project file is in Visual Studio 2010 format, but basically you only need to have Direct2DHandler class. You can also use other prior version of Visual Studio with Windows 7/Vista SDK.</p>
<p>Note: Take whole responsibility of downloading and executing the code shared here. Don&#8217;t sue me. It was virus free, malware free when I uploaded.</p>
<p><a href="http://cid-5544789b26bfc05d.office.live.com/embedicon.aspx/.Public/Direct2DDemo.zip">Download Demo Source code</a><br />
<iframe title ="Preview" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" style="width:98px;height:115px;padding:0;background-color:#fcfcfc;" src="http://cid-5544789b26bfc05d.office.live.com/embedicon.aspx/.Public/Direct2DDemo.zip"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://codereflect.com/2010/07/19/programming-direct2d-part-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Visual Studio 2010 &#8211; Theme Editor &amp; Hide Main Menubar extension</title>
		<link>http://codereflect.com/2010/07/09/visual-studio-2010-theme-editor/</link>
		<comments>http://codereflect.com/2010/07/09/visual-studio-2010-theme-editor/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 16:09:40 +0000</pubDate>
		<dc:creator>@sarat</dc:creator>
				<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[Visual Studio Editor]]></category>

		<guid isPermaLink="false">http://codereflect.com/2010/07/09/visual-studio-2010-theme-editor/</guid>
		<description><![CDATA[Are you really bored of the default appearance of Visual Studio? Even it’s quite different from Normal Windows (XP) Menus and toolbars, yea I’m sure it’s really nice if we can customize the colors based on our mood. Here’s a free tool to play around with Visual Studio 2010. You can edit the theme for [...]]]></description>
			<content:encoded><![CDATA[<p>Are you really bored of the default appearance of Visual Studio? Even it’s quite different from Normal Windows (XP) Menus and toolbars, yea I’m sure it’s really nice if we can customize the colors based on our mood. </p>
<p>Here’s a free tool to play around with Visual Studio 2010. You can edit the theme for Visual Studio with <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/20cd93a2-c435-4d00-a797-499f16402378">Visual Studio Color Theme Editor</a>. It comes up with some default flavors of themes but we can also customize or download pre-created themes from any website. You can see a bunch of extensions, tools, themes etc. at <a href="http://visualstudiogallery.msdn.microsoft.com/en-us">Visual Studio Gallery</a>.</p>
<p><a href="http://codereflect.com/wp-content/uploads/2010/07/image.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/07/image_thumb.png" width="505" height="348" /></a> </p>
<p>Also <a href="http://studiostyles.info/">studiostyles.info</a> contains 100’s of themes to satisfy your moods. The Visual Studio 2010 extensibility library contains lot of gems to make everything in your way. Not only themes, the whole Visual Studio and it’s contents can be taken in your hand using <a href="http://msdn.microsoft.com/en-us/vstudio/vextend.aspx">Visual Studio 2010 SDK</a>. It’s much more flexible and innovative than it’s predecessors. You can get a bit more <a href="http://blogs.msdn.com/b/visualstudio/archive/2010/01/04/changing-visual-studio-s-color-palette.aspx" target="_blank">detailed scoop here</a>. Anyways have a nice time with colors <img src='http://codereflect.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Bonus: </strong>How many of you guys are fascinated with keyboard shortcuts? I usually use mouse only if I can’t operate something with keyobard. Have you ever wished, if we could hide the unusable menubar? Matthew Johnson has written a nice <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/bdbcffca-32a6-4034-8e89-c31b86ad4813">extension to hide the menubar from Visual Studio 2010 IDE</a>. On hitting, alt key will enable the menubar again. You can directly press the Alt+ Any (valid) key (e.g. Alt+F, Alt+T etc.)</p>
<p><a href="http://codereflect.com/wp-content/uploads/2010/07/image1.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/07/image_thumb1.png" width="422" height="175" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://codereflect.com/2010/07/09/visual-studio-2010-theme-editor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows  7: Task Dialog Part 2 &#8211; A more detailed task dialog</title>
		<link>http://codereflect.com/2010/07/07/windows-7-task-dialog-part-2-a-more-detailed-task-dialog/</link>
		<comments>http://codereflect.com/2010/07/07/windows-7-task-dialog-part-2-a-more-detailed-task-dialog/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 14:48:39 +0000</pubDate>
		<dc:creator>@sarat</dc:creator>
				<category><![CDATA[C++]]></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[Windows Vista]]></category>

		<guid isPermaLink="false">http://codereflect.com/?p=1196</guid>
		<description><![CDATA[In the last installment, we’ve seen using the basic version of task dialog. But usually when we see the task dialogs in Windows Vista or 7, it’s more detailed and can have flashy icons etc. Let’s see how to take more control over the task dialogs. TaskDialogIndirect function can be used to have more options [...]]]></description>
			<content:encoded><![CDATA[<p>In the last installment, we’ve seen using the basic version of task dialog. But usually when we see the task dialogs in Windows Vista or 7, it’s more detailed and can have flashy icons etc. Let’s see how to take more control over the task dialogs.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/bb760544(VS.85).aspx">TaskDialogIndirect</a> function can be used to have more options with task dialogs. <a href="http://msdn.microsoft.com/en-us/library/bb787473(v=VS.85).aspx">TASKDIALOGCONFIG</a> structure is used along with TaskDialogIndirect API.</p>
<p><a href="http://codereflect.com/wp-content/uploads/2010/07/clip_image001.png"><img style="display: inline; border: 0px;" title="clip_image001" src="http://codereflect.com/wp-content/uploads/2010/07/clip_image001_thumb.png" border="0" alt="clip_image001" width="456" height="326" /></a></p>
<p>As you’re seeing above the task dialog contains different type of controls, icons and capable of displaying more information to the user. It can have lengthy big buttons, radio buttons, checkbox, footer area, progressbar, custom icon, displaying predefined buttons like OK, Cancel, Yes, No etc. even we can have control over the buttons in the titlebar( minimize, maximize button etc)</p>
<p>The following code describes creating a task dialog with more flexible options. User can specify the callback functions which can be used to control the behavior if the controls and contents in the task bar. Filling the TASKDIALOGCONFIG structure is simple and straight forward as we’re seeing the code. The detailed option can be obtained from MSDN page.</p>
<pre>

HRESULT CALLBACK CTaskDialogSampleDlg::TaskDialogCallbackProc(
  __in  HWND hwnd,
  __in  UINT uNotification,
  __in  WPARAM wParam,
  __in  LPARAM lParam,
  __in  LONG_PTR dwRefData
)
{
	if( TDN_CREATED == uNotification )
	{
		::SendMessage( hwnd, TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE, IDOK, TRUE );
		::SendMessage( hwnd, TDM_SET_PROGRESS_BAR_RANGE, 0, 100 );
	}
	else if( TDN_HYPERLINK_CLICKED == uNotification )
	{
		ShellExecute( 0, L&quot;open&quot;, (LPCTSTR) lParam, 0, 0, SW_SHOW );
	}
	else if( TDN_TIMER == uNotification )
	{
		static int i = 0;
		::SendMessage( hwnd, TDM_SET_PROGRESS_BAR_POS, i++,0 );
	}

	return 0;
}

void CTaskDialogSampleDlg::OnBnClickedButton1()
{
	int nButtonPressed                  = 0;
	TASKDIALOGCONFIG config             = {0};
	const TASKDIALOG_BUTTON buttons[]   = {
		{ IDOK, L&quot;Elevate Privilege&quot; },
		{ IDCANCEL, L&quot;Run with user privilege&quot; }
	};

	const TASKDIALOG_BUTTON radiobuttons[] = {
		{ IDCANCEL, L&quot;Test Radio&quot; }};
	config.cbSize                       = sizeof(config);
	config.hInstance                    = AfxGetApp()-&gt;m_hInstance;
	config.dwCommonButtons              = TDCBF_OK_BUTTON | TDCBF_CANCEL_BUTTON;
	config.pszMainIcon                  = TD_SHIELD_ICON;
	config.pszMainInstruction           = L&quot;Main Instruction&quot;;
	config.pszContent                   = L&quot;This is the content.&quot;;
	config.pszVerificationText          = L&quot;Conifirm license agreement&quot;;
	config.pButtons                     = buttons;
	config.cButtons                     = ARRAYSIZE(buttons);
	config.pRadioButtons				= radiobuttons;
	config.cRadioButtons				= ARRAYSIZE( radiobuttons );
	config.dwFlags						= TDF_SHOW_PROGRESS_BAR |
		TDF_EXPAND_FOOTER_AREA | TDF_ENABLE_HYPERLINKS | TDF_CAN_BE_MINIMIZED
		| TDF_USE_COMMAND_LINKS | TDF_CALLBACK_TIMER;
	config.pszExpandedInformation		= _T( &quot;&lt;a href=\&quot;http://codereflect.com/\&quot; &gt;Codereflect.com&lt;/a&gt;&quot; );
	config.pfCallback = TaskDialogCallbackProc;
	BOOL bVerification = FALSE;
	TaskDialogIndirect(&amp;config, &amp;nButtonPressed, NULL, &amp;bVerification);

	switch (nButtonPressed)
	{
	case IDOK:
		break; // the user pressed button 0 (change password).
	case IDCANCEL:
		break; // user canceled the dialog
	default:
		break; // should never happen
	}
}
</pre>
<p>The callback function is also easy to manage. There are predefined set of events for each type of control and we can simply make use of these controls by sending various messages to update its state and values. One of the best example is updating the progressbar during the lifetime of messagebox. Once the timer is enabled, the callback function will be automatically fired on discrete time interval. The <a href="http://msdn.microsoft.com/en-us/library/bb760542(v=VS.85).aspx">notify messages are specified in detail in MSDN Documentation. Please check it.</a></p>
<p>To compile this source code, please use latest version of Visual Studio 2010 or any prior version with Windows Vista/7 SDK. You can also use express edition of Visual C++ to try this API.</p>
]]></content:encoded>
			<wfw:commentRss>http://codereflect.com/2010/07/07/windows-7-task-dialog-part-2-a-more-detailed-task-dialog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

