border only gets its look after rezising manually(win7)

Sep 13, 2010 at 2:40 PM

hello, im really interested in this project, i was glad to find it but it doesnt seem to work on windows 7. when i start the program the border looks white with not border around it. the caption buttons dont draw after start and restoring from minimized state.

my question would be if anyone got it to work on windows 7 or maybe someone knows a solution to this? ive been trying for quite some time now but just cant get it to work...


even without the border, so without the longhornform class i would be happy but the form also grows a little everytime its minimized and maximized.


any help would be great, thank you.



Jun 29, 2011 at 7:49 PM


I've the same problem. It seems that there are no intentions to solve the bug.

Jun 29, 2011 at 11:08 PM

doesn't look like it no, ive removed the border and worked with that, had some dificulties that i solved with ugly solutions. it is what it is.

Aug 19, 2011 at 5:14 PM

Hello Politie,

The problem might be you won’t get a valid hRgn in PaintNonClientArea. So replace GetDCEx by GetWindowDC:


private void PaintNonClientArea(IntPtr hWnd, IntPtr hRgn)
old code
           IntPtr hDC = NativeMethods.GetDCEx(hWnd, hRgn,
            (int)(NativeMethods.DCX.DCX_WINDOW | 
                NativeMethods.DCX.DCX_INTERSECTRGN |
                NativeMethods.DCX.DCX_CACHE |
new Code
           IntPtr hDC = NativeMethods.GetWindowDC(hWnd);



You already have to declare GetWindowDC:



       public static extern IntPtr GetWindowDC(IntPtr hwnd);



Aug 22, 2013 at 5:21 PM
Edited Aug 22, 2013 at 5:22 PM
42na wrote:
...So replace GetDCEx by GetWindowDC:..
Thanks, worked.

As-is, CustomFormBorder v0.5 Alpha (2006.06.16) appears to work on WinXP (x86) but doesn't on Win7 (x64) until after resizing. Changing GetDCEx to GetWindowDC inside FormWithNonClientArea.PaintNonClientArea appears to have fixed this issue for me.