Window transparency dilemma



I'm seeing some strange PM behavior that I can't quite understand, apparently relating to whether or not a window was created in a given process.

I'm trying to emulate transparent window behavior as closely as possible and I've had good success so far, with only one minor drawing glitch. I've been able to re-capture the bitmap underneath the window (and superimpose my transparent bitmap over it) by triggering off of when my window's visible region changes (WinSetVisibleRegionNotify, WM_VRNENABLED/WM_VRNDISABLED). My logic here is that if the user changes the Z-order of a window underneath my transparent window, my transparent window's visible region will change. I know I'll never be able to capture updates that windows below my transparent window are doing in their client areas, but at least when the user moves them around I can get these changes and update my bitmaps accordingly.

This much is working really well. When my visible region changes, I hide my window, re-capture the bitmap, and show it again.

The drawing glitch is... if the window being moved happens to exist in the same process (and for that matter, message queue thread in this case) as the transparent window, it all goes to hell. The transparent window hides itself, but the windows below it never redraw before the window re-captures the bitmap again.

So if I had another one of my app's windows underneath the transparent window, and I click and drag its titlebar to bring it to the top and move it, the desktop window below it never gets a chance to redraw to cover over where the window used to be. Also, the hiding of the transparent window becomes ineffective because the desktop doesn't redraw there either! This is very strange because if I'm dragging the titlebar of a window from another process, it all works absolutely perfectly!

So it looks like there might be some kind of "short-circuit" in the full window dragging behavior, where my transparent window hides and re-shows itself before the other windows ever get a chance to know what happened. This might have been viewed as an optimization in the PMShell, eliminating some seemingly unnecessary window message traffic, but it's making this task absolutely impossible.

Any suggestions on how I can force the full dragging behavior to allow the other windows to get a chance to draw themselves? My transparent window's style is: CS_MOVENOTIFY | CS_CLIPSIBLINGS. Its parent and owner are HWND_DESKTOP.

My window procedure for the transparent window has a flow like this:

case WM_CREATE:
// Create memory device contexts/HPS for offscreen bitmaps
// Create bitmap handles of the appropriate size
// Initialize other stuff
WinSetVisibleRegionNotify( myWin, TRUE );
...
break;
case WM_MOVE:
// Perform a bitblt from the window HPS to offscreen memory HPS
...
break;
case WM_PAINT:
// Perform a bitblt from memory HPS to the window HPS in the
// visible region only if the visible region is enabled.
break;
case WM_VRNDISABLED:
// Increase visible region counter (window ULONG) to avoid recursion.
vrnNotificationCount = WinQueryWindowULong( myWin, ... );
WinSetWindowULong( myWin, ..., vrnNotificationCount + 1 );
if ( !vrnNotificationCount )
{
WinShowWindow( myWin, FALSE );
}
break;
case WM_VRNENABLED:
vrnNotificationCount = WinQueryWindowULong( myWin, ... );
WinSetWindowULong( myWin, ..., 0 );
if ( vrnNotificationCount )
{
WinShowWindow( myWin, TRUE );
WinPostMsg( myWin, WM_MOVE, NULL, NULL );
// Originally WinSendMsg... made no difference.
}
break;

--
[Reverse the parts of the e-mail address to reply.]
.



Relevant Pages

  • Re: Is it possible to force a covered window to repaint itself ?
    ... One possibility would be to take a screenshot of the entire screen, ... this onto a fullscreen window that you have created. ... Everything is OK with the transparent window design, ... covered window beneath it can repaint itself, stylus events are ...
    (microsoft.public.pocketpc.developer)
  • Re: Redraw Transparent Window
    ... I listed the main points and styles of my transparent window here: ... you should only get the underlying window to redraw ... BitBlt from a memory device context (i.e., get the underlying window to draw ...
    (microsoft.public.win32.programmer.ui)
  • Re: Window transparency dilemma
    ... After calling WinBeginEnumWindows, ... My transparent window has the desktop as ... pair of messages to my transparent window. ... window ULONG flag), beg the windows underneath to draw themselves, do ...
    (comp.os.os2.programmer.misc)
  • Re: Window transparency dilemma
    ... My transparent window has the desktop as its parent/owner. ... When a completely different window from within the same process, with the desktop also as its parent/owner loses the window focus by the user clicking on the desktop, I get a WM_VRNDISABLE/ENABLE pair of messages to my transparent window. ... When this happens, I hide my transparent window, beg the windows underneath to draw themselves, do the DosSleep, and then capture the bitmap where my window used to be and draw the transparent window again. ...
    (comp.os.os2.programmer.misc)
  • Re: Copying Bitmap
    ... Remember I said that my code does not work when the window is obscured by another window. ... CDC dc_bitmap; ... // Copy output bitmap onto display target ... Add your control notification handler code here ...
    (microsoft.public.vc.mfc)

Loading