Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shell Integration Library WindowChrome with Drop Shadow

Tags:

wpf

shadow

Ive been googling this alot but can't find any working solution. Im using Shell Integration Library to cerate custom Window Chrome and I also need drop shadows for this window. Some say setting GlassFrameThickness to -1 do the trick but its not working for me. And Jeremiah Morrill suggested using DwmExtendFrameIntoClientArea. Ive tried that and it works, sort of. The shadows looks ok but when the window is shown it is first shown as a glass-frame and then a second later the real content is superimposed. This causes to much flickering for me. Is there any way to get rid of this flickering or is there any better way using only Shell Integration Library?

like image 235
Andreas Zita Avatar asked Dec 21 '22 14:12

Andreas Zita


2 Answers

I had a similar problem where it wouldn't display any shadow when using a custom chrome. It worked fine when using the glass.

I got a shadow by setting GlassFrameThickness="0,0,0,1". The glass didn't show and I got the shadow.

Be warned, the shadow is a simple RECT to Windows, so if you have a funky chrome with transparencies it may look funny.

Also if you support the maximized state be aware the you'll need to set a margin on your top-level panel element of "8,8,8,8" when in maximized mode. All other modes should be "0,0,0,0".

To alimbada, the WindowStyle defaults to None on custom chrome.

like image 136
Adam Wilson Avatar answered Jan 05 '23 09:01

Adam Wilson


The Shell Integration Library uses DwmExtendFrameIntoClientArea, plus handling of several Window messages to get the effects. If you're using the full window rect (i.e. no rounded corners) then setting it to (0,0,0,1) as suggested will give you the drop shadows as you want. If you want to simulate the rounded corners of Aero, then setting it to (8,8,8,8) will extend the glass frame enough that the corners also stay rounded, and then you're responsible for not drawing over the corners of the rectangle. The shape of the drop shadow doesn't change regardless of the glass frame thickness.

The flashing you're seeing when setting the thickness to -1 still exists even when not fully extending the glass frame. What's happening is the window is getting shown while the content is still compositing. What you can do is simplify the default UI so it displays quicker (or you can stage it, bringing in a simnple background first and then replacing it with something usable), or you can create and show the window off-screen, and then move it to the desired start location once the content has been rendered. The easy way to detect when it's probably ready is to invoke a DispatchTimer with Priority=Loaded. That should only get invoked once the basic first layout has been completed.

like image 42
Joe Castro Avatar answered Jan 05 '23 10:01

Joe Castro