Ian*_*oyd 6 winforms visual-styles
我试图用来TextBoxRenderer呈现一个"热"文本框:
TextBoxRenderer.DrawTextBox(e.Graphics, rectangle, TextBoxState.Hot);
Run Code Online (Sandbox Code Playgroud)
除了它不起作用,它不会使文本框变为热.
TextBoxState.Selected 不会呈现为选中状态TextBoxState.Hot 不会变得很热
我如何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);
}
}
Run Code Online (Sandbox Code Playgroud)
(尝试从中获取元素很诱人VisualStyleElement,但没有 的嵌套类EP_EDITBORDER_NOSCROLL。所以它是数字常量 6 和 3。)
| 归档时间: |
|
| 查看次数: |
973 次 |
| 最近记录: |