I have a C# .NET WinForm app which draws to the non-client area. Everything works fine and the drawing happens as expected with the exception of when the form loads.
I catch the WM_NCPAINT fine but when i try to get the DC using GetDCEx it always returns null until the form has been displayed which is perfectly logical but that means that the non-client area isnt painted again until the window is resized which means that when the form is first loaded or restored from a minimized state the NC area isnt redrawn and remains white.
This seems to be unique to Windows 7.
So how do I draw to the NC area in this situation?
EDIT: I should add that I dont care about Aero glass and my form disables it entirely.
Instead of GetDCEx, I use GetWindowDC. Below is the code I use, and I haven’t had an issue with Windows 7. As Hans commented, the best way is to set the FormBorderStyle to None, but then I like to put in my own borders using this code from csharptest.net
Of course, once you do this, then you have to handle any resize, min-max, closing functionality yourself.