WPF:我如何创建一个自定义模式对话框闪光? [英] WPF: How do I make a custom modal dialog flash?

查看:788
本文介绍了WPF:我如何创建一个自定义模式对话框闪光?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,当你打开一个模态对话框,并尝试点击它的父窗口中的模态对话框的标题栏闪烁。当创建一个自定义的,无国界,无边框,在WPF窗口中,你失去所有功能,而且必须自己重建。我看着高和低,为我的生活不能弄清楚如何让我的模态窗口闪烁。虽然它仍然发出哔哔声...



我想我将不得不留意的WndProc中的某些事件(县),我会要处理,但我无法找出哪些事件或如何做到这一点。我试过看着窗口变化,窗口改变事件还有WM_ACTIVATE事件无济于事。我敢肯定,我只是失去了一些东西简单,但我希望有这方面的帮助。谢谢!


解决方案

 私人的IntPtr的WndProc(IntPtr的HWND,INT味精,IntPtr的wParam中,IntPtr的lParam的,裁判布尔处理)
{
VAR retVal的= IntPtr.Zero;

开关(MSG)
{
情况下UnsafeNativeConstants.WM_NCACTIVATE:
retVal的= UnsafeNativeMethods.DefWindowProc(HWND,UnsafeNativeConstants.WM_NCACTIVATE,新的IntPtr(1),新的IntPtr (-1));
AssociatedObject.UpdateTitlebar((INT)的wParam == 1真?假的);
处理= TRUE;
中断;
}

返回retVal的;
}



WndProc中我已经在附加到我的窗口中的自定义行为挂钩。它要求我的窗上的内部方法,将更新的标题栏适当的颜色。



感谢@Hans帕桑特指着我在正确的方向。


Normally when you open a Modal Dialog and try to click on it's parent window the Modal Dialog's titlebar flashes. When creating a custom, borderless, chromeless, window in WPF you lose all that functionality and must rebuild it yourself. I've looked high and low and for the life of me cannot figure out how to get my Modal window to flash. Though it still beeps...

I figure I'm going to have to watch for some event(s) in WndProc that I'll have to handle, but I can't figure out which event or how to do it. I've tried watching the window changed and window changing event as well as the WM_ACTIVATE event to no avail. I'm sure I'm just missing something simple, but I would appreciate any help on this. Thanks!

解决方案

private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
    {
        var retVal = IntPtr.Zero;

        switch (msg)
        {
            case UnsafeNativeConstants.WM_NCACTIVATE:
                retVal = UnsafeNativeMethods.DefWindowProc(hwnd, UnsafeNativeConstants.WM_NCACTIVATE, new IntPtr(1), new IntPtr(-1));
                AssociatedObject.UpdateTitlebar((int)wParam == 1 ? true : false);
                handled = true;
                break;
        }

        return retVal;
    }

The WndProc I have hooked up in a custom behavior that's attached to my window. It calls an internal method on my window that will update the color of the Titlebar appropriately.

Thanks to @Hans Passant for pointing me in the right direction.

这篇关于WPF:我如何创建一个自定义模式对话框闪光?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆