Preventing editing item labels in tree view

This article was contributed by Marius Bakelis.

If we have created tree view control with the TVS_EDITLABELS style we can edit all its items labels. But sometimes we do need that not all tree view control items labels could be editable. So we must prevent editing of item labels we don't want to be editable. We can override the PreTranslateMessage() function:

BOOL CTreeCtrlX::PreTranslateMessage(MSG* pMsg) 
    if( pMsg->message == WM_LBUTTONDOWN )
		CPoint		pt = pMsg->pt;

		if( HitTest( pt, &flag ) == GetSelectedItem() 
			// && there you can check is the item which cannot be editable
			SetFocus();	//We must set focus to the tree view control
					//becouse it can have no focus

			return TRUE ;   // DO NOT process further

    return CTreeCtrl::PreTranslateMessage(pMsg);


  • What To Do About nike Before Time Expires

    Posted by Dethysheree on 03/11/2013 07:16pm

    SobRcjIeoJvj [url=]nike[/url] TroPofPnbHbb [url=]ナイキシューズ[/url] PytSnzDkwZdf [url=]nike[/url] MboLibNupJjq [url=]ナイキシューズ[/url] QjaKuuZcgBcb [url=]nike シューズ[/url] MiaFnvIioBut [url=]ナイキスニーカー[/url] DsvNmyDzwWuh [url=]スニーカーナイキ[/url] MmtEdpBarNkz [url=]スニーカー nike[/url] OovEzkVpnEab [url=]スニーカー nike[/url] PfoJaqErqUlg NlcCqlUqkOsz [url=]nike id[/url] HqeIqhSqeRmi [url=]nike エア[/url] DpuEaoFgaAub [url=]ナイキ[/url] DiqPnjGwuEud [url=]ナイキ[/url] ItqWxqGkpBjj [url=]nike air[/url] FkhHmiJfyXss [url=]スニーカーナイキ[/url] YluYrpRuwWec [url=]ナイキ air[/url] UrjUqtDruFfn [url=]ナイキ air[/url] IaoFfcEniTeb [url=]ナイキスニーカー[/url] YapXmvWwkBpk NloXroYkcRcl [url=]nike id[/url]YvlKcsYvmIld [url=]ナイキランニング[/url]VuqWlnGrsQug [url=]nike ランニング[/url]EybUklWzqEzj [url=]ナイキゴルフ[/url]BtxOqnNakOvw [url=]nike sb[/url]HowWgsNqsNey [url=]free nike[/url] BfyDbvNdzNvb [url=]nike sb[/url] PryEscMzbPzo [url=]nike sb[/url]SfzSjgXdeKtb

  • Preventing editing item labels in tree view

    Posted by Legacy on 08/05/1999 12:00am

    Originally posted by: Chris Grieve

    This was a great help but it has a tiny buggette in the way that HitTest is used which stops you D&D ing something by the icon that is already selected. This is the correction;

    As before except;

    UINT flag = 0;

    if( ( ( tree.HitTest( pt, &flag ) == tree.GetSelectedItem()
    &&( flag & TVHT_ONITEMLABEL ) ) // new bit
    && ( FALSE ) ) // your check in here

    But I wouldn't have got this far without the original code(!)



  • Why not handle TVN_BEGINLABELEDIT notification?

    Posted by Legacy on 01/16/1999 12:00am

    Originally posted by: Peter Schregle

    A more straightforward way to inhibit label editing would be to handle the TVM_BEGINLABELEDIT notification. Return FALSE to allow and TRUE to cancel label editing.

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

Top White Papers and Webcasts

  • U.S. companies are desperately trying to recruit and hire skilled software engineers and developers, but there's simply not enough quality talent to go around. In response, companies often resort to inferior solutions -- hiring substandard developers and engineers, recruiting talent on a part-time or temporary basis, poaching people from competitors, or burdening an already stressed IT staff for more of their labor. Fortunately, there's a better solution. Read this white paper to learn the business value of …

  • Lenovo recommends Windows 8 Pro. "I dropped my laptop getting out of the taxi." This probably sounds familiar to most IT professionals. If your employees are traveling, you know their devices are in for a rough go. Whether it's a trip to the conference room or a convention out of town, any time equipment leaves a user's desk it is at risk of being put into harm's way. Stay connected at all times, whether at the office or on the go, with agile, durable, and flexible devices like the Lenovo® …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date