Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如果开启了对话框阴影,双击对话框阴影即消失 #5

Closed
halx99 opened this issue Jun 23, 2020 · 3 comments · Fixed by #6
Closed

如果开启了对话框阴影,双击对话框阴影即消失 #5

halx99 opened this issue Jun 23, 2020 · 3 comments · Fixed by #6
Assignees
Labels
bug Something isn't working enhancement New feature or request
Milestone

Comments

@halx99
Copy link
Member

halx99 commented Jun 23, 2020

win7以上可考虑如下方式:

static bool IsCompositionEnabled()
{
	static int NTVer = 6;
	if (NTVer < 6) return false;

	BOOL enabled = FALSE;
	DwmIsCompositionEnabled(&enabled);

	return enabled;
}
if (bShadow) {
       if(IsCompositionEnabled()) {
		// apply shadow
		int v = 2;
		DwmSetWindowAttribute(m_hWnd, 2, &v, 4);

		MARGINS margins = {1, 1, 1, 1};
		DwmExtendFrameIntoClientArea(m_hWnd, &margins);
	} else {
		; // Use CS_DROPSHADOW
	}
}
@halx99 halx99 added bug Something isn't working enhancement New feature or request labels Jun 23, 2020
@halx99 halx99 added this to the 1.0.0 milestone Jun 23, 2020
@halx99 halx99 self-assigned this Jun 23, 2020
@halx99
Copy link
Member Author

halx99 commented Jun 23, 2020

Acording to CS_DROPSHADOW referenced from https://docs.microsoft.com/en-us/windows/win32/winmsg/window-class-styles , change HWND_NOTOPMOST to HWND_TOPMOST can solve this issue.

@halx99
Copy link
Member Author

halx99 commented Jun 23, 2020

Update: 如果是双显示器,双击对话框,阴影只会在主显示器消失,将对话框拖入副显示器有阴影,再拖回主显示器无阴影,如此往复 【神奇】

@halx99
Copy link
Member Author

halx99 commented Jun 23, 2020

最终应当使用DWM实现

  • 严格按照微软官方文档来
  • 非Top-level窗口不适合使用CS_DROPSHADOW
  • CS_DRAWSHADOW只适用于短生命周期的top-level窗口,例如弹出菜单
  • 目前DWM阴影和Layered不兼容,如果同时开启,切后台回前台,阴影会消失

This was referenced Jun 23, 2020
@halx99 halx99 linked a pull request Jun 27, 2020 that will close this issue
@halx99 halx99 closed this as completed in #6 Jun 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant