 |
|
 |
I'm using graphics engiene Vega Prime and need to run another window above it with some graphics, which cutted by using SetLayeredWindowAttributes() with LWA_COLORKEY. The problem is that Layered window is flickering. I've tried it with DirectX and it works fine, so seems like OpenGL rendering of Vega is the origin of the problem. I understand, that it's drawing in different levels (i.e. soft & hardware rendering), but in Direct3D it somehow works completly clear.
If someone can say something useful related to this topic - I'll happy to hear.
|
|
|
|
 |
|
 |
I have the same problem and I figured out, that moving the layered window around the desktop isn't also that nice. It leaves the rendered picture on the same place (on the app in the background - desktop for example) and the content of the window is transparent (even if I don't render in the transparent layercolor).
|
|
|
|
 |
|
 |
Have you set WNDCLASS.hbrBackground != NULL? This causes flickering in my program, too. Buth there's still the problem, that I can't draw the window around
|
|
|
|
 |
|
 |
I tried to use the SetLayeredWindowAttributes() with an openGL window, but it doesn't work! The OpenGl window doesn't display anymore, but the transparency works fine with what remains of the dialog..
What might be very interesting, if it is possible to do, is to make for example a 3D cube (openGL cube), that spins on the desktop not inside a window. Of course, that's a possibility, but we can have a lot of fun applications..
Does anyone know if that's possible? can anyone provide a simple example?
Thanks a lot.
Satchel
|
|
|
|
 |
|
 |
It's Ok. The function SetLayeredWindowAttributes(), working on GDI level, and can not affect as you expect OpenGL context, which drown by hardware. Possible solution is drawing OpenGL in the buffer, reading of that buffer to array, and drawing using standard Windows GDI. Something like this I've already wrote for fun. It works good, but slow.
|
|
|
|
 |
|
 |
I have also try, using 2 ways. the first one is to do a render to bitmap but it very slow. The second, using a pbuffer is faster. The framerate is not incredible but sufficient for interactive purpose in screen resolution.
you can try it with my mp3 player available
here
|
|
|
|
 |
|
 |
I failed to set a child window to GWL_EX_LAYERED attributes, so is GWL_EX_LAYERED only valid to main window?
|
|
|
|
 |
|
 |
MSDN: Note that this cannot be used for child windows. Also, this cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC.
|
|
|
|
 |
|
 |
It looks fine but...
-> // Sets the window to 70% visibility.
-> m_pSetLayeredWindowAttributes(m_hWnd, 0, (255 / 70) * 100, LWA_ALPHA);
Thats not 70% !!!!!!
It must be ....
m_pSetLayeredWindowAttributes(m_hWnd, 0, (255 / 100) * 70, LWA_ALPHA);
|
|
|
|
 |
|
 |
255 * 0.7 = 178.5
(255 / 100) * 70 = 140 // Don't forget you're working with integer !
(255 * 70) / 100 = 178
Kochise
In Code we trust !
|
|
|
|
 |
|
 |
I saw the posts on trans and WMP and it got me curious. How does windows handle the overlay? I know WMP is a special case because it may in fact be changing bit in video memory, but what about other windows the use GDI? For example if I have a window with animation and a transparent window over that does the Windows(tm) render process invalidate any windows that are under a transparent window or is there some virtual bitmap of the window available in memory that is used to blend drawing?
|
|
|
|
 |
|
 |
Hello, is there a difference between : HMODULE hUser32 = GetModuleHandle(_T("USER32.DLL")); m_pSetLayeredWindowAttributes = (lpfnSetLayeredWindowAttributes)GetProcAddress(hUser32, "SetLayeredWindowAttributes"); (code in this article) and HINSTANCE hLibrary = LoadLibrary("USER32.DLL"); if (!hLibrary) return FALSE; pSetLayeredWindowAttributes = (lpfnSetLayeredWindowAttributes)GetProcAddress(hLibrary, "SetLayeredWindowAttributes"); FreeLibrary(hLibrary); Which methode is better ? Thanks !
|
|
|
|
 |
|
 |
GetModuleHandle will not load the library if it isn't already in the address space. It also doesn't increment the reference count on the library.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
 |
|
 |
Does it mean when I am done using this, I should NOT Free the handle using FreeLibrary?
Quick sample:
// Does not increment the library reference count ?
HMODULE hUser32 = GetModuleHandle(_T("USER32.DLL"));
m_pSetLayeredWindowAttributes = (lpfnSetLayeredWindowAttributes)GetProcAddress(hUser32, "SetLayeredWindowAttributes");
// decrement the library reference count
if (hUser32)
FreeLibrary(hUser32);
|
|
|
|
 |
|
 |
Hi,
I use
SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
and m_pSetLayeredWindowAttributes(hWnd, 0, 255 * 0.5, LWA_ALPHA);
to make a window transparent. But when I set
m_pSetLayeredWindowAttributes(hWnd, 0, 255, LWA_ALPHA);
to remove the transparancy, the drawing of the window is very slow... is there a there way to set the original state of the window ? or to remove the WS_EX_LAYERED style (I tried SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | ~WS_EX_LAYERED); but it didn't work).
Thanks for help !
|
|
|
|
 |
|
 |
try SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) & ~WS_EX_LAYERED)
|
|
|
|
 |
|
 |
yes I have been having the same problem and am trying everything to get it to work but it just wont take. using
SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) & ~WS_EX_LAYERED)
should clear the WS_EX_LAYERED flag, but the window still renders very slowly as if it were layered, i have also tried calling
SetWindowPos(g_hwndWindow, HWND_TOP, 0,0,0,0, SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOREPOSITION|SWP_NOSENDCHANGING|SWP_NOSIZE|SWP_NOZORDER);
RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
to flush the windowlong flags into the system but it doesn't do anything. the only crutch i have found is to just create a new window (without the layered style) over the old one and swap it out when my blending is done, but this is very ugly and undesirable as you see quick flash of the new window being created.
does anyone else have any ideas on how to fix this issue
|
|
|
|
 |
|
 |
if I change the color of dialog
how can i let it trans
|
|
|
|
 |
|
 |
Dude! Get some smaller units or a faster PC! Sheesh!
|
|
|
|
 |
|
|
 |
|
 |
(This is a slightly edited cross-post of my question at http://www.codeproject.com/useritems/trans.asp?&forumid=957&select=31147#xx31147xx)
Bernhard Hammer provides a neat sample program showing transparency at http://www.codeproject.com/useritems/trans.asp (thanks Bernhard!).
I have need to build translucent windows like this in my application. The sample works great in all the places I need except the most important for my program. It does not work properly with Windows Media Player. I'm running version 7.00.00.1956, but can run another version if that would help. Of course, I'm running on Win2000.
What I need is a window that is about 50% translucent, floating above the Windows Media Player (WMP), so the running movie shows through. When WMP is running in its browser-like mode, it shows through the overlaying translucent window just fine. Once I start playing a video in WMP, the rectangle of the video goes dark in the overlaying window. I've tried this playing an MPEG and an AVI, with similar results in both cases.
For my application, I don't need to make the WMP window itself translucent. But, as an additional data point, if you use Bernhard Hammer's sample application to set the WMP translucent, WMP itself turns the rectangle of the playing video dark. And, once you quit WMP, you get some odd remnants left over on the screen.
So, does anyone know how to make a translucent window that overlays WMP and properly shows WMP's playing video through the overlaying window? Is there something special I need to do in my use of WMP? I'm using WMP as an Active X control in my MFC Visual C++ application.
|
|
|
|
 |
|
 |
Hi.
I tried to use windows media player (same version as you) with the transparancy code provided in the article, and it seamed to work...
But how it will act when WMP is an ActiveX is another story... Havent tested... Maybe its a video driver issue?
On my home computer (the above I tried on my work computer with win2000) I'm running whistler beta and there I have some problem with WMP and transparency. Havent tried with my program, but MWP has som own transparacy stuff that fades away play-controls when running in fullscren. The transparay there flickers. That started when I upgraded to the newest Nvidia drivers....
|
|
|
|
 |
|
 |
My application is using WMP via ActiveX, but my tests were also done with Microsoft's stand-alone WMP player. I had the same solid-gray-box results there.
One theory I've heard is WMP is using DirectShow, writing the video directly to hardware. So the Windows graphic space has no pixels in the video to alpha blend with the overlaying translucent window.
If this is correct, I suppose it's possible you could get different behavior on different hardware.
I don't claim to be an expert in this area - just bumbling my way through.
|
|
|
|
 |
|
 |
ok... I have tried it on my home computer now, and sure enough there is a gray box instead of transparance. The graphics card is a Geforce2, and the one at work (where the tránsparancy worked) was a Matrox...
|
|
|
|
 |
|
 |
Hi Guyz,
The WMP (through DS) uses various techniques to display videos. The options depend very much on your video-card (e.g. Overlay-Mode).
Transparency for Movies (if thats what you want) is not possible with Windows2k (unless you have very advanced video-drivers) or you provide a plugin (rendering filter) that displays the movie using standard GDI-BitBlts on a standard DC (slow and ugly).
Alternative1:
Provide a filter that emulates transparency for direct show - that could be done and the results do not have to be ugly or slow since you dont need to replace the rendering filter. You could supply an additional transformation filter. But, thats some work to do since its not too easy writing such filter... DS for 2K doesnt provide on the fly mixing, you would have to create it on your own - wouldnt try.
Alternative2:
Use WindowsXP and its DS features. DS for XP provides on the fly mixing. Its very handy and requires just a few lines of code for you to mix a video with a bitmap. Thats how I would emulate transparency for a video.
Hope that helps...
Greetings,
Till
|
|
|
|
 |