Limiting label length when editing

CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.




To limit the length of text that can be entered when editing an item label,
you have to add a handler for the TVN_BEGINLABELEDIT notification. Within
this handler get the edit control and call the LimitText() function.

 
void COutline::OnBeginLabelEdit(NMHDR* pNMHDR, LRESULT* pResult) 
{
        TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;
        
        // Limit text to 127 characters
        GetEditControl()->LimitText(127);

        *pResult = 0;
}

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read