CTreeCtrl get individual item font ?
-
I'm setting a CTreeCtrl item item font to Italic by handling the NM_CUSTOMDRAW message and setting the font with SelectObject. This is working.
void MyTree::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
{
NMTVCUSTOMDRAW *itemToDraw = reinterpret_cast<NMTVCUSTOMDRAW*>>(pNMHDR);switch (itemToDraw->nmcd.dwDrawStage) { case CDDS\_PREPAINT: \*pResult = CDRF\_NOTIFYITEMDRAW; return; case CDDS\_ITEMPREPAINT: { HTREEITEM item = reinterpret\_cast<HTREEITEM>(itemToDraw->nmcd.dwItemSpec); if (!m\_IsItalicFontCreated) //Create once the italic font { CFont\* currentFont = GetFont(); LOGFONT logfont; currentFont->GetLogFont(&logfont); logfont.lfItalic = TRUE; m\_ItalicFont.CreateFontIndirect(&logfont); m\_IsItalicFontCreated = true; } if (m\_IsItalicFontCreated) { ::SelectObject(itemToDraw->nmcd.hdc, m\_ItalicFont); \*pResult = CDRF\_NEWFONT; } } return; } \*pResult = 0;
}
But at some point I need to check an item current font; to see if a tree item is in italic. The CTreeCtrl's item data (CTreeCtrl::SetItemData) is already used to hold data for each item. Is it possible to do it ? I can't see in the documentation anything I can use. There is a lItemlParam in the NMCUSTOMDRAW struct, I'm not certain if I could use this to some some simple data ? or even if it is persistent. Any suggestions ? Thanks.
I'd rather be phishing!
-
I'm setting a CTreeCtrl item item font to Italic by handling the NM_CUSTOMDRAW message and setting the font with SelectObject. This is working.
void MyTree::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
{
NMTVCUSTOMDRAW *itemToDraw = reinterpret_cast<NMTVCUSTOMDRAW*>>(pNMHDR);switch (itemToDraw->nmcd.dwDrawStage) { case CDDS\_PREPAINT: \*pResult = CDRF\_NOTIFYITEMDRAW; return; case CDDS\_ITEMPREPAINT: { HTREEITEM item = reinterpret\_cast<HTREEITEM>(itemToDraw->nmcd.dwItemSpec); if (!m\_IsItalicFontCreated) //Create once the italic font { CFont\* currentFont = GetFont(); LOGFONT logfont; currentFont->GetLogFont(&logfont); logfont.lfItalic = TRUE; m\_ItalicFont.CreateFontIndirect(&logfont); m\_IsItalicFontCreated = true; } if (m\_IsItalicFontCreated) { ::SelectObject(itemToDraw->nmcd.hdc, m\_ItalicFont); \*pResult = CDRF\_NEWFONT; } } return; } \*pResult = 0;
}
But at some point I need to check an item current font; to see if a tree item is in italic. The CTreeCtrl's item data (CTreeCtrl::SetItemData) is already used to hold data for each item. Is it possible to do it ? I can't see in the documentation anything I can use. There is a lItemlParam in the NMCUSTOMDRAW struct, I'm not certain if I could use this to some some simple data ? or even if it is persistent. Any suggestions ? Thanks.
I'd rather be phishing!
You could implement the method in your MyTree class that would return true if italic font was created. Something like
bool MyTree::IsItalicFontCreated()
{
return m_IsItalicFontCreated;
} -
I'm setting a CTreeCtrl item item font to Italic by handling the NM_CUSTOMDRAW message and setting the font with SelectObject. This is working.
void MyTree::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
{
NMTVCUSTOMDRAW *itemToDraw = reinterpret_cast<NMTVCUSTOMDRAW*>>(pNMHDR);switch (itemToDraw->nmcd.dwDrawStage) { case CDDS\_PREPAINT: \*pResult = CDRF\_NOTIFYITEMDRAW; return; case CDDS\_ITEMPREPAINT: { HTREEITEM item = reinterpret\_cast<HTREEITEM>(itemToDraw->nmcd.dwItemSpec); if (!m\_IsItalicFontCreated) //Create once the italic font { CFont\* currentFont = GetFont(); LOGFONT logfont; currentFont->GetLogFont(&logfont); logfont.lfItalic = TRUE; m\_ItalicFont.CreateFontIndirect(&logfont); m\_IsItalicFontCreated = true; } if (m\_IsItalicFontCreated) { ::SelectObject(itemToDraw->nmcd.hdc, m\_ItalicFont); \*pResult = CDRF\_NEWFONT; } } return; } \*pResult = 0;
}
But at some point I need to check an item current font; to see if a tree item is in italic. The CTreeCtrl's item data (CTreeCtrl::SetItemData) is already used to hold data for each item. Is it possible to do it ? I can't see in the documentation anything I can use. There is a lItemlParam in the NMCUSTOMDRAW struct, I'm not certain if I could use this to some some simple data ? or even if it is persistent. Any suggestions ? Thanks.
I'd rather be phishing!
Hello, I also have the same issues, I need to set CTreeCtrl item. ______________________[
Gmail Klantenservice
-
I'm setting a CTreeCtrl item item font to Italic by handling the NM_CUSTOMDRAW message and setting the font with SelectObject. This is working.
void MyTree::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
{
NMTVCUSTOMDRAW *itemToDraw = reinterpret_cast<NMTVCUSTOMDRAW*>>(pNMHDR);switch (itemToDraw->nmcd.dwDrawStage) { case CDDS\_PREPAINT: \*pResult = CDRF\_NOTIFYITEMDRAW; return; case CDDS\_ITEMPREPAINT: { HTREEITEM item = reinterpret\_cast<HTREEITEM>(itemToDraw->nmcd.dwItemSpec); if (!m\_IsItalicFontCreated) //Create once the italic font { CFont\* currentFont = GetFont(); LOGFONT logfont; currentFont->GetLogFont(&logfont); logfont.lfItalic = TRUE; m\_ItalicFont.CreateFontIndirect(&logfont); m\_IsItalicFontCreated = true; } if (m\_IsItalicFontCreated) { ::SelectObject(itemToDraw->nmcd.hdc, m\_ItalicFont); \*pResult = CDRF\_NEWFONT; } } return; } \*pResult = 0;
}
But at some point I need to check an item current font; to see if a tree item is in italic. The CTreeCtrl's item data (CTreeCtrl::SetItemData) is already used to hold data for each item. Is it possible to do it ? I can't see in the documentation anything I can use. There is a lItemlParam in the NMCUSTOMDRAW struct, I'm not certain if I could use this to some some simple data ? or even if it is persistent. Any suggestions ? Thanks.
I'd rather be phishing!
Maximilien wrote:
The CTreeCtrl's item data (CTreeCtrl::SetItemData) is already used to hold data for each item.
You could extend your data adding the font type (create a struct containing all the necessary data and set the pointer to the struct instance as an ItemData)
-
You could implement the method in your MyTree class that would return true if italic font was created. Something like
bool MyTree::IsItalicFontCreated()
{
return m_IsItalicFontCreated;
}That only tells me the font is created, but not if it was set to one particular tree item.
I'd rather be phishing!
-
Maximilien wrote:
The CTreeCtrl's item data (CTreeCtrl::SetItemData) is already used to hold data for each item.
You could extend your data adding the font type (create a struct containing all the necessary data and set the pointer to the struct instance as an ItemData)
Yes, I'm looking into that. Thanks. :thumbsup:
I'd rather be phishing!