DevExpress remove the title text shadow XtraForm

problem

When using DevExpress WinForm development program, I was using the default skin for development. But customer title bar background color to blue, the title text color to white.

Change the color is relatively simple, with reference to the DevExpress Support described, by acquiring skin changes BackColorand ForeColorcan be achieved. But after the changes, found in ambiguous situations arise at low partial screen below the title text.

the reason

Initial guess should be the text shadow, but most of the information search solution is not found, the last in DevExpress Support of this article to see the custom FormPainter. At first I think it is a heavy load DrawText()to resolve, but the relevant parameter is not found, after discovering it has a DrawTextShadow()method, it should be is it.

solve

The solution is simple, is to rewrite the DrawTextShadow()method it as an empty method on the line, without any shading.

public class ReplaceFontFormPainter : FormPainter
{
    public ReplaceFontFormPainter(Control owner, ISkinProvider provider) : base(owner, provider)
    {
        
    }
    
    // 不再绘制标题文字阴影。
    protected override void DrawTextShadow(GraphicsCache cache, AppearanceObject appearance, Rectangle bounds)
    {
        
    }
}

You need to change the form, the form of overloaded CreateFormBorderPainter()methods, use your own created FormPainter.

public partial class MainForm : XtraForm
{
    protected override FormPainter CreateFormBorderPainter() => new ReplaceFontFormPainter(this, LookAndFeel);
}

The final results:

Guess you like

Origin www.cnblogs.com/myzony/p/11276001.html