1

I added ElementHost as child to winform. While maximizing window, black screen appears before showing form.

public Form1()
{
    InitializeComponent();
    System.Windows.Forms.Integration.ElementHost host = new 
    System.Windows.Forms.Integration.ElementHost();
    host.Dock = DockStyle.Fill;
    Controls.Add(host);
}

Maximizing window behaviour works fine without element host as child. Provide possible solution to avoid black screen on maximizing winform having element host as child .

Reza Aghaei
  • 120,393
  • 18
  • 203
  • 398
Amk
  • 23
  • 2
  • The first time you load a Form containing an ElementHost, it takes more time than usual. Since you also have to dock it, more time is needed. In the meanwhile, the Form can appear *black* (not rendered). It shouldn't persist if the Form is resized again (except the docking affair, that won't go, DoubleBuffering or not). But I'm pretty sure you're not leaving this ElementHost empty, as it is in the code snippet you're presenting. What's filling it would be the real offender, if this behaviour is persistent. – Jimi Aug 21 '19 at 10:01
  • I tried to add element host with control at any time not only form initialization , but my problem is during maximization only gets black screen.@Jimi – Amk Aug 28 '19 at 12:26
  • Does the problem reproduce if you leave the ElementHost empty (no control added to it)? If no, then the Control you're adding to the ElementHost is causing the Form to stop redrawing itself, hence the *black effect*. You probably need to introduce some form of async processing to perform whatever tasks this control is for. You never mentioned what this control is and what it's doing. – Jimi Aug 28 '19 at 12:40
  • yes, the problem is reproduced even ElementHost are empty . FYI i tried to add WPF control(Button) with ElementHost. – Amk Aug 29 '19 at 10:53

0 Answers0