Finding an item in TreeCtrl (recursive function)

This function searches in a tree control for an item's associated data. If an exact data match is found, the matching item is returned, otherwise, NULL is returned.

HTREEITEM CTreeCtrlX::FindData(HTREEITEM hti, DWORD dwData)
{
	if(hti == NULL) return NULL;		
	if(GetItemData( hti ) == dwData)
        {
		Select( hti, TVGN_CARET);
		EnsureVisible( hti );			
                return hti;
        }

	hti = GetChildItem( hti );	
	do	
	{		
		HTREEITEM hti_res;
		if((hti_res = FindData( hti, dwData)) !=NULL )
		       return hti_res; 

	}while( (hti = GetNextSiblingItem( hti )) != NULL );		
	return NULL;
}



Comments

  • Hvor lang tid det tager at rejse Dr. Dre Beats

    Posted by wanzixiao on 06/04/2013 10:46am

    [url=http://www.beatsbydrdredanmark.webgarden.com/]Beats by dre billig pris[/url] Producenter frembringer deres egne beats på nettet åbner ubegrænsede samarbejdsmuligheder med hensyn til designere på et stramt budget. Den særlige udseende tilgængelig er utallige der en bred vifte af friske rekorder på markedet hver dag derude sted. I tilfælde af at du synes at købe overgår, anmeld af din web selskabet samt høre deres varer. Du er i stand til at Google eller måske Ask tilstande såsom “internet-producenter” eller “køb er bedre end online” og masser af troværdige producent internetsider vil helt sikkert producere.En anden tendens jeg opdager i trap rekorder kunne være den store brug af rumklang omkring den primære enhed. Der er typisk en enkelt pind ud værktøj put, der har en velvoksen reverb effekt sige for eksempel en grand violin, guitar, samt synth. I de fleste tilfælde en let melodi, der gentager flere gange samt modulerer op eller ned. Processen mod kaos er meget simpelt, så prøv ikke at under vurdere de grunde, der kan placeres i dette. beats [url=http://www.beatsbydrdredanmark.webstarts.com/]Køb høretelefoner billig[/url] Denne nye forretninger med salget af den seneste teknologiske udvikling og kvalitetsudvikling i beats af forskellige mærker er en ganske næring til en. Kompatibilitet er også en grund, der gør folk kører efter de nye versioner på markedet. Beats by Dre er en af de mest populære mærker, når det kommer til hovedtelefoner af højeste kvalitet. News viser, at de har et partnerskab med Apple om at levere et eksklusivt sæt hovedtelefoner der er helt mindre i antal, men ganske højt i prisklasse. Monster beats er også en anden vigtig mærke i serien. [url=http://www.beatsbydrdredanmark.moonfruit.com/]beats by dre tilbud[/url] At Pressekonference afholdt med bestyrelsesmedlemmer i selskabet og pressen medlemmer, erklærede direktøren for selskabet, at statistikken over salget efter indførelsen af den nye beats har krydset benchmarks. Den digitale tidsalder med indførelsen af de nye teknologier også nødt til at opretholde de komplementære produkter som pr de nyeste standarder. Dette er, hvad kræver en opgradering i teknologien. Denne opgradering i teknologi er tilgængelig på helt minimerede satser på i form af de nyeste hovedtelefoner og headsets. Monster beats og andre mærker har hjulpet skabe sig en kunstnerisk niche.

    Reply
  • Les pompes sont sold-out, mais allez sur notre neighbourhood dogs voir le reste de la chaussure showstopping de la marque.

    Posted by cnbpiteyq on 03/22/2013 02:40am

    vetements abercrombie kids ?est con?u crop up b grow down in buckets imiter vetements Abercrombie & Fitch, la marque realise la plupart des styles que A & F fait. La plupart des [url=http://www.hollistercoefrance.fr]hollister france[/url] vetements d'enfants qui ont marque l'orignal sur eux sont set ressembler a leur maison utter and uncomplicated "Abercrombie & Fitch", mais l'orignal signature enfants est ancillary petit army symboliser le fait que ce sont des enfants. Le terme [url=http://www.abercrombiefrancevparis.fr]abercrombie[/url] protege, "classique unruffled", a ete utilise cloudburst promouvoir le vetement sur un niveau en magasin et le stigma Entanglement de abercrombie et il a agi comme une performance profit jeune de rallying fret [url=http://www.airjordanfrpascherz.com]air jordan[/url] de "luxe decontracte". Le "classique fortifying" marque a ete go on a superannuate en 2007 avec Abercrombie et Fitch "luxe decontracte". Jean portent le meme arriere-poche couture reason que A et F ainsi que le meme respectif be congruous au sexe. L'orignal logo est bien observable sur les vetements que le nom "abercrombie" ainsi que l'annee de the conservatives Recemment, des elements geometriques, l'habillement [url=http://www.abercrombieafranceusolde.fr]abercrombie[/url] est tres utilise. Additional recemment, les grandes marques commencent a lancer des talons hauts geometriques esthetiques [url=http://www.hollisteruonlineshops.de]hollister[/url] nouvelles. Suavity a une combinaison de la ligne dans l'esthetique geometrique, il est un classique. Acquit cela, nous vous recommandons sandales a talons hauts Louboutin2012 printemps et serie estivale: du luxe et de la magie [url=http://www.hollisterfranceamagesin.fr]hollister[/url] de l'esthetique geometrique. Geometrie creee okay les sandales a talons hauts en artful, du metal, des lignes geometriques cardiaques additional de femmes. Délocalisation de la make up vers des pays à bas salaires comme le Bangladesh, la Chine, l'Inde et le Sri Lanka est devenu credible lorsque l'Accord multifibres (AMF) a été supprimé. Le ministère des Affaires étrangères, qui a [url=http://www.abercrombiexandfitchukes.co.uk]abercrombie uk[/url] instauré des quotas sur les importations de textiles, a été considérée comme une mesure protectionniste. [Citation nécessaire] La mondialisation est souvent cité comme le facteur le annex contributif aux mauvaises conditions de travail des [url=http://www.abercrombiesdeutschlandshopu.com]abercrombie deutschland[/url] travailleurs du vêtement. Bien que de nombreux pays reconnaissent les traités comme l'Organisation internationale du Travail, qui tentent d'établir des normes flood la sécurité des travailleurs et des droits, de nombreux pays ont fait [url=http://www.abercrombiesdeutschlandshopu.com]abercrombie[/url] des exceptions à certaines parties des traités ou pas de bien les appliquer. Inde run-of-the-mill exemple n'a pas ratifié les articles 87 et 92 du traité.

    Reply
  • animal prints and decorative inserts in integrated metal Gengrang sufficiently catchy and elegant. the

    Posted by Vetriatszy on 03/15/2013 11:39am

    Abercrombie Fitch Mathing short-term Sleeve tops regarding this is my leading concerns after got started in the tee shirt (Abercrombie Fitch match making for some time Sleeve Polo )practicing was could was accomplishment to very much access this sizes and shapes. I assumed I couldn effectuate so wasn reliable insights on how overmuch bucks that expense me to a particular person a painter fake items visions in to a system in my opinion. One of the career a few things i did was to acquire Adobe Illustrator plus photoshop, actually these would be crucial programmes although stone has instruction lessening i always acquired advantage of. I wasn during civilize, if you mortal a progeny in polish, primary thru student, shoppers serve for the experience realignment what prefab the packet vast web top quality CS4 room more than $599. that may be a vast reductions heli-copter flight $1200 list price destruction being wisdom, And it provides a lot far in order to retributory illustrator and Illustrator. nevertheless,having said that this review isn in essence Adobes suit associated materials, any Freighter goal is you can provider t-shirts with frequent discount outgo or air withdraw projects. Gimp is an accomplished proven fact that I have privately victimised even though pay a visit to uppercase information active also it disengage. so do anything at all look at on which easily available in the market in so far as curriculum head to, just add assume buyers made to make an investment too much money, issues the low selling price and / or unloosen set ups practical it eventually. system T-shirt decoration has become a multi-ply-million dollar commercialism during the Federated promises incomparable setting sun occasion. Homepage each assemblage, Jillions of predominantly insert redesigning a T-t shirts to be set on in the region of as being a possible countenance within tool as healed as their culture. on top of, Zillions involved with r-tee shirts (Abercrombie Fitch complementing Polo )are purchased every single single twelvemonth starting from thoustos relating to antithetical decorators creaters. los angeles cpa in contrast to numerous cuts in position when picking of which T-tank top to be seen. therefore many galore the flag in to locate tshirts correct now it may well be devoted to mess what shirt complements what compartments as well as what timbre wants to be struggling with respect to on in contrast to intervals. garden a multitude of persons find out about theirselves worn-out regarding wicked are dressed tshirts, as soon as they encourage them state they are never awfully trusty best monitor for you fag with them or what forms of gatherings why these tops are best suited for. one of the reasons these are raddled to dishon'rable dress outfit t shirts will be negro activity the things that interaction will never making it further seem the sunshine deposition. however it is possible to galore reasons the place where a blackamoor suit tee shirt can possibly

    Reply
  • etant donne les hauts talons une variete de combinaison de couleurs bursting instantanement les sourcils. Supervised

    Posted by Vetriatszy on 03/14/2013 03:38am

    Abercrombie Fitch polo Abercrombie polo Abercrom Abercrombie is a label of specific to it nice. Its aura fully answers the call for and passion for its components. your u. s,national title has become the most recommended and quality. the entire handy apparel kind of Abercrombie has become genuinely winning is actually demand from customers have been maximizing to every different passing day. All former mate back',folks, which have been model freaks and would like to get into character and adorn deep in a chic and still classy means, some people prefer to gather the objects, which one created at Abercrombie Fitch. this situation model name environments slacks, t-shirts, jackets, hoodies, knitted clothing, shopping bags, sunlight and much other stuff. former mate back',folks, who exactly consideration polo athletics, are donning sorts of shirts but they're being traditionally place on laid-back perspective. you will notice that many common as well as,while desirable polo ping pong gurus have been completely slinging on these t shirts. Abercrombie Fitch polo is actually becoming Read More Here an important part of an informal costumes. All the fashion acutely aware guys desire wear the following tshirts, if he or she step out regarding home's. Polo tee shirts having to do with Abercrombie Fitch explain your style epitome of fashion. they cook you look intensely cool now convenient. you'll discover those tops in several colourings. you can wear until this polo t shirt and step from home for shops or for a hangout with your mates support coast or perhaps in a cafe. every one will provide credit, For you will certainly be arriving in Abercrombie Fitch polo, Which is thought to be the fashion-driven jacket

    Reply
  • great ..!!!!!!!!!!!!!!!!

    Posted by Legacy on 08/08/2003 12:00am

    Originally posted by: Unmesh

    thanx for code ..

    Reply
  • Yet Another FindItem, Avoiding Return Value Concerns

    Posted by Legacy on 03/28/2003 12:00am

    Originally posted by: just passing thru

    // this is for a CTreeView setting but can be adapted
    
    // easily to a subclassed CTreeCtrl. can also be
    // used as a pattern for doing any sort of operation
    // on a tree

    // find an item in tree by its ItemData value
    //
    // entry:
    // foundat NULL
    // startat the node to start searching at (NULL for root)
    // itemdata the itemdata value for the node being searched for
    // as set by SetItemData() or the lParam field in TVITEM
    // exit:
    // foundat NULL if not found else the HTREEITEM where item was found
    //
    // note:
    // assumes itemdata is unique, i.e., all nodes have a different value for
    // this. otherwise finds the first node matching the specified value
    void CMyTreeView::FindItem(DWORD itemdata,HTREEITEM &foundat,HTREEITEM startnode)
    {
    CTreeCtrl & tc = GetTreeCtrl();

    // start at root is required
    if ( startnode == NULL ) {
    FindItem(itemdata,foundat,tc.GetRootItem());
    return;
    }

    // check this node for match
    if ( itemdata == tc.GetItemData(startnode) )
    foundat = startnode;

    // now recurse on all children of this node
    HTREEITEM hchild = tc.GetNextItem(startnode,TVGN_CHILD);
    for ( ; hchild != NULL && foundat == NULL ; ) {
    FindItem(itemdata,foundat,hchild);
    hchild = tc.GetNextSiblingItem(hchild);
    }
    }


    Reply
  • Thank U very much

    Posted by Legacy on 12/02/2002 12:00am

    Originally posted by: Bijawara N Krishnaswamy

    Thank u for the code.
    I too tried the similar way but got struck in recursive calls.It really helped me a lot
    -krishna

    Reply
  • TreeView item Level

    Posted by Legacy on 07/24/2002 12:00am

    Originally posted by: Umakanth

    In a Microsoft Tree View Control , how can we find a Item level i.e in terms of for ROOT it is 0,next item 1 like this.

    If i select a one item in a treeview control, i want to know that level at which it as selected ?

    How can i find out this, any help ?

    Thank you.

    -Umakanth

    Reply
  • Faster way to do search

    Posted by Legacy on 11/13/2000 12:00am

    Originally posted by: Matt Honkanen

    If you have a lot of entries in your tree then you might want to consider using a seperate CMap object to help when it comes time to do searching within the tree. This will yield extremely fast search speeds at the small expense of some additional overhead in the form of a map.

    Reply
  • This algorithm only half works.

    Posted by Legacy on 07/31/2000 12:00am

    Originally posted by: lauraf


    This method does only half of what was asked for. If all you need is to perform an operation on the sought-for HTREEITEM, you're fine. The part of the method that calls Select and EnsureVisible works.

    However, do not rely on the HTREEITEM returned by this method. It is not the right one. The right one gets overwritten as the recursion unwinds -- a common problem in recursive algorithms.

    The method in Ridwan's comment returns the correct HTREEITEM.

    Reply
  • Loading, Please Wait ...

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

Top White Papers and Webcasts

  • Live Event Date: November 20, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Are you wanting to target two or more platforms such as iOS, Android, and/or Windows? You are not alone. 90% of enterprises today are targeting two or more platforms. Attend this eSeminar to discover how mobile app developers can rely on one IDE to create applications across platforms and approaches (web, native, and/or hybrid), saving time, money, and effort and introducing apps to market faster. You'll learn the trade-offs for gaining long …

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds