WPF doesn't always redraw when using WindowsFormsHost

I have a simple application that hosts managed DirectX Controlwith WindowsFormsHost. I overridden the drawing methods in Controlto prevent flickering:

protected override void OnPaint(PaintEventArgs e)
{
    if (this.Visible == true) { base.OnPaint(e); }
}

// Don't paint the background unless the control is not visible
protected override void OnPaintBackground(PaintEventArgs e)
{
    if (this.Visible == false) { base.OnPaintBackground(e); }
}

There is a timer that periodically cancels managed DirectX Controlso that it is redrawn.

My problem is that when I lock the computer (WIN + L) and then unlock it, the contents of WPF around WindowsFormsHostsometimes sometimes do not become fully colorized. Its various parts are not drawn until I get the window completely out of sight. Any ideas on why WPF won't redo itself?

Sorry if this is too vague to solve the problem, I cannot share more source code.

+3

Source: https://habr.com/ru/post/1739901/


All Articles