A Control like IE 4's Favorites/History/Channels View

Everyone knows the new menu-like left pane view's in IE4. But did you know that this is only a extended TreeView? You can do this by using CUSTONDRAW notification in the new from CTreeCtrl derived class. I called it CTreeMenu. To do this is quite easy. See an code extract below.
But note: This works only with the extended TreeCtrl that comes with IE4. You can use my wrapper class or the one from Luis Barreira IE4 Classes. This should also work, but I didn't test it. Also on Codeguru's Webpage.

I wrote a class, that makes the handling pretty easy. Included are a Button to close the view and some Bevel stuff to be uptodate with the Windows style. There is also a self RegisterClass() function to use as a CustomControl on Dialog Templates.

The Frame use the SizingControlBar from Cristi Posea also found here on Codeguru's Webpage.

See more details in code comments.

void CTreeMenu::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult) 
{

	NMTVCUSTOMDRAW *pTVCD = (NMTVCUSTOMDRAW*)pNMHDR;
	
	CDC* pDC = CDC::FromHandle(pTVCD->nmcd.hdc);

	// The rect for the cell gives correct left and right values
	CRect rect = pTVCD->nmcd.rc;
	
	// By default set the return value to do the default behavior
	*pResult = 0;

	
	switch( pTVCD->nmcd.dwDrawStage )
		{
		// First stage (for the whole control
		case  CDDS_PREPAINT: 
			{		
				*pResult = CDRF_NOTIFYITEMDRAW;
			}
			break;

		// Stage three (called for each subitem of the focused item
		case CDDS_ITEMPREPAINT | CDDS_SUBITEM: 
			{
				*pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NOTIFYPOSTPAINT;
			}
			break;

		// Stage four (called for each subitem of the focused item
		case CDDS_ITEMPOSTPAINT | CDDS_SUBITEM: 
			{
				*pResult = CDRF_SKIPDEFAULT;	
			}
			break;
		
		default: 
			// Stage two handled here. (called for each item
			if (pTVCD->nmcd.uItemState & CDIS_HOT)
			{
				pDC->Draw3dRect( &rect, m_clr3DHilight, m_clr3DShadow );
				pDC->SetBkColor(GetBkColor());
				pDC->SetTextColor(RGB(0,0,255));
	
				// Tell the control that to draw it again
				*pResult = CDRF_NOTIFYPOSTPAINT;

			}

			if (pTVCD->nmcd.uItemState & CDIS_SELECTED)
			{
				*pResult = CDRF_SKIPDEFAULT;
			}

			if( (pTVCD->nmcd.uItemState & CDIS_FOCUS) )
			{
				pDC->Draw3dRect( &rect, m_clr3DShadow, m_clr3DHilight );
				pDC->SetBkColor(m_clrSelBkColor);
				pDC->SetTextColor(m_clrSelTextColor);
	
				*pResult = CDRF_NOTIFYPOSTPAINT;
			}	
			
			if( (pTVCD->nmcd.uItemState & CDIS_CHECKED) )
			{
				*pResult = CDRF_DODEFAULT;
			}	
			
			break;
		}
}

Download demo - 70KB

P.S: Did everyone has successfull experienced with the new pager control (see latest "commctrl.h"), please send a notice to Rainer Pfitzner

Date Posted: 05/13/98



Comments

  • The most important bvlgari purse Business venture Speak - - Visitors who cares about stress triumphs?!?

    Posted by expopmerm on 03/22/2013 08:30pm

    Brand new questions regarding bvlgari purse replied and consequently the reasons you have got to study every message in this guide. [url=http://www.bvlgarishopjprie.com]ブルガリ[/url] The greatest key for bvlgari purse that you will understand more about straight away. [url=http://www.bvlgarioutletshopjp.com]ブルガリ 時計[/url] Heya- All together we could help make bvlgari purse a lot better ! [url=http://www.bvlgarisalekodojp.com]ブルガリ店舗[/url] Everything that the competition actually does concerning bvlgari purse and moreover specifically what you want to do different. [url=http://www.bvlgarisakaijpsale.com]ブルガリブルガリ[/url] bvlgari purse Knockoffs -- The Most Beneficial bvlgari purse hack Regarding Fools 98% of the end-users [url=http://www.bvlgariaokisalejp.com]ブルガリブルガリ[/url] Your own double turn on bvlgari purse mcm Teaches You Different Verbiage . . . Our Company Step Into The Proceeding [url=http://www.mcmbagsjphadori.com]MCM 店舗[/url] The Things Everyone Seems To Be Reporting About mcm Is In Fact Dead Wrong And Reason Why [url=http://www.mcmstorejpkodo.com]mcm[/url] mcm Fakes . . . Wonderful mcm Hack Regarding Fools 87.5% Of The Buyers [url=http://www.mcmoutletjpinoue.com]mcm 店舗[/url] mcm Brings All New Life To The Old Matter-- Defacto Popular [url=http://www.mcmsalejapanoka.com]MCM 財布[/url] The Best Way To Earn Money From Home Using mcm [url=http://www.mcmzankijpshop.com]mcm バッグ[/url] Ways To Steer Clear Of mcm Troubles

    Reply
  • Just stop Protesting And Commence your personal nike shoes Marketing plan Instead

    Posted by expopmerm on 03/18/2013 01:54am

    Rare post gives the main points around adidas shoes which experts state a few personsare conscious of.|Brief guide demonstrates to you all the cogs and wheels on nike shoes and also those things that you ought to do this afternoon.}[url=http://www.nikejapan.asia/]ナイキ air [/url] Specifically how to master all that there is to find around nike shoes in five basic steps. [url=http://www.adidasjapan.biz/]adidas シューズ[/url] Info- adidas shoes Will certainly Have An Important role In Virtually Any Site administration Update: gucci Can Have Major role In Virtually Any Website administration [url=http://www.guccijp.asia/]gucci 財布[/url] New chloe Book Will show Guidelines On How To Rule The chloe Marketplace [url=http://www.chloejp.biz/]クロエ 財布[/url] 8 carefully-protected chanel tricks explained in clear detail. [url=http://www.chaneljp.biz/]シャネル バッグ[/url] Tips to find out all sorts of things there is to understand regarding chanel in 3 rather simple steps.A Slack Guy's Process To The nike shoes Triumph [url=http://www.adidasjapan.asia/]アディダス シューズ[/url] The things that all the others does in regard to adidas shoes and moreover something that you are looking to do different. [url=http://www.nikejp.biz/]nike running[/url] Strategies about how to learn pretty much everything there is to find concerning nike shoes in 5 basic steps.

    Reply
  • How to change 16-color Icons into truecolor

    Posted by Legacy on 04/27/2003 12:00am

    Originally posted by: Jack

    How to change 16-color Icons into truecolor?
    use SetImageList only allow to use 16-color bitmap.

    Reply
  • How to place two sidepanes in the same column?

    Posted by Legacy on 09/18/2002 12:00am

    Originally posted by: Min Tang

    It is very good and the the very thing I was looking for, but I still have problem on it needing help.
    That is, I want to place the second sidepane to the bottom of the first one, but I found I can't. The second sidepane is always on the left side of the first one. How to solve this problem? Thank you very much!

    Reply
  • Changes for debug version

    Posted by Legacy on 09/04/2002 12:00am

    Originally posted by: eflame

    // sizecbar.h
    class CSizingControlBar : public CControlBar
    {...
    virtual BOOL Create(CWnd* pParentWnd,sizeDefault, UINT nID, DWORD dwStyle = CBRS_TOP);
    ...
    }

    // sizecbar.cpp
    BOOL CSizingControlBar::Create(CWnd* pParentWnd, CSize sizeDefault, UINT nID, DWORD dwStyle)
    {
    ...
    dwStyle |= CCS_NOMOVEY|CCS_NODIVIDER|CCS_NORESIZE|WS_CHILD|WS_VISIBLE;
    ...
    }


    Reply
  • Error

    Posted by Legacy on 08/28/2002 12:00am

    Originally posted by: hongky

    !!!!Memery Error!!!!

    Reply
  • 干得不错,伙计~~~

    Posted by Legacy on 03/10/2002 12:00am

    Originally posted by: 麟麟

    辛苦辛苦,值得表扬。
    
    建议中国人在此就说中国话吧,呵呵,
    发扬国语。
    也可以加英文注释。

    Reply
  • Windows2000 is not play..

    Posted by Legacy on 10/12/2001 12:00am

    Originally posted by: Chung daewon

    how >??

    Reply
  • Release Build Error

    Posted by Legacy on 03/29/2001 12:00am

    Originally posted by: Bryan

    This code does not work in Release mode. After building the .exe in Release, if you click on the DragCaption ("Tree Menu"), the program bombs with this error:

    "The instruction at "..." referenced memory at "...". The memory could not be "read"."

    I suggest reverting back to Cristi Posea's original code (found here at CodeGuru) and modifying it yourself to suit your app.

    Reply
  • Help Me

    Posted by Legacy on 09/20/1999 12:00am

    Originally posted by: Rajabhakshi

    I compiled this demo successfully in VC6.0 by commenting SetBorder() and GetBorder() functions. While executing it gave me assertion failure.

    Help me as soon as possible

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Java developers know that testing code changes can be a huge pain, and waiting for an application to redeploy after a code fix can take an eternity. Wouldn't it be great if you could see your code changes immediately, fine-tune, debug, explore and deploy code without waiting for ages? In this white paper, find out how that's possible with a Java plugin that drastically changes the way you develop, test and run Java applications. Discover the advantages of this plugin, and the changes you can expect to see …

  • 10 Rules that Make or Break Enterprise App Development Projects In today's app-driven world, application development is a top priority. Even so, 68% of enterprise application delivery projects fail. Designing and building applications that pay for themselves and adapt to future needs is incredibly difficult. Executing one successful project is lucky, but making it a repeatable process and strategic advantage? That's where the money is. With help from our most experienced project leads and software engineers, …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds