diff --git a/WIndows.Forms/VisualTheme.cs b/WIndows.Forms/VisualTheme.cs
index 0363ff87..35910269 100644
--- a/WIndows.Forms/VisualTheme.cs
+++ b/WIndows.Forms/VisualTheme.cs
@@ -718,6 +718,24 @@ namespace Vanara.Windows.Forms
DrawThemeParentBackground(childWindow.Handle, hdc, bounds);
}
+ /// Draws text using the color and font defined by the visual style.
+ /// Used for drawing the text.
+ /// Value that specifies the part to draw.
+ /// Value that specifies the state of the part to draw.
+ /// The bounding rectangle, in logical coordinates.
+ /// A string that contains the text to draw.
+ /// One or more values that specify the string's formatting.
+ /// Draw text disabled.
+ /// The font to use when drawing the text. If null, the default system font is used.
+ public void DrawText(IDeviceContext graphics, int partId, int stateId, Rectangle bounds, string text, TextFormatFlags fmt = TextFormatFlags.Default, bool disabled = false, Font font = null)
+ {
+ RECT b = bounds;
+ using (var hdc = new SafeHDC(graphics))
+ using (var hfont = new SafeHFONT(font?.ToHfont() ?? IntPtr.Zero))
+ using (hdc.SelectObject(hfont))
+ DrawThemeText(Handle, hdc, partId, stateId, text, text.Length, (DrawTextFlags)fmt, disabled ? 1 : 0, b);
+ }
+
/// Draws text using the color and font defined by the visual style.
/// Used for drawing the text.
/// Value that specifies the part to draw.
@@ -730,7 +748,7 @@ namespace Vanara.Windows.Forms
public void DrawText(IDeviceContext graphics, int partId, int stateId, Rectangle bounds, string text, TextFormatFlags fmt = TextFormatFlags.Default, DTTOPTS? options = null, Font font = null)
{
RECT b = bounds;
- var dt = options ?? DTTOPTS.Default; //new DrawThemeTextOptions(true) {AntiAliasedAlpha = true, BorderSize = 10, BorderColor = Color.Red, ApplyOverlay = true, ShadowType = TextShadowType.Continuous, ShadowColor = Color.White, ShadowOffset = new Point(2, 2), GlowSize = 18, TextColor = Color.White, Callback = DrawTextCallback };
+ var dt = options ?? DTTOPTS.Default;
using (var hdc = new SafeHDC(graphics))
using (var hfont = new SafeHFONT(font?.ToHfont() ?? IntPtr.Zero))
using (hdc.SelectObject(hfont))