[Windows] Remove unnecessary code, implement hasShadow and setHasShadow in frameless mode #110
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
hasShadowandsetHasShadowin frameless mode (setAsFrameless())Note:
hasShadow()andsetHasShadow()will only work in frameless mode. Otherwise (TitleBarStyle.normal/hidden),hasShadow()will always return true.This is because in Windows, according to my experience, a window's shadow will only be removed/hidden if the client area is fully covering the window frame (
MARGINS margins = {0, 0, 0, 0}; DwmExtendFrameIntoClientArea(hWnd, &margins[has_shadow_]);).
However, if the app doesn't cover the window frame, even if only on one side (
MARGINS margins = {0, 0, 1, 0}; DwmExtendFrameIntoClientArea(hWnd, &margins[has_shadow_]);), the shadow will reappear.
Also note that to enable resizing in frameless mode, You must wrap the app with
VirtualWindowFramewith allResizeEdges enabled. However, this will only enable mouse resize border inside the app, unlikeTitleBarStyle.hidden, which still has invisible frame with resizable border on the left, bottom, and right side of the app.In the future, I would like to replicate Microsoft Office apps, which has 4 separate windows on each border with class name
MSO_BORDEREFFECT_WINDOW_CLASSandWS_EX_TOOLWINDOWstyle. I think it also draws/paints a fake shadow on its own and is used to resize the app outside the app. I took this conclusion because when I hid that window using WinSpy+, the shadow disappears and I can no longer resize the app outside the window.If we succeed, we don't have to worry about not being able to interact with any widget on the border of the app while still enabling resize border and window shadow.