gpt4 book ai didi

winforms - 如何使用.NET TextBoxRenderer和TextBoxState.Hot来绘制热文本框?

转载 作者:行者123 更新时间:2023-12-02 22:08:57 26 4
gpt4 key购买 nike

我正在尝试使用TextBoxRenderer渲染“热”文本框:

TextBoxRenderer.DrawTextBox(e.Graphics, rectangle, TextBoxState.Hot);

除了它不起作用之外,它不会将文本框渲染得很热。

  • TextBoxState.Selected 未呈现为选定状态
  • TextBoxState.Hot 未呈现为热

enter image description here

如何使 TextBoxRenderer.DrawTextBox(..., Hot) 渲染为 Hot

相关但不同的问题:

如何使 TextBoxRenderer.DrawTextBox(..., Selected) 呈现为 Selected

最佳答案

似乎 TextBoxRenderer 使用 EP_BACKGROUNDWITHBORDER,而 EP_EDITBORDER_NOSCROLL 通常由 TextBox 控件使用[1] .

if (VisualStyleRenderer.IsSupported)
{
// Use the text control's focus rectangle.
// EP_EDITBORDER_NOSCROLL, EPSN_FOCUSED
VisualStyleElement element = VisualStyleElement.CreateElement("EDIT", 6, 3);
if (VisualStyleRenderer.IsElementDefined(element))
{
VisualStyleRenderer renderer = new VisualStyleRenderer(element);
renderer.DrawBackground(e.Graphics, ClientRectangle);
}
}

(尝试从 VisualStyleElement 获取元素很诱人,但 EP_EDITBORDER_NOSCROLL 没有嵌套类。所以是数字常量 6 和 3。)

关于winforms - 如何使用.NET TextBoxRenderer和TextBoxState.Hot来绘制热文本框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8477522/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com