Is it possible to use WM_NCPAINT and still get shadow outside the window on Aero?

I am currently trying to create a top-level window in Windows Forms with a custom frame (using DevExpress' SkinManager.EnableFormSkins

function
) and still have a shadow around the window when running on Windows 7 Aero.

Currently the window looks like this:

enter image description here

and I want it to look like this:

enter image description here

(I have a soft shadow around the window).

I've done a lot of research and try and error, including using CS_DROPSHADOW

, asking for DevExpress support , reading in SO format , other blogs, and MSDN documentation .

However, nothing brings shadows to my window.

While I believe my requirement is simply impossible to achieve, I still want to take a chance and ask about SO here.

(I even thought about pretending to have my own Aero window behind my actual window, but failed to implement ...)

My question is:

Is it possible to have a custom area window without a client (NC) and still get a shadow around that window when Aero is active?

+3


source to share


2 answers


To summarize and close your own question, after a lot of effort I think this is simply not possible.

What I have achieved is to simulate the shadow using the technique used in the Locus Effects article .

Basically use a transparent window, dynamically use PNG alpha blending as a simulated shadow, and paint on the sides (and corners) of the window; move the transparent window when the real window moves, etc.



This works well, but it still looks unprofessional to the user, because small things like the shadow disappear when another window is activated don't behave as expected.

So my conclusion: Impossible with reasonable effort.

0


source


Can you try custom shadow scoring shapes like this:



/// <summary>
/// Base class for drop shadows forms.
/// </summary>
public partial class DropShadowForm : Form
{
    private const int CS_DROPSHADOW = 0x00020000;

    /// <summary>
    /// Creates new instance of DropShadowForm.
    /// </summary>
    public DropShadowForm()
    {
        InitializeComponent();
    }

    /// <summary>
    /// Overrides from base class.
    /// </summary>
    protected override CreateParams CreateParams
    {
        [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
        get
        {
            CreateParams parameters = base.CreateParams;

            if (DropShadowSupported)
            {
                parameters.ClassStyle = (parameters.ClassStyle | CS_DROPSHADOW);
            }

            return parameters;
        }
    }

    /// <summary>
    /// Gets indicator if drop shadow is supported
    /// </summary>
    public static bool DropShadowSupported
    {
        get
        {
            OperatingSystem system = Environment.OSVersion;
            bool runningNT = system.Platform == PlatformID.Win32NT;

            return runningNT && system.Version.CompareTo(new Version(5, 1, 0, 0)) >= 0;
        }
    }       
}

      

0


source







All Articles