<?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>Visual C++ Tips &#187; Uncategorized</title>
	<atom:link href="http://weseetips.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://weseetips.com</link>
	<description>Gold mine of Visual C++ tricks!</description>
	<lastBuildDate>Thu, 11 Mar 2010 09:09:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Tool Review: CppDepends &#8211; C\C++ Static Analysis Tool</title>
		<link>http://weseetips.com/2010/02/23/tool-review-cppdepends-cc-static-analysis-tool/</link>
		<comments>http://weseetips.com/2010/02/23/tool-review-cppdepends-cc-static-analysis-tool/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 19:04:00 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://weseetips.com/?p=1364</guid>
		<description><![CDATA[I just want to introduce a new tool that I met recently. Its the CppDepends! its a wonderful tool which can do static code analysis and generate lot of metrics. It has got CQL( Code Query Language) by which you can write sql like queries to get code metrics. Have a look at the complete [...]]]></description>
			<content:encoded><![CDATA[<p>I just want to introduce a new tool that I met recently. Its the <a href="http://www.cppdepend.com">CppDepends</a>! its a wonderful tool which can do static code analysis and generate lot of metrics. It has got CQL( Code Query Language) by which you can write sql like queries to get code metrics.</p>
<p><img class="alignnone size-full wp-image-1365" title="CppDepends" src="http://weseetips.com/wp-content/uploads/2010/02/CppDepends.png" alt="" width="523" height="347" /></p>
<p>Have a look at the <a href="http://www.cppdepend.com/Features.aspx">complete feature list</a>. You can download the tool from <a href="http://www.cppdepend.com/CppDependDownload.aspx">here</a>. I think its worth a trial. Try it!</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2010/02/23/tool-review-cppdepends-cc-static-analysis-tool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WeSeeTips Reloaded!!!</title>
		<link>http://weseetips.com/2010/02/07/weseetips-reloaded/</link>
		<comments>http://weseetips.com/2010/02/07/weseetips-reloaded/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 15:57:25 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://weseetips.com/?p=1302</guid>
		<description><![CDATA[Dears Visual C++ Enthusiasts , At last the migration is successfully completed. It was a bit painful though. Encountered a lot of issues, but lucky was able to solve it without much trouble. Now WeSeeTips is back in new style. Enjoy! You have already noticed that for last few months there were hardly any update. [...]]]></description>
			<content:encoded><![CDATA[<p>Dears Visual C++ Enthusiasts ,</p>
<p>At last the migration is successfully completed. It was a bit painful though. Encountered a lot of issues, but lucky was able to solve it without much trouble. Now WeSeeTips is back in new style. Enjoy!</p>
<p><a href="http://weseetips.com/wp-content/uploads/2010/02/StyleChanged.jpg"><img class="alignnone size-full wp-image-1303" title="StyleChanged" src="http://weseetips.com/wp-content/uploads/2010/02/StyleChanged.jpg" alt="" width="500" height="313" /></a></p>
<p>You have already noticed that for last few months there were hardly any update. My sincere apologies to my readers that I was damn busy due to several personal reasons. But I&#8217;ve a chest full of interesting tips to show you. Now enjoy the show!</p>
<p>BTW, what do you think about the new theme? Do you like it? Please don&#8217;t hesitate to write a few lines in comment section. Thanks for your time!</p>
<p>For WeSeeTips,<br />
Jijo.</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2010/02/07/weseetips-reloaded/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>WeSeeTips moving to new Home!</title>
		<link>http://weseetips.com/2010/02/07/weseetips-moving-to-new-home/</link>
		<comments>http://weseetips.com/2010/02/07/weseetips-moving-to-new-home/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 14:53:06 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://weseetips.com/?p=1298</guid>
		<description><![CDATA[Dears, Its been a very long time, I know. But rejoice! WeSeeTips is moving to its new home. Due to several personal and technical reasons, the migration was a bit delayed. Anyway, We will be back soon in new style and new tips to rock you. Keep your fingers crossed! For WeSeeTips, Jijo.]]></description>
			<content:encoded><![CDATA[<p>Dears,</p>
<p>Its been a very long time, I know. But rejoice! WeSeeTips is moving to its new home. Due to several personal and technical reasons, the migration was a bit delayed. Anyway, We will be back soon in new style and new tips to rock you. Keep your fingers crossed!</p>
<p><a href="http://weseetips.files.wordpress.com/2010/01/packing.jpg"><img class="alignnone size-full wp-image-1253" title="Packing" src="http://weseetips.files.wordpress.com/2010/01/packing.jpg" alt="" width="448" height="295" /></a></p>
<p>For WeSeeTips,<br />
Jijo.</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2010/02/07/weseetips-moving-to-new-home/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get the CPU Name String?</title>
		<link>http://weseetips.com/2009/06/21/how-to-get-the-cpu-name-string/</link>
		<comments>http://weseetips.com/2009/06/21/how-to-get-the-cpu-name-string/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 18:29:49 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Visual C++]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[C++ cpu name]]></category>
		<category><![CDATA[c++ get cpu name]]></category>
		<category><![CDATA[C++ get processor name]]></category>
		<category><![CDATA[CPU brand string]]></category>
		<category><![CDATA[cpu name]]></category>
		<category><![CDATA[Cpu name string]]></category>
		<category><![CDATA[get Cpu name]]></category>
		<category><![CDATA[get processor name]]></category>
		<category><![CDATA[intrin.h]]></category>
		<category><![CDATA[processor name]]></category>
		<category><![CDATA[VC++]]></category>
		<category><![CDATA[VC++ cpu name]]></category>
		<category><![CDATA[VC++ get cpu name]]></category>
		<category><![CDATA[VC++ get processor name]]></category>
		<category><![CDATA[__cpuid]]></category>

		<guid isPermaLink="false">http://weseetips.com/?p=1163</guid>
		<description><![CDATA[While taking the System properties, you have noticed the processor name string. For instance, in my laptop it is &#8211; &#8220;Intel(R) Core(TM)2 Duo CPU T5250 @ 1.50GHz&#8220;. Ever though about how to get this processor name string? Image Courtesy &#8211; Wallpaper Mania. You can use the function &#8211; __cpuid(), which generates the instruction &#8211; cpuid. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-11" title="Icon Description" src="http://weseetips.wordpress.com/files/2008/03/icon_description.jpg?w=166" alt="" width="166" height="32" /></p>
<p>While taking the System properties, you have noticed the processor name string. For instance, in my laptop it is &#8211; &#8220;<span style="color: #0000ff;">Intel(R) Core(TM)2 Duo CPU     T5250  @ 1.50GHz</span>&#8220;. Ever though about <span style="color: #0000ff;">how to get this processor name string</span>?</p>
<p><img class="alignnone size-full wp-image-1166" title="cpuid" src="http://weseetips.wordpress.com/files/2009/06/cpuid.jpg" alt="cpuid" width="400" height="300" /></p>
<p>Image Courtesy &#8211; <a href="http://piczzmania.blogspot.com/">Wallpaper Mania</a>.</p>
<p><img class="alignnone size-medium wp-image-12" title="Icon How Can I Do It?" src="http://weseetips.wordpress.com/files/2008/03/icon_howcanidoit.jpg?w=220" alt="" width="220" height="32" /></p>
<p>You can use the function &#8211; <span style="color: #0000ff;"><strong>__cpuid()</strong></span>, which generates the instruction &#8211; cpuid. Have a look at the code snippet. Code taken and modified from MSDN.</p>
<pre>#include &lt;iostream&gt;
#include &lt;intrin.h&gt;

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    // Get extended ids.
    int CPUInfo[4] = {-1};
    __cpuid(CPUInfo, 0x80000000);
    unsigned int nExIds = CPUInfo[0];

    // Get the information associated with each extended ID.
    char CPUBrandString[0x40] = { 0 };
    for( unsigned int i=0x80000000; i&lt;=nExIds; ++i)
    {
        __cpuid(CPUInfo, i);

        // Interpret CPU brand string and cache information.
        if  (i == 0x80000002)
        {
            memcpy( CPUBrandString,
            CPUInfo,
            sizeof(CPUInfo));
        }
        else if( i == 0x80000003 )
        {
            memcpy( CPUBrandString + 16,
            CPUInfo,
            sizeof(CPUInfo));
        }
        else if( i == 0x80000004 )
        {
            memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo));
        }
}

    cout &lt;&lt; "Cpu String: " &lt;&lt; CPUBrandString;
}</pre>
<p><img class="alignnone size-medium wp-image-18" title="Icon Note" src="http://weseetips.wordpress.com/files/2008/03/icon_note.jpg?w=94" alt="" width="94" height="32" /><br />
You can get a lot of information about cpu by using __cpuid. Have a look at the <a href="http://msdn.microsoft.com/en-us/library/hskdteyh(VS.80).aspx">MSDN Documentation</a>.</p>
<p><img class="alignnone size-medium wp-image-53" title="intermediateseries" src="http://weseetips.wordpress.com/files/2008/03/intermediateseries.jpg?w=248" alt="" width="248" height="32" /><br />
Targeted Audiance &#8211; Intermeidate.</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2009/06/21/how-to-get-the-cpu-name-string/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to Change the Display Orientation?</title>
		<link>http://weseetips.com/2009/05/10/how-to-change-the-display-orientation/</link>
		<comments>http://weseetips.com/2009/05/10/how-to-change-the-display-orientation/#comments</comments>
		<pubDate>Sun, 10 May 2009 16:42:24 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[change display orientation]]></category>
		<category><![CDATA[change screen orientation]]></category>
		<category><![CDATA[ChangeDisplaySettings()]]></category>
		<category><![CDATA[DEVMODE]]></category>
		<category><![CDATA[DEVMODE.dmDisplayOrientation]]></category>
		<category><![CDATA[dmDisplayOrientation]]></category>
		<category><![CDATA[EnumDisplaySettings()]]></category>
		<category><![CDATA[VC++]]></category>
		<category><![CDATA[Visual C++]]></category>

		<guid isPermaLink="false">http://weseetips.com/?p=1154</guid>
		<description><![CDATA[Are you using Windows XP? Press Ctrl+Atl+DownArrow, and then Ctrl+Atl+UpArrow. The screen changes its orientation upside down. isn&#8217;t it? But how to turn the screen, upside down programmatically? Image Courtesy &#8211; marieforleo.com Get the current DEVMODE by calling -EnumDisplaySettings(). Then change orientation by setting DEVMODE.dmDisplayOrientation and calling ChangeDisplaySettings(). Have a look at the code snippet. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-11" title="Icon Description" src="http://weseetips.files.wordpress.com/2008/03/icon_description.jpg?w=166" alt="" width="166" height="32" /><br />
Are you using Windows XP? Press <span style="color:#0000ff;">Ctrl+Atl+DownArrow</span>, and then <span style="color:#0000ff;">Ctrl+Atl+UpArrow</span>. The screen changes its orientation upside down. isn&#8217;t it? But how to <span style="text-decoration:underline;"><strong>turn </strong><strong>the screen, upside down</strong></span> programmatically?</p>
<p><img class="alignnone size-full wp-image-1155" title="ChangeDisplayOrientation" src="http://siteground205.com/~weseetip/wp-content/uploads/2009/05/changedisplayorientation.jpg" alt="ChangeDisplayOrientation" width="510" height="340" /><br />
Image Courtesy &#8211; <a href="http://marieforleo.com" target="_blank">marieforleo.com</a></p>
<p><img class="alignnone size-medium wp-image-12" title="Icon How Can I Do It?" src="http://weseetips.files.wordpress.com/2008/03/icon_howcanidoit.jpg?w=220" alt="" width="220" height="32" /><br />
Get the<span style="color:#0000ff;"> current DEVMODE</span> by calling -<span style="color:#0000ff;">EnumDisplaySettings()</span>. Then change orientation by setting <span style="color:#0000ff;">DEVMODE.dmDisplayOrientation</span> and calling <span style="color:#0000ff;">ChangeDisplaySettings()</span>. Have a look at the code snippet. Code taken from MSDN.</p>
<pre>// Get current Device Mode.
DEVMODE DeviceMode = { 0 };
EnumDisplaySettings( NULL,
 ENUM_CURRENT_SETTINGS,
 &amp;DeviceMode );

// Change display mode upside down.
DeviceMode.dmDisplayOrientation = DMDO_180;
ChangeDisplaySettings( &amp;DeviceMode, 0 );

// Sleep for 10 seconds.
Sleep( 10000 );

// Change display mode back.
DeviceMode.dmDisplayOrientation = DMDO_DEFAULT;
ChangeDisplaySettings( &amp;DeviceMode, 0 );</pre>
<p><img class="alignnone size-medium wp-image-18" title="Icon Note" src="http://weseetips.files.wordpress.com/2008/03/icon_note.jpg?w=94" alt="" width="94" height="32" /><br />
Be careful to restore the display orientation back. Or else <img src='http://weseetips.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><img class="alignnone size-medium wp-image-53" title="intermediateseries" src="http://weseetips.files.wordpress.com/2008/03/intermediateseries.jpg?w=248" alt="" width="248" height="32" /><br />
Targeted Audiance &#8211; Intermeidate.</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2009/05/10/how-to-change-the-display-orientation/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to Parse Virtual Table?</title>
		<link>http://weseetips.com/2009/05/07/how-to-parse-virtual-table/</link>
		<comments>http://weseetips.com/2009/05/07/how-to-parse-virtual-table/#comments</comments>
		<pubDate>Thu, 07 May 2009 16:47:06 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C++ virtual functions]]></category>
		<category><![CDATA[C++ virtual table]]></category>
		<category><![CDATA[parse virtual table]]></category>
		<category><![CDATA[virtual function]]></category>
		<category><![CDATA[virtual table]]></category>
		<category><![CDATA[virtual table parsing]]></category>
		<category><![CDATA[virtual table under the hood]]></category>
		<category><![CDATA[vtable]]></category>
		<category><![CDATA[vtable under the hood]]></category>
		<category><![CDATA[vtbl]]></category>

		<guid isPermaLink="false">http://weseetips.com/?p=1146</guid>
		<description><![CDATA[Virtual Table is one of the most fascinating stuff for C++ programmer. Well, did you ever peek into virtual table, which is the real engine of virtual functions? The first 4 bytes of an objects points to another pointer which points to virtual table. Casting it to DWORD*, we can parse all virtual functions. Once [...]]]></description>
			<content:encoded><![CDATA[<p>Virtual Table is one of the most fascinating stuff for C++ programmer. Well, did you ever  peek into virtual table, which is the <span style="color: #0000ff;"><strong>real engine </strong></span>of virtual functions?</p>
<p><img class="alignnone size-full wp-image-1147" title="virtualfunction" src="http://weseetips.wordpress.com/files/2009/05/virtualfunction.jpg" alt="virtualfunction" width="510" height="351" /></p>
<p><img class="alignnone size-medium wp-image-12" title="Icon How Can I Do It?" src="http://weseetips.wordpress.com/files/2008/03/icon_howcanidoit.jpg?w=220" alt="" width="220" height="32" /><br />
The <span style="color: #0000ff;">first 4 bytes of an objects points to another pointer which points to virtual table.</span> Casting it to DWORD*, we can parse all virtual functions. Once you get function address, you can get the function name by calling &#8211; <span style="color: #0000ff;">SymFromAddr()</span>. Have a look at code snippet.</p>
<p><img class="alignnone size-full wp-image-1148" title="virtualfunction2" src="http://weseetips.wordpress.com/files/2009/05/virtualfunction2.jpg" alt="virtualfunction2" width="493" height="290" /></p>
<pre>#include &lt;ImageHlp.h&gt;
...
// Get list of virtual functions.
void CRabbitDlg::ParseVtable()
{
    // Initialize symbols.
    InitializeSymbols();

    // We are going to parse vtable of CWinApp object.
    DWORD* pBase = (DWORD*)(AfxGetApp());
    DWORD* pVptr = (DWORD*)*pBase;

    // Iterate through VirtualTable.
    DWORD Index = 0;
    DWORD FnAddr = pVptr[Index];
    while( FnAddr )
    {
        // Translate FunctionAddress to FunctionName.
        CString FunctionName;
        GetSymbolNameFromAddr( FnAddr, FunctionName );

        // Format and add to list.
        CString Final;
        Final.Format( _T("%0x - %s"), FnAddr, FunctionName.operator LPCTSTR());
        m_List.AddString( Final );

        // Next function pointer.
        FnAddr = pVptr[++Index];
    }
}

// Initialize Symbol engine.
void CRabbitDlg::InitializeSymbols()
{
    DWORD Options = SymGetOptions();
    Options |= SYMOPT_DEBUG;
    Options |= SYMOPT_UNDNAME; 

    ::SymSetOptions( Options ); 

    // Initialize symbols.
    ::SymInitialize ( GetCurrentProcess(),
                      NULL,
                      TRUE );
}

// Get symbol name from address.
void CRabbitDlg::GetSymbolNameFromAddr( DWORD SymbolAddress, CString&amp; csSymbolName )
{
    DWORD64 Displacement = 0;
    SYMBOL_INFO_PACKAGE SymbolInfo = {0};
    SymbolInfo.si.SizeOfStruct  = sizeof( SYMBOL_INFO );
    SymbolInfo.si.MaxNameLen = sizeof(SymbolInfo.name);

    // Get symbol from address.
    ::SymFromAddr( GetCurrentProcess(),
                   SymbolAddress,
                   &amp;Displacement,
                   &amp;SymbolInfo.si );

    csSymbolName = SymbolInfo.si.Name;
}</pre>
<p><img class="alignnone size-medium wp-image-18" title="Icon Note" src="http://weseetips.wordpress.com/files/2008/03/icon_note.jpg?w=94" alt="" width="94" height="32" /><br />
Don&#8217;t forget to include <span style="color: #0000ff;">ImageHlp.lib </span>to project settings.</p>
<p><img class="alignnone size-medium wp-image-53" title="intermediateseries" src="http://weseetips.wordpress.com/files/2008/03/intermediateseries.jpg?w=248" alt="" width="248" height="32" /><br />
Targeted Audiance &#8211; Intermediate.</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2009/05/07/how-to-parse-virtual-table/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>How to set Font for Static Text Controls?</title>
		<link>http://weseetips.com/2009/03/04/how-to-set-font-for-static-text-controls/</link>
		<comments>http://weseetips.com/2009/03/04/how-to-set-font-for-static-text-controls/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 17:57:04 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Codeproject]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Visual C++]]></category>
		<category><![CDATA[CFont]]></category>
		<category><![CDATA[CFont::CreateFontIndirect()]]></category>
		<category><![CDATA[change dialog font]]></category>
		<category><![CDATA[change static font]]></category>
		<category><![CDATA[change static text font]]></category>
		<category><![CDATA[CWnd::GetFont()]]></category>
		<category><![CDATA[CWnd::SetFont()]]></category>
		<category><![CDATA[LOGFONT]]></category>
		<category><![CDATA[static font]]></category>

		<guid isPermaLink="false">http://weseetips.com/?p=894</guid>
		<description><![CDATA[By default, static text is displayed in normal fonts. And you don&#8217;t have any option to make it bold or italic or underline. Is there any way to enable these styles and change the font of the static text control? Yes! you can do it. First you&#8217;ve to get the current font of the text [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-11" title="Icon Description" src="http://weseetips.files.wordpress.com/2008/03/icon_description.jpg?w=166" alt="" width="166" height="32" /><br />
<span style="color:#0000ff;"> By default, static text is displayed in normal fonts</span>. And you don&#8217;t have any option to make it bold or italic or underline. <span style="color:#0000ff;">Is there any way to </span>enable these styles and <span style="color:#0000ff;">change the font of the static text control?</span></p>
<p><img class="alignnone size-full wp-image-900" title="staticfont" src="http://siteground205.com/~weseetip/wp-content/uploads/2009/03/staticfont.gif" alt="staticfont" width="500" height="262" /></p>
<p><img class="alignnone size-medium wp-image-12" title="Icon How Can I Do It?" src="http://weseetips.files.wordpress.com/2008/03/icon_howcanidoit.jpg?w=220" alt="" width="220" height="32" /><br />
Yes! you can do it. First you&#8217;ve to <span style="color:#0000ff;">get the current font of the text control</span> and then <span style="color:#0000ff;">enable the styles you need </span>then <span style="color:#0000ff;">set it back.</span> Setting font is done in OnInitDialog() and new font is kept as member variable. See the code snippet below.</p>
<pre>BOOL CStaticFontDlg::OnInitDialog()
{
	...

    // Get current font.
    CFont* pFont = GetDlgItem( IDC_STATIC_ITALIC )-&gt;GetFont();
    LOGFONT LogFont = { 0 };
    pFont-&gt;GetLogFont( &amp;LogFont );

    // Create new font with underline style.
    LogFont.lfUnderline = TRUE;
    m_StaticFont.CreateFontIndirect( &amp;LogFont );

	// Sets the new font back to static text.
    GetDlgItem( IDC_STATIC_ITALIC )-&gt;SetFont( &amp;m_StaticFont );

	return TRUE;
}</pre>
<p>Now the static text will look like this.</p>
<p><img class="alignnone size-full wp-image-904" title="staticfont3" src="http://siteground205.com/~weseetip/wp-content/uploads/2009/03/staticfont3.jpg" alt="staticfont3" width="301" height="161" /></p>
<p><img class="alignnone size-medium wp-image-18" title="Icon Note" src="http://weseetips.files.wordpress.com/2008/03/icon_note.jpg?w=94" alt="" width="94" height="32" /><br />
<span style="color:#0000ff;">Don&#8217;t forget to change the Id of static text control from IDC_STATIC to something else.</span> Or else GetDlgItem() will return invalid handle.</p>
<p><img class="alignnone size-medium wp-image-53" title="intermediateseries" src="http://weseetips.files.wordpress.com/2008/03/intermediateseries.jpg?w=248" alt="" width="248" height="32" /><br />
Targeted Audiance &#8211; Intermediate.</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2009/03/04/how-to-set-font-for-static-text-controls/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to restrict the tree control labels to be integer?</title>
		<link>http://weseetips.com/2009/01/18/how-to-restrict-the-tree-control-labels-to-be-integer/</link>
		<comments>http://weseetips.com/2009/01/18/how-to-restrict-the-tree-control-labels-to-be-integer/#comments</comments>
		<pubDate>Sun, 18 Jan 2009 20:40:09 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Codeproject]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CTreeCtrl GetEditControl()]]></category>
		<category><![CDATA[CTreeCtrl label int]]></category>
		<category><![CDATA[ES_NUMBER]]></category>
		<category><![CDATA[GetEditControl()]]></category>
		<category><![CDATA[ModifyStyle()]]></category>
		<category><![CDATA[OnBeginlabeleditTreectrl()]]></category>
		<category><![CDATA[restrict tree control label as int]]></category>
		<category><![CDATA[tree control label edit]]></category>
		<category><![CDATA[tree control label integer]]></category>
		<category><![CDATA[tree label as int]]></category>
		<category><![CDATA[TVN_BEGINLABELEDIT]]></category>

		<guid isPermaLink="false">http://weseetips.com/?p=858</guid>
		<description><![CDATA[Tree Controls supports label editing and by default it accepts all kind of chars for label. But is there any trick to restrict the input label to be an integer? Yes. You can. When user starts editing tree control will send a notification message - TVN_BEGINLABELEDIT. At first you have to handle the message and [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-11" title="Icon Description" src="http://weseetips.files.wordpress.com/2008/03/icon_description.jpg?w=166" alt="" width="166" height="32" /><br />
Tree Controls supports label editing and by default it accepts all kind of chars for label. <span style="color:#0000ff;">But is there any trick to restrict the input label to be an integer?</span></p>
<p><img class="alignnone size-full wp-image-860" title="limittreeinputasint" src="http://siteground205.com/~weseetip/wp-content/uploads/2009/01/limittreeinputasint.jpg" alt="limittreeinputasint" width="334" height="500" /></p>
<p><img class="alignnone size-medium wp-image-12" title="Icon How Can I Do It?" src="http://weseetips.files.wordpress.com/2008/03/icon_howcanidoit.jpg?w=220" alt="" width="220" height="32" /><br />
Yes. You can. When user starts editing tree control will send a notification message -<span style="color:#0000ff;"> TVN_BEGINLABELEDIT</span>. At first you have to <span style="color:#0000ff;">handle the message </span>and in the message handler, you can <span style="color:#0000ff;">get the label edit control by calling GetEditControl()</span>. Then set the edit control style to ES_NUMBER. Then the label edit control of tree, will allow only integers as input. Have a look at the code snippet.</p>
<pre>// Message Map.
BEGIN_MESSAGE_MAP(CRabbitDlg, CDialog)
	...
	ON_NOTIFY(TVN_BEGINLABELEDIT, IDC_TREECTRL, OnBeginlabeleditTreectrl)
END_MESSAGE_MAP()

// Begin Label edit - Message Handler.
void CRabbitDlg::OnBeginlabeleditTreectrl(NMHDR* pNMHDR,
					  LRESULT* pResult)
{
    // Get the edit control which of tree control and set
    // its style to number only.
    CEdit* pEdit = m_TreeCtrl.GetEditControl();
    if( pEdit )
    {
        // Allow only numbers
        pEdit-&gt;ModifyStyle( 0, ES_NUMBER );
    }

    *pResult = 0;
}</pre>
<p><img class="alignnone size-medium wp-image-18" title="Icon Note" src="http://weseetips.files.wordpress.com/2008/03/icon_note.jpg?w=94" alt="" width="94" height="32" /><br />
Feel the power!</p>
<p><img class="alignnone size-medium wp-image-53" title="intermediateseries" src="http://weseetips.files.wordpress.com/2008/03/intermediateseries.jpg?w=248" alt="" width="248" height="32" /><br />
Targeted Audience &#8211; Intermediate.</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2009/01/18/how-to-restrict-the-tree-control-labels-to-be-integer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to check whether the Pointer is allocated in Stack or Heap in Debug?</title>
		<link>http://weseetips.com/2008/12/14/how-to-check-whether-the-pointer-is-allocated-in-stack-or-heap-in-debug/</link>
		<comments>http://weseetips.com/2008/12/14/how-to-check-whether-the-pointer-is-allocated-in-stack-or-heap-in-debug/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 18:06:55 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[in heap or stack]]></category>
		<category><![CDATA[memory allocation in heap or stack]]></category>
		<category><![CDATA[pointer in heap]]></category>
		<category><![CDATA[pointer in stack]]></category>
		<category><![CDATA[_CrtIsValidHeapPointer()]]></category>

		<guid isPermaLink="false">http://weseetips.com/?p=702</guid>
		<description><![CDATA[What if you call delete operator by using a stack pointer? Like that, while writing frameworks sometimes we expects the pointer that gets passed to the function should point a valid memory block which is allocated on heap itself. So how can we check whether the pointer points to stack or heap in debug version? [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-11" title="Icon Description" src="http://weseetips.files.wordpress.com/2008/03/icon_description.jpg?w=166" alt="" width="166" height="32" /><br />
What if you call delete operator by using a stack pointer? Like that, while writing frameworks sometimes we expects the pointer that gets passed to the function should point a valid memory block which is allocated on heap itself. So <span style="color:#0000ff;">how can we check whether the pointer points to stack or heap in debug version</span>?</p>
<p><img class="alignnone size-full wp-image-703" title="stackorheap" src="http://siteground205.com/~weseetip/wp-content/uploads/2008/12/stackorheap.jpg" alt="stackorheap" width="479" height="284" /></p>
<p><img class="alignnone size-medium wp-image-12" title="Icon How Can I Do It?" src="http://weseetips.files.wordpress.com/2008/03/icon_howcanidoit.jpg?w=220" alt="" width="220" height="32" /><br />
You can use the function &#8211; <span style="color:#0000ff;">_CrtIsValidHeapPointer()</span>. Its an undocumented CRT function. But it <strong><span style="color:#0000ff;">works only in debug version</span></strong>. Well, please check the code snippet below,</p>
<pre>#include "malloc.h"
...

// Check heap pointer.
int* pInteger = new int;
BOOL bHeap = _CrtIsValidHeapPointer( pInteger );

// Check stack pointer and you'll get an assertion.
char CharArray[100];
bHeap = _CrtIsValidHeapPointer( CharArray );</pre>
<p><img class="alignnone size-medium wp-image-18" title="Icon Note" src="http://weseetips.files.wordpress.com/2008/03/icon_note.jpg?w=94" alt="" width="94" height="32" /><br />
Its annoying that its not available in release version. Well, atleast we could make our framework to notify the user while debugging in the debug build. isn&#8217;t it?</p>
<p><img class="alignnone size-medium wp-image-51" title="beginnerseries" src="http://weseetips.files.wordpress.com/2008/03/beginnerseries.jpg?w=215" alt="" width="215" height="32" /><br />
Targeted Audience &#8211; Beginners.</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2008/12/14/how-to-check-whether-the-pointer-is-allocated-in-stack-or-heap-in-debug/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Watch byte streams in Memory Window more easily.</title>
		<link>http://weseetips.com/2008/11/13/watch-byte-streams-in-memory-window-more-easily/</link>
		<comments>http://weseetips.com/2008/11/13/watch-byte-streams-in-memory-window-more-easily/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 21:09:45 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Codeproject]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[byte stream]]></category>
		<category><![CDATA[memory layout]]></category>
		<category><![CDATA[memory window]]></category>
		<category><![CDATA[visual studio memory window]]></category>
		<category><![CDATA[watch byte stream]]></category>

		<guid isPermaLink="false">http://weseetips.wordpress.com/?p=573</guid>
		<description><![CDATA[Assembly programming! It fascinates me always. I love sending packets of data to hardware, parsing back the replies, etc. You might be using BYTE arrays for doing such stuffs. well, in that case, instead of watch window, memory window is preferable to see the byte stream, because it will be so easy to see the [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-11" title="Icon Description" src="http://weseetips.files.wordpress.com/2008/03/icon_description.jpg?w=166" alt="" width="166" height="32" /><br />
<span style="color:#0000ff;">Assembly programming!</span> It <span style="color:#0000ff;">fascinates me </span>always. I love <span style="color:#0000ff;">sending packets of data</span> to hardware, <span style="color:#0000ff;">parsing back the replies</span>, etc. You might be <span style="color:#0000ff;">using BYTE arrays</span> for <span style="color:#0000ff;">doing such stuffs</span>. well, in that case, <span style="color:#0000ff;">instead of watch window</span>, <span style="color:#0000ff;">memory window is preferable</span> to <span style="color:#0000ff;">see the byte stream</span>, because it will be <span style="color:#0000ff;">so easy</span> to see the entire message.</p>
<p>For instance, <span style="color:#0000ff;">assume </span>that we need to send a <span style="color:#888888;"><span style="color:#0000ff;">packet of data</span> </span>in <span style="color:#0000ff;">following format</span>.<br />
<img class="alignnone size-full wp-image-576" title="memorywindow1" src="http://siteground205.com/~weseetip/wp-content/uploads/2008/11/memorywindow1.jpg" alt="memorywindow1" width="445" height="71" /></p>
<p>Following <span style="color:#0000ff;">code snippet generates similar array</span>. Ofcourse in <span style="color:#0000ff;"><strong>legacy coding style.</strong></span></p>
<pre>// Data packet.
const int DATA_PACKET_LEN = 12;
BYTE DataPacket[DATA_PACKET_LEN] = { 0 };

int Index = 0;

// Add the first DWORD.
DataPacket[Index] = 1;
Index += sizeof( DWORD );

// Add the second WORD.
DataPacket[Index] = 2;
Index += sizeof( WORD );

// Add the third WORD.
DataPacket[Index] = 3;
Index += sizeof( WORD );

// Add the forth DWORD.
DataPacket[Index] = 4;
Index += sizeof( DWORD );</pre>
<p>If you <span style="color:#0000ff;">watch DataPacket in memory window</span>, it will look like this.<br />
<img class="alignnone size-full wp-image-580" title="memorywindow2" src="http://siteground205.com/~weseetip/wp-content/uploads/2008/11/memorywindow2.jpg" alt="memorywindow2" width="435" height="312" /><br />
A chunk of bytes. It <span style="color:#0000ff;">seems hard to read and interpret values</span>. isn&#8217;t it? More over that, <span style="color:#0000ff;">in intel machines</span>, the <span style="color:#0000ff;">values are stored in LSB format</span> which <span style="color:#0000ff;">makes the readability</span> even <span style="color:#0000ff;">more worse</span>. well is there any trick which helps to read the format even better.</p>
<p><img class="alignnone size-medium wp-image-12" title="Icon How Can I Do It?" src="http://weseetips.files.wordpress.com/2008/03/icon_howcanidoit.jpg?w=220" alt="" width="220" height="32" /><br />
If you <span style="color:#0000ff;">right click </span>in the <span style="color:#0000ff;">Memory window,</span> you&#8217;ll get the <span style="color:#0000ff;">context menu </span>and in that you can <span style="color:#0000ff;">select </span>the <span style="color:#0000ff;">preferred byte ordering</span>.<br />
<img class="alignnone size-full wp-image-583" title="memorywindow3" src="http://siteground205.com/~weseetip/wp-content/uploads/2008/11/memorywindow3.jpg" alt="memorywindow3" width="441" height="321" /></p>
<p>Select <span style="color:#0000ff;">&#8220;Long Hex Format&#8221;</span> to group bytes as <span style="color:#0000ff;">DWORDs</span>. Well, <span style="color:#0000ff;">now you can read the byte stream</span>, <span style="color:#0000ff;">as such in the packet format picture.</span> cool! isn&#8217;t it?<br />
<img class="alignnone size-full wp-image-584" title="memorywindow4" src="http://siteground205.com/~weseetip/wp-content/uploads/2008/11/memorywindow4.jpg" alt="memorywindow4" width="448" height="321" /></p>
<p><img class="alignnone size-medium wp-image-18" title="Icon Note" src="http://weseetips.files.wordpress.com/2008/03/icon_note.jpg?w=94" alt="" width="94" height="32" /><br />
Yes! i know. <span style="color:#0000ff;">You&#8217;re thinking about this</span> &#8211; the <span style="color:#0000ff;">second and third parameter</span> get <span style="color:#0000ff;">swapped</span>. Well, its due to the fact that <span style="color:#0000ff;">Intel machines follows LSB layout</span> for storing values in memory. This is not perfect solution but <span style="color:#0000ff;">it does make life easier</span> and having something is better than nothing! isn&#8217;t it? <img src='http://weseetips.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><img class="alignnone size-medium wp-image-53" title="intermediateseries" src="http://weseetips.files.wordpress.com/2008/03/intermediateseries.jpg?w=248" alt="" width="248" height="32" /><br />
Targeted Audience &#8211; Intermediate.</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2008/11/13/watch-byte-streams-in-memory-window-more-easily/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

