question

SteveValliere-8275 avatar image
0 Votes"
SteveValliere-8275 asked RitaHan-MSFT edited

Transparent borders when maximized?

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-generalwindows-api-ui
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @SteveValliere-8275, could you show a snapshot to demonstrate this issue? This maybe related to different Windows version features, so what's your Windows 10 version? You can check to see if transparency effect is enabled or not.
38838-111.png

0 Votes 0 ·
111.png (7.7 KiB)

Transparency effects were enabled, but turning them off (and then restarting everything) had no effect on this issue.

Explaining the screen shot: My system has three monitors: 1024x1280, 3840x2160, and 1280x1024, respectively. Non-existent areas show as black, outside any windows My program is maximized on the leftmost monitor and you can clearly see the bright border around the client area -- that is part of the MONITOR's screen and does not show if I maximize something like the Windows 10 Settings program on that screen (I'm in dark mode, so a light colored frame would show very clearly.) FWIW, I use the center screen for development work and the right/left for testing on different display aspects.

When I run with different colored backgrounds, the unexpected outer frame colors are visible to the right/left of the title bat and menu, too. They may exist above the window as well.

screen.png


0 Votes 0 ·

Thanks for demonstration for this issue. I test on Windows 10 2004 (OS Build 19041.572) with same setting with yours like dark mode and black desktop etc, both system application like settings and a simple Win32 C++ window application work for me in maximized mode and normal mode. It does has a white border but very light not as much clear and bright as yours. We may need narrow down this issue further as below:
1. Since there are three monitors in your environment, and it seems your own application and system setting app are not in the same monitor, if this is true, could you check if the system setting app on the leftmost monitor to see if it reproduces the same issue?

0 Votes 0 ·

(continue) 2. Since you mentioned that "this happens even in the simplest "Hello World"-type project", so can you create a simple Win32 UI application based on the template and paint the window's background to black using the following code. Test to see if this application reproduce the same issue? If it does, share the snapshot.
3. Can you Run winver and share your version and build information?

 case WM_PAINT:
     {
         PAINTSTRUCT ps;
         RECT clientRect;
         HDC hdc = BeginPaint(hWnd, &ps);
         GetClientRect(hWnd, &clientRect);
         FillRect(hdc, &clientRect, (HBRUSH)GetStockObject(BLACK_BRUSH));
         EndPaint(hWnd, &ps);
     }
     break;
0 Votes 0 ·
Show more comments
SteveValliere-8275 avatar image
0 Votes"
SteveValliere-8275 answered

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!

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Castorix31 avatar image
0 Votes"
Castorix31 answered

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)


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.