page 1 of 1
Comments: 17 | Views: 899

On Windows 7, I'm trying to write something which overlays a top-level layered window above my app's main window to create some visual effects. The intention is to make it look like everything is part of the main window even though there's really another window above it rendering some of the effects.

 

It goes wrong if the main window is opening / closing / minimizing / etc. because of the DWM's animations. The top-level effects window is positioned so that it's on top of where GetWindowRect reports the main window to be, but the on-screen representation of the main window isn't really there. The main window is being transformed & animated in 3D space away from or towards the reported window location. So my top-level effects window is sitting in space looking really weird and drawing its effects over other windows. Smiley

 

I'd be happy to simply disable my effect while the DWM animations are playing. Problem is I can't see a way to detect them. I'd like to do it properly in case future OS versions make the animations longer or shorter. i.e. I'd prefer not to use a kludge that says "don't apply my effects if the window was only opened/restored/maximized 1 second ago."

 

(I don't want to turn off the DWM animations for the main window.)

 

There are a bunch of stats returned by DwmGetCompositionTimingInfo but I'm not sure if any of them are useful for detecting the animations. It's not very clear to me what the stats are for but I'm guessing it's to do with syncing multimedia or measuring performance rather than seeing what's going on with a particular window.

 

There's also some DWM APIs like DwmFlush, DwmAttachMilContent, DwmGetGraphicsStreamTransformHint, DwmGetGraphicsStreamClient which (despite dating back to Vista) still seem to be undocumented (beyond their argument/return types). Is there some fuller documentation for the DWM API somewhere that I'm missing?

 

figuerres
figuerres
???

are you using WPF or GDI+ ?

 

with wpf you can't do it in one window?

figuerres
figuerres
???

well one thing i was thinking of was to make a dll that was C++/CLI with just the UI bits only.

so 90% of the app logic would stay in raw C++ and would just have calls to an interface / with the impliemtation in C++/CLI

minimal impack to the perf of the app and to the non-ui code.

 

honestly there comes a point when IMHO it becomes time to embrace a chnage, WPF was made for making better visuals that in apps and to be able to do things that were difficult or impossible with GDI and WInforms.

sounds like you are getting into that area or right on the edge of it.

 

just as a bit of input - Over the last few months I have been getting more into SIlverlight as our clients use a lot of web stuff and they have been asking for more complex things that really needed silverlight or flash to do them.

 

so with silverlight what i have found is that on the code side i can't really see any huge change from winforms to xaml in event handlers and other mundane coding.

yes xaml is very different from the classic forms code but even then most of the code that interacts with the markup is not that far different.

 

now things like building a dependancy property - a bit funky but not hard to follow.

 

just so you know that it's some work but not all that hard if you take a bit of time and study some examples.

figuerres
figuerres
???

well a control is an hwnd .....

and that is in an hwnd.....

 

it would seem like you could create a window that is a child of the "main" window and make it act like a docking panel

that might do it for you?

 

just don't try this with anti-matter Smiley  BOOM!

CannotResolveSymbol
CannotResolveSymbol
{insert caption here}

You don't need to "make it act like a docking panel" (or provide any behavior at all, really), just setting the parent of your effects window to your main window should be sufficient to make it behave as though its part of the main window from the DWM's perspective (along with the obvious change to use coordinates relative to the window).

 

Downside:  if your child window has a title bar, it will most likely no longer be drawn by the DWM.  Also, you can get some weirdness WRT keyboard focus when doing this; if your effects window is just a transient thing, this shouldn't be an issue (and it won't be any more of an issue than when you were using a separate window).

figuerres
figuerres
???

Leo i was replying to your "use a window" as you wrote it...  IE a classic GDI window.

 

perhaps not a child window but ... like a child.  hey it's a hack .... who knows....

 

thats why i was thinking get out of gdi .... or make a custom window class that takes over the layering and drawing.

CannotResolveSymbol
CannotResolveSymbol
{insert caption here}

Wait, what?  I'm not sure I follow you here...  are you using this window as an overlay to add visual effects to your application or are you using this window to draw a custom preview thumbnail?

 

At any rate, anything you do on this is a hack.  You're only going to get so far before you need to move to a proper animation framework (through WPF, through the Windows 7-specific Animation Manager, or through a third-party framework).  Might as well do it right from the start than have to come back in a year and rewrite everything when you need to do something that's beyond what your hack-around can do.

figuerres
figuerres
???

it's an overlay on the main app window. he is creating visual effects to make the app window have some look.

when the win7 dwm starts animating the close / open or other effects his second window gets out of sync with what dwm is doing.

 

 

As you say, it's a bit of a hack and you aren't really using DWM thumbnails in a way anyone ever intended them to work, which is probably why it doesn't. I suspect the best you'll get is to disable DWM animations for your window, although I have a suspicion that something like Flip3D may make your UI break also.

page 1 of 1
Comments: 17 | Views: 899
Microsoft Communities