• <legend id='7Te7O'><style id='7Te7O'><dir id='7Te7O'><q id='7Te7O'></q></dir></style></legend>

  • <tfoot id='7Te7O'></tfoot>

      <i id='7Te7O'><tr id='7Te7O'><dt id='7Te7O'><q id='7Te7O'><span id='7Te7O'><b id='7Te7O'><form id='7Te7O'><ins id='7Te7O'></ins><ul id='7Te7O'></ul><sub id='7Te7O'></sub></form><legend id='7Te7O'></legend><bdo id='7Te7O'><pre id='7Te7O'><center id='7Te7O'></center></pre></bdo></b><th id='7Te7O'></th></span></q></dt></tr></i><div id='7Te7O'><tfoot id='7Te7O'></tfoot><dl id='7Te7O'><fieldset id='7Te7O'></fieldset></dl></div>
        <bdo id='7Te7O'></bdo><ul id='7Te7O'></ul>

    1. <small id='7Te7O'></small><noframes id='7Te7O'>

        TextBox 使用 GDI 还是 GDI+

        时间:2023-06-09

        • <i id='Xpayy'><tr id='Xpayy'><dt id='Xpayy'><q id='Xpayy'><span id='Xpayy'><b id='Xpayy'><form id='Xpayy'><ins id='Xpayy'></ins><ul id='Xpayy'></ul><sub id='Xpayy'></sub></form><legend id='Xpayy'></legend><bdo id='Xpayy'><pre id='Xpayy'><center id='Xpayy'></center></pre></bdo></b><th id='Xpayy'></th></span></q></dt></tr></i><div id='Xpayy'><tfoot id='Xpayy'></tfoot><dl id='Xpayy'><fieldset id='Xpayy'></fieldset></dl></div>
          <legend id='Xpayy'><style id='Xpayy'><dir id='Xpayy'><q id='Xpayy'></q></dir></style></legend>
            <bdo id='Xpayy'></bdo><ul id='Xpayy'></ul>

                  <tbody id='Xpayy'></tbody>
                <tfoot id='Xpayy'></tfoot>

                <small id='Xpayy'></small><noframes id='Xpayy'>

                1. 本文介绍了TextBox 使用 GDI 还是 GDI+的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  基本上,我想测量 TextBox 中的文本大小,我发现 TextRenderer 给了我正确的值,而 Graphics 给了我错误的值.这样看来,TextBox 应该使用 GDI 来绘制文本,对吧?

                  Basically, I want to measure the text size in a TextBox, and I found out that TextRenderer gives me the correct values, while Graphics would give me wrong values. So that seems like TextBox should be using GDI to draw text, right?

                  但是,无论我在哪里阅读,我都看到它应该使用 GDI+.例如:

                  However, wherever I read, I see that it's supposed to use GDI+. For example:

                  • 这里 http://microsoft.public.dotnet.framework.windowsforms.controls.narkive.com/yoHKjPut/text-rendering-accuracy-problem-in-textbox-richtextbox 它说 TextBox 和 Buttons 使用 GDI+.
                  • 这里 为什么 Graphics.MeasureString() 返回比预期的数字高?它说默认是兼容模式",它吸引了 GDI+
                  • Here http://microsoft.public.dotnet.framework.windowsforms.controls.narkive.com/yoHKjPut/text-rendering-accuracy-problem-in-textbox-richtextbox it says that TextBox and Buttons use GDI+.
                  • Here Why is Graphics.MeasureString() returning a higher than expected number? it says that default is "compatibility mode" that draws in GDI+

                  那么为什么我使用 TextRenderer 而不是使用 Graphics 得到一致的结果,而它应该是其他方式呢?

                  So why is it that I'm getting consistent results with TextRenderer and not with Graphics when it's supposed to be other way around?

                  推荐答案

                  好吧,更多研究表明默认"是什么存在混淆.

                  All right, some more research have shown that there is a confusion of what is "Default".

                  当这些消息来源谈论Default"时,他们谈论的是Default(1)",如如果没有执行额外的代码",而不是Default(2)",如如果不采取额外操作".

                  When these sources talk about "Default", they talk about "Default(1)" as in "If no extra code is executed", not "Default(2)" as in "If no extra action is taken".

                  由于Default(2)",Application.SetCompatibleTextRenderingDefault(false)"被添加到新项目的Program.cs文件中,使得TextBox类使用GDI进行渲染,从而不是它的Default(1)",但事实上,如果你作为程序员不采取额外的行动,就会发生这种情况.

                  Because by "Default(2)", "Application.SetCompatibleTextRenderingDefault(false)" is added to the Program.cs file of a new proiject, which makes TextBox class use GDI for rendering, which is not the "Default(1)" for it, but in fact this is what happens if you, as a programmer, take no additional action.

                  这基本上就是吸引我的原因.

                  This is basically what got me.

                  PS:我假设默认(1)"是正确的,这个假设是基于这个问题的接受答案 UseCompatibleTextRendering 属性设置为 false 时不是由设计师创建的

                  PS: I'm basing the assumtion that it's true by "Default(1)" on the accepted answer from this question UseCompatibleTextRendering property not created by designer when it is set to false

                  这篇关于TextBox 使用 GDI 还是 GDI+的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何自定义 ToolStripTextBox 的呈现? 下一篇:用户选择子项后 TreeView 自动选择父项

                  相关文章

                    <legend id='0bucr'><style id='0bucr'><dir id='0bucr'><q id='0bucr'></q></dir></style></legend>
                    <i id='0bucr'><tr id='0bucr'><dt id='0bucr'><q id='0bucr'><span id='0bucr'><b id='0bucr'><form id='0bucr'><ins id='0bucr'></ins><ul id='0bucr'></ul><sub id='0bucr'></sub></form><legend id='0bucr'></legend><bdo id='0bucr'><pre id='0bucr'><center id='0bucr'></center></pre></bdo></b><th id='0bucr'></th></span></q></dt></tr></i><div id='0bucr'><tfoot id='0bucr'></tfoot><dl id='0bucr'><fieldset id='0bucr'></fieldset></dl></div>

                    <small id='0bucr'></small><noframes id='0bucr'>

                    • <bdo id='0bucr'></bdo><ul id='0bucr'></ul>
                    1. <tfoot id='0bucr'></tfoot>