保持非活动窗口在外观上,即使激活 [英] Keep Window Inactive In Appearance Even When Activated

查看:306
本文介绍了保持非活动窗口在外观上,即使激活的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让一个窗口处于非活动状态看,即使它包含重点是什么?我有两种形式(A和B)。之后用户提供了一个互动,我转移焦点回到B.重点转移的结果(在A用户点击,然后重点转移回到B)是A型闪烁,从活动到非活动。这看起来丑陋(尤其是在Vista上,其中A暂时得到了更大的阴影)。我怎样才能让入住处于非活动状态显得很闪烁的会不会发生?

Is there a way to keep a window inactive looking, even if it contains focus? I have two forms (A and B). After the user interacts with A, I transfer focus back to B. The result of the focus transfers (the user clicking on the A, then focus being transferred back to B) is that form A blinks from active to inactive. This looks ugly (especially on Vista where A momentarily gets a bigger shadow). How can I make A stay inactive looking so this blinking will not happen?

推荐答案

最后,我找到了答案!

警告:不要滥用这个答案的方法这样做会混淆用户,将是有害于一般的计算体验。下面描述的技术可以在某些情况下是非常有用(如实施类似IntelliSense的行为),但的是明智在它的使用情况。

WARNING: DO NOT abuse this answer's technique. Doing so will confuse your users and will be harmful to the computing experience in general. The technique described below can be very useful under certain circumstances (e.g implementing IntelliSense-like behavior), but please be judicious in your usage of it.

href="http://msdn.microsoft.com/en-us/library/ms632633%28VS.85%29.aspx"> WM_NCACTIVATE 的消息被发送到一个窗口的

The WM_NCACTIVATE message is sent to a window to change the state of its non-client area (i.e. border and titlebar) to inactive or active. The wParam of the message indicates whether the state will be inactive or active. If the wParam is true (a value of 1), the window will look active. If the wParam is false (a value of 0), the window will look inactive. To force a window to stay either inactive or active, override the wParam by setting it to the corresponding value (0 or 1), and you will be all set!

private const int WM_NCACTIVATE = 0x0086;

protected override void WndProc(ref Message m)
{
    if (m.Msg == WM_NCACTIVATE)
    {
        // Use this to make it always look inactive:
        m.WParam = (IntPtr)0;

        // Alternately, use this to make it always look active:
        m.WParam = (IntPtr)1;
    }

    base.WndProc(ref m);
}

这篇关于保持非活动窗口在外观上,即使激活的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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