leocb / MaterialSkin

Theming .NET WinForms, C# or VB.Net, to Google's Material Design Principles.
MIT License
428 stars 130 forks source link

Forms only partially refreshing when activated from taskbar #352

Closed ainwood closed 1 year ago

ainwood commented 2 years ago

I have a MaterialForm application. I have a WinForms TableLayoutPanel, with a few MaterialControls on it.

I start the form Maximised (but I've repeated it with the form set to WindowState.Normal as well). Once the application is started, clicking on the taskbar icon will minimize it, as expected. When I click the taskbar icon again, it will maximise, but only the Material Controls get redrawn - I end-up with the rest of the form background not being redrawn.

ainwood commented 2 years ago

OK - I'm struggling to understand this. I started a new project, and couldn't reproduce it. But the original one was more complicated - async, connecting to databases in form_load etc. In the end, I added Form.Refresh() to Main_Resize() and Main_SizeChanged(). Seems to work (albeit with a slight flicker).

ainwood commented 2 years ago

Sorry to spam this again - found the problem.

I was using this in my form:

protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED return cp; } }

Removed that, and seems to work properly!