积极答复者
求助:CreateWindow创建的窗口会出现在win10所有的虚拟桌面里

问题
-
源码如下
WNDCLASSEX wcex; HINSTANCE hInstance = GetModuleHandle(NULL); static int hasRegistered = 0; if (hasRegistered == 0) { hasRegistered = 1; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = IndicatorWndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = NULL; wcex.hCursor = NULL; wcex.hbrBackground = NULL; wcex.lpszMenuName = NULL; wcex.lpszClassName = _T("SHARING INDICATOR"); wcex.hIconSm = NULL; ATOM ret = RegisterClassEx(&wcex); } *hWnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_LAYERED | WS_EX_NOACTIVATE, _T("SHARING INDICATOR"), NULL, WS_POPUP | WS_DISABLED, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); SetLayeredWindowAttributes(*hWnd,RGB(255,255,255),0,LWA_COLORKEY);
这样生成的窗口会出现在所有的虚拟桌面上...求问如何能让它只出现在当前桌面上 是否与Create时使用的Style有关? 谢谢
答案
-
我测试了一下是可以重现的,好像跟WS_EX_NOACTIVATE的窗口扩展风格有关。我给一个创建好的窗口用SetWindowLongPtr 添加这个扩展风格,仍然会出现这个问题。
建议将这个问题发到Connect去,然后等待微软的人给的回复。也许是by design的问题,也有可能是bug。https://connect.microsoft.com/VisualStudio
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- 已标记为答案 水仓莉丝佳 2015年10月15日 2:33
全部回复
-
我测试了一下是可以重现的,好像跟WS_EX_NOACTIVATE的窗口扩展风格有关。我给一个创建好的窗口用SetWindowLongPtr 添加这个扩展风格,仍然会出现这个问题。
建议将这个问题发到Connect去,然后等待微软的人给的回复。也许是by design的问题,也有可能是bug。https://connect.microsoft.com/VisualStudio
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- 已标记为答案 水仓莉丝佳 2015年10月15日 2:33