Transparent borders when maximized?

Steve Valliere 116 Reputation points
2020-11-10T12:43:48.557+00:00

I'm working with a VS2019 C (not C++) project that has unexpected transparent borders that are two or three pixels thick. The project was originally created for Windows 7 using VS2010 and did not have these borders in that environment (I still have that system and I checked.) The program has a "full screen" mode (without title bar, menu, frames, etc.) that works perfectly with no margins, but when I allow the system to handle the MAXIMIZE function, the borders appear. After checking, this affects all of our projects, even those created by VS2019 specifically for Win10. It also appears to affect other (3rd party) products, but not all of them. So there IS a solution.

But is the solution possible with a native C project? If so, can anyone offer any ideas?

FWIW, when the program is not in full screen mode, I forward all WM_GETMINMAXINFO, WM_SIZE and any other related messages to Windows, so I shouldn't be involved in whatever is happening. Plus, this happens even in the simplest "Hello World"-type project that does nothing but create a window that is filled with a solid color during the WM_PAINT, so I KNOW is it not in my code. I suspect a "magic" (to me) new project setting, but since I don't know what it might be, I have no possible way to search for it, either! HELP!

PS: Sorry about the lousy tags, I have no idea how to best tag this question, but knowing the answer would probably help with that!

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,429 questions
{count} votes

Accepted answer
  1. Steve Valliere 116 Reputation points
    2020-11-12T13:07:31.937+00:00

    I was using CreateWindowEx() with the WS_EX_OVERLAPPEDWINDOW style. In Windows 7 this produced a nice looking border when the window was restored and no border when the window was maximized. In Windows 10 I can see no real difference between using the flag and using a ZERO for the flag when the window is RESTORED. However, when the window is MAXIMIZED, Windows 10 apparently reserves the SPACE for a border but never actually DRAWS anything in it, resulting in a narrow frame of "bleed through" from whatever is behind the maximized window.

    The solution is to not use the the WS_EX_OVERLAPPEDWINDOW flag in Windows 10 because the implementation of it is somewhat broken.

    Thanks helping me to realize what Microsoft has broken!

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Castorix31 81,831 Reputation points
    2020-11-12T12:13:51.483+00:00

    It is probably because of DWM
    I did a test that you can check in VB .NET (faster to do than in C/C++, but the code is the same) : VB_DWM_Test.zip
    I draw with Alpha = 255 on the border and I don't see it on my OS (Windows 10 1909)

    0 comments No comments