border only gets its look after rezising manually(win7)

Sep 13, 2010 at 1: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.

 

Politie

Jun 29, 2011 at 6:49 PM

hi,

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

Jun 29, 2011 at 10: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 4:14 PM

Hello Politie,

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

 FormWithNonClientArea.cs

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 |
                NativeMethods.DCX.DCX_CLIPSIBLINGS));
 
new Code
           IntPtr hDC = NativeMethods.GetWindowDC(hWnd);

 

 

You already have to declare GetWindowDC:

NativeMethods.cs

[DllImport("user32.dll")]

       public static extern IntPtr GetWindowDC(IntPtr hwnd);

 

Paul

Aug 22, 2013 at 4:21 PM
Edited Aug 22, 2013 at 4: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.