window transparency
BlitzMax Forums/BlitzMax Beginners Area/window transparency
| ||
The following code turns the window frame transparent, but not the drawing area. Also when moved, the window leaves graphics where it was. What am I missing to get the entire window transparent, and not having it leave graphics behind? Extern "Win32" Function SetLayeredWindowAttributes(HWND:Int,COLORREF:Int,bAlpha:Byte,dwFLAGS:Int) EndExtern Const LWA_ALPHA=2 Graphics 320,240 Local alpha:Int = 192 Local hwnd:Int = GetForegroundWindow() Local tmpStyle:Int = GetWindowLongW(hwnd, GWL_EXSTYLE) If Not (tmpStyle & WS_EX_LAYERED) Then SetWindowLongW(hwnd, GWL_EXSTYLE, tmpStyle|WS_EX_LAYERED) SetLayeredWindowAttributes(hwnd,0,Byte(alpha*255),LWA_ALPHA) SetClsColor 192,192,192 While Not KeyHit(KEY_ESCAPE) Cls DrawText("Test",8,8) Flip Wend End |
| ||
Interesting start! Another glitch: If another window pops up above the transparent window, the titlebar and such doesn't get redrawn after you move it away. |
| ||
1. It needs at least XP + enabled Luna 2. The 3D Accelerated Part won't become transparent, only Windows GUI elements. Thats because the rendering draws over the original content of that GUI Element with its own data. 3. I wouldn't use it too much. Don't forget that WinXP has no 3D acceleration ... so alpha is done through CPU (unless you enable the alpha effect from the 3D drivers or use WindowBlinds) |
| ||
2. So would using a canvas to fill the window make the entire window transparent? It seem like other are doing this, but then again I have no clue how they do it, but if you look at this example: ![]() Its a sticky note program, which does have transparent notes as an option. But how its done, thats the question. |
| ||
by borderless windows and your above winapi function most likely. Or if this is really tablet stuff then potentially .NET 3 + .NET tablet component Beeing transparent does not mean its hardware accelerated, just that it is transparent. |
| ||
You will have to use UpdateLayeredWindow ( http://msdn2.microsoft.com/en-us/library/ms633556.aspx ), after you created a Device Context in memory and rendered the alpha image into a bitmap. You can even create alpha gradients or shadows with this method. And it requires at least Windows 2000 and does not work with the Graphics window or a canvas. ;) |