Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6103425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:43:38+00:00 2026-05-23T13:43:38+00:00

I’m writing a sample application that is both GDI and WPF. I have a

  • 0

I’m writing a sample application that is both GDI and WPF. I have a WPF window that has a button with a click handler with the following body:

this.DialogResult = true;

This closes the WPF dialog as it should. However, when closing this dialog, there is no “fade” effect on Windows 7/Vista. Alternatively, using a GDI window, the fade works. I’m either doing something wrong or this is the default behavior when closing WPF windows. Additionally, using the X button to close performs the same unwanted behaviour.

Ideally, I’d like both types of windows to close with the same style. Has anyone else encountered this? Is this something easily fixed for all of my WPF windows?

EDIT: Ok so I noticed something very interesting. When the window to closed is not over the parent window (e.g. it’s moved to a different monitor) and closed, the usual fade fires correctly! However, if the window to close is over the parent window, no fade occurs. Lovely!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:43:38+00:00Added an answer on May 23, 2026 at 1:43 pm

    I’ve come up with a solution, although I think it’s still quite the hack to actually have fade working. I also tested with a pure WPF application and the window will still only fade when not overlapping its parent window. If anyone has a better solution than the code below, please let me know!

    public class WindowBase : Window
    {
        private bool hasFadeCompleted = false;
    
        protected override void OnClosing(CancelEventArgs e)
        {
            if (this.hasFadeCompleted)
            {
                base.OnClosing(e);
                return;
            }
    
            e.Cancel = true;
    
            var hWnd = new WindowInteropHelper(this).Handle;
            User32.AnimateWindow(hWnd, 1, AnimateWindowFlags.AW_BLEND | AnimateWindowFlags.AW_HIDE);
    
            Task.Factory.StartNew(() =>
            {
                this.Dispatcher.Invoke(new Action(() =>
                {
                    this.hasFadeCompleted = true;
                    this.Close();
                }), DispatcherPriority.Normal);
            });
        }
    }
    
    public static class User32
    {
        [DllImport("user32.dll")]
        public static extern bool AnimateWindow(IntPtr hWnd, int time, uint flags);
    }
    
    public static class AnimateWindowFlags
    {
        public const uint AW_HOR_POSITIVE = 0x00000001;
        public const uint AW_HOR_NEGATIVE = 0x00000002;
        public const uint AW_VER_POSITIVE = 0x00000004;
        public const uint AW_VER_NEGATIVE = 0x00000008;
        public const uint AW_CENTER = 0x00000010;
        public const uint AW_HIDE = 0x00010000;
        public const uint AW_ACTIVATE = 0x00020000;
        public const uint AW_SLIDE = 0x00040000;
        public const uint AW_BLEND = 0x00080000;
    }
    

    I’m still surprised that this hasn’t been an issue for anyone else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.