GetTextExtent在某些非英文系统下会有内存泄漏。
for( lineNumber = 0; lineNumber<lines; lineNumber++) 
{   
    ......     
    CSize WrittenSize = cDC.GetTextExtent( OneLine ); 
    cDC.TextOut( x- WrittenSize.cx/2, y, OneLine ); 
    y += WrittenSize.cy; 
    .     ........... 

实际上我们写了一个简单的测试程序,就是在OnDraw()里头调用这个函数,放大和缩小窗口(每刷新一次),也就是执行一次GetTextExtent,内存都会有增长。
-----------------------微软的建议-------------------------------------------
(中文意思:用ExtTextOut输出,以图片的形式输出字符,用GetGlyphOutline、ExtTextOut这些函数来做。)但我没用过这些api,看msdn试着去做,一直没弄出来,那位能给个详细的例子,就是用ExtTextOut如何从字符到图片输出
Hi **,  
The current target is for Longhorn, but we could request an earlier hotfix if you wish.  If so, we would need a business impact statement from you, to log with the request.  Note that a hotfix request is just that  a request  and there is no guarantee that a fix will occur.  
Due to the uncertain nature of this, I would very strongly recommend investigating the workarounds I described previously.  Another (3rd) possible workaround to try would be to get the glyph images of the characters you want to draw (with GetGlyphOutline), then draw them with ExtTextOut and the ETO_GLYPH_INDICES flag.  I will experiment with this possibility tomorrow as well.  I do not know whether the memory leak will still occur when doing this. 
Please let me know how you would like to proceed.+++++++++++++++++++++++++++++++++++++++
(中文意思:有两种替代方法,一是用bmp图片代替文本输出,这样放缩窗口就是放缩图片,但是文字可读性不好。第二种方法就是放缩窗口时,定义不同大小的字体,这样不用调用GetTextExtent,但这样放缩的比例会不精确)
Thanks **.  I have done some more research and testing.  Unfortunately, until this is fixed, I dont see a good workaround beyond the two that I described below. As mentioned, the only possibilities would be to render the text a single time to a bitmap, then scale the bitmap (using the bitmap dimensions to determine the size of the string).  Of course, the readability of the text will not be good and font scaling will not be smooth, but doing this will not leak.  Or, to generate different fonts with different sizes, to be used without scaling. Im sorry I don't have a better solution at this time.+++++++++++++++++++++++++++++++++++++++
他们的email签名挺有意思
**** *******
Microsoft Developer Support
425-704-5212
****@microsoft.com
 
We want you to be "very satisfied" with Microsoft Support. If you cannot say you are "very satisfied", or if you'd like to make a comment (good or bad) about the quality of our support, please feel free to contact me (*****@microsoft.com) or my manager **** ******* (********@microsoft.com). 
 
Get Secure.  Visit http://windowsupdate.microsoft.com to update your machine with all critical security fixes and additional software updates.
---------------------------------------------------------------------------

解决方案 »

  1.   

    ExtTextOut() 参数表 
    参数 类型及说明 
    hdc Long,设备场景的句柄 
    x,y Long,以逻辑坐标表示的一个点,指定了绘图起点 
    wOptions Long,下述标志常数的任意组合 
    ETO_CLIPPED 将文本剪切出指定的矩形 
    ETO_GLPYH_INDEX lpString是一个字样索引表。参考对GetCharacterPlacement函数的说明。只适用于Win95 
    ETO_OPAQUE 在正式描绘文本前,用当前的背景色填充矩形 
    lpRect Rect,指定一个矩形,用于对文本进行格式化处理。可指定长整数0,在不用矩形区域的前提下描绘文本 
    lpString String,欲描绘的字串 
    nCount Long,字串中要显示出来的字符数 
    lpDx Long,如果不是零,这个参数就代表指向一个Long值数组的指针。该数组对每一对字符的间距进行了说明(采用逻辑单位)。其中第一个条目是第一和第二个字符的间距;第二个条目是第二和第三个字符的间距;以此类推。如果为零,函数就使用字体的默认间距设置 
      

  2.   

    re: surstar(断水流)
    msdn上这段都看了好多遍了,可是没试出来。今天给微软客户支持发信了,看看他们能不能给我写个例子。
      

  3.   

    to xiaoyuzi (小鱼子) 
    请问:你描述这个问题在那些操作系统上出现?
      

  4.   

    我都不敢说出来啊,是在日文系统下阿,我也讨厌小日本,但怕写上没人回答问题了。GetTextExtent和TextOut函数都会有泄漏
      

  5.   

    还好,被我解决了,找到了替代方法。微软fix这个问题估计还要等好久吧
      

  6.   

    不用OnDraw提供的CDC, 自己建一个CDC,然后用CreateCompatibleDC建一个内存DC来调用GetTextExtent就没有泄漏,TextOut用ExtTextOut代替,并且使用忽视语言选项。