Layered ATL Window
-
I have a Browser Helper Object that I have created and I want it to create a Window using the API function CreateWindowEx so that I can using the window layering extended style described here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwui/html/layerwin.asp My question is how do I create a window using this API in my ATL project? I have tried creating a class that inherates from CWindows and then using the http://www.codeproject.com/w2k/QDWndTransparency.asp?print=true But this does not have the same effect. I really need a faded window using: hwnd = CreateWindowEx(WS_EX_LAYERED | WS_EX_TRANSPARENT, gszFade, gszFade, WS_POPUP | WS_VISIBLE, prc->left, prc->top, 0, 0, NULL, (HMENU)0, ghinst, NULL); My goal is to have a window placed over the browser main window that I can then draw on. Any suggestions? Thank you much, Mike
-
I have a Browser Helper Object that I have created and I want it to create a Window using the API function CreateWindowEx so that I can using the window layering extended style described here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwui/html/layerwin.asp My question is how do I create a window using this API in my ATL project? I have tried creating a class that inherates from CWindows and then using the http://www.codeproject.com/w2k/QDWndTransparency.asp?print=true But this does not have the same effect. I really need a faded window using: hwnd = CreateWindowEx(WS_EX_LAYERED | WS_EX_TRANSPARENT, gszFade, gszFade, WS_POPUP | WS_VISIBLE, prc->left, prc->top, 0, 0, NULL, (HMENU)0, ghinst, NULL); My goal is to have a window placed over the browser main window that I can then draw on. Any suggestions? Thank you much, Mike
Try this: typedef BOOL (__stdcall *PFUNCSETLAYEREDWINDOWATTR)(HWND, COLORREF, BYTE, DWORD); PFUNCSETLAYEREDWINDOWATTR m_pfSetLayeredWindowAttributes; HMODULE hUser32 = GetModuleHandle(_T("User32.dll")); if (hUser32) { m_pfSetLayeredWindowAttributes = (PFUNCSETLAYEREDWINDOWATTR)::GetProcAddress(hUser32, "SetLayeredWindowAttributes"); if (m_pfSetLayeredWindowAttributes) { ::SetWindowLong(m_hWnd, GWL_EXSTYLE, GetWindowLong(GWL_EXSTYLE)^WS_EX_LAYERED); // After the SetWindowLong call, the layered window will not become visible // until the SetLayeredWindowAttributes function has been called for this window m_pfSetLayeredWindowAttributes(m_hWnd, 0, (BYTE)255, LWA_ALPHA); } } and then somewhere // Sets the transparency of the window void MakeTransparent(int nAlpha) { if (m_pfSetLayeredWindowAttributes) m_pfSetLayeredWindowAttributes(m_hWnd, 0, (BYTE)nAlpha, LWA_ALPHA); }