开发者

Filtering messages in WPF application

Windows Fo开发者_Python百科rms have the IMessageFilter interface to capture messages. How is this done in WPF? Specifically, I want to create a clipboard format listener.


In your Window derived class:

    protected override void OnSourceInitialized(EventArgs e)
    {
        base.OnSourceInitialized(e);
        ((HwndSource)PresentationSource.FromVisual(this)).AddHook(myHook)
    }

    private IntPtr myHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
    {
        switch (msg)
        {
            // process messages here
            default:
                return IntPtr.Zero;
        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜