Hi,

I'm having some problems with flickering in a popup window that
I'm trying to do some alpha blending with. The alpha blending
source I'm using is given on the MS Web site as "DoAlphaBlend"
and works x-platform.

Anyway, here what I'm doing:


    [*]Make sure the popup window doesn't have a background brush (wc.hbrbackground)
    [*]Hide the window. (to get screen "artifacts", ie, the background)
    [*]Show the window (you can't really see it now)
    [*]Alpha blend a bitmap onto my popup's DC


    The problem is that the Hide/Show causes a very irritating visual
    hum (flicker).

    Any ideas?

    I can't copy the area of the screen to a mem DC because my
    popup is already there. If I do this my popup ends up looking
    like a an 80's music video (mirror)....

    Thanks!
Posted on 2001-10-01 13:24:19 by Xtreme
I've posted another method for making a window transparent, wich doesn't cause flickering:



.386
.model flat, stdcall
option casemap :none



include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib



.data
szClassName db "Notepad", 0
szApiName db "SetLayeredWindowAttributes", 0
szDllName db "user32.dll", 0

hwnd dd 0



.code

start:
; open notepad and run this example to make notepad transparent
invoke FindWindow, addr szClassName, 0

mov hwnd, eax

push -20
push eax
invoke GetWindowLong, eax, -20 ; GWL_EXSTYLE

mov edi, eax
mov eax, 80000h ; WS_EX_LAYERED
or eax, edi

invoke SetWindowLong, hwnd, -20, eax

invoke LoadLibrary, addr szDllName

push eax ; for FreeLibrary

invoke GetProcAddress, eax, addr szApiName

push 2h ; LWA_ALPHA
push 96h ; transparent level (0-255). 0 = invisible, 255 = visible
push 0
push hwnd
call eax

call FreeLibrary

invoke ExitProcess, 0
end start
Posted on 2001-10-01 16:59:29 by bazik
bAZiK,

I've studied your example and it works great. But unfortunately
I need a method that will work cross-platform. Win95 included.
Otherwise I would run with your sample.

Thanks!
Posted on 2001-10-02 08:49:47 by Xtreme

1. Make sure the popup window doesn't have a background brush (wc.hbrbackground)
2. Hide the window. (to get screen "artifacts", ie, the background)
3. Show the window (you can't really see it now)
4. Alpha blend a bitmap onto my popup's DC

The problem is that the Hide/Show causes a very irritating visual
hum (flicker).


I hope I got it right :) If the flicker occurs between steps 2 and 3, why don't you try to create an invisible window in the first place?
If it occurs while alpha blending you might want to have a look at Iczelion's site, there should be a 'flicker free animation' example somewhere (I guess it uses double buffering).


Tola
Posted on 2001-10-02 10:06:24 by Tola
What I'm actually doing is alpha blending a new bitmap on my
popup after every hide/show sequence (which occurs every
20ms).

The hide/show steps clear the old bitmap and gives me the
screen background (artifacts) because my window has no
background brush and I don't handle WM_ERASEBKGND or
WM_PAINT.

The purpose is to make a 50% (or so) transparent figure (car,
robot, airplane) move about on the desktop.

Basically I'm trying to fake Win2000's Layered Windows....
Posted on 2001-10-02 18:17:54 by Xtreme
The hide/show steps clear the old bitmap and gives me the screen background (artifacts)

Maybe you could try to save the background in a memory dc and just overwrite the bitmap (at least that's what I'd do :) )
Posted on 2001-10-03 11:22:27 by Tola
Tola,

(EDIT: Keep in mind that I'm doing an animation)

Saving a section of the screen to a memDC is what I want to do,
but I'd have to hide my window to get the screen behind it. This
solution has the same problems as my current one:

1. Hide window
2. Copy a rectangle of the screen
3. Show window
4. BitBlt memDC to popup window

Same hide/show sequence....

Is there anyway to have the GDI to ignore a window? Does
anyone know the "internal" concepts behind Win2K's Layered
Windows?

Thanks!
Posted on 2001-10-04 10:42:09 by Xtreme