问题描述
如果我使用派生自CTreeCtrl的类的DC来计算我想插入的树项目的水平范围,则:
If I use the DC of my CTreeCtrl-derived class to calculate the horizontal extent of a tree item I would like to insert:
CDC *pDC = GetDC();
CSize nameSize = pDC->GetTextExtent (*dString);
...似乎无法在将字符附加到字符串(dString)上以使所有树项具有相同的长度(一两个像素以内)时依赖此函数.换句话说,我可以这样做:
... it seems I cannot depend on this function while appending characters to the string (dString)in order to make all tree items the same length (within a pixel or two). In other words, I can do:
while (nameSize.cx < someLimit) {
dString->Append ("-");
nameSize = pDC->GetTextExtent (*dString);
}
如果我以这种方式扩展"每个字符串,它们的确在几个像素内具有最终的文本范围(长度),但是当它们在CTreeCtrl中显示时,它们的长度都不同.
好像CTreeCtlr的DC与实际DC不匹配.有什么想法吗?
Thx
If I ''extend'' each string in this fashion, they indeed have a final text extent (length) within a few pixels, but when they are displayed in the CTreeCtrl, they are all of different length.
It is as if the DC of the CTreeCtlr does not match the actual DC. Any ideas?
Thx
推荐答案
这篇关于CTreeCtrl-GetTextExtent似乎很奇怪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!