Git Product home page Git Product logo

deskbandtest's People

Contributors

y-theta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

deskbandtest's Issues

这个库无法兼容windows消息?

我写了这样一个类:
用它来测试windows消息。
这个类可以在CSDeskband中很好的运行,但是无法在您的DeskBandTest中运行。

using System;
using System.Windows;
using System.Windows.Interop;

namespace WMessager
{
    public class WMessage
    {
        public event EventHandler reciveWMessage;
        private int MESSAGENUMBER { get; set; }

        public IntPtr Hwnd { get; set; }
        public WMessage(object element, int message)
        {
            MESSAGENUMBER = message;
    
            if (element is Window)
            { Hwnd = new WindowInteropHelper((Window)element).EnsureHandle(); }
            else
            { Hwnd = ((HwndSource)PresentationSource.FromVisual((System.Windows.Media.Visual)element)).Handle; }

            HwndSource.FromHwnd(Hwnd)?.AddHook(HwndHandler);
        }

        private IntPtr HwndHandler(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == MESSAGENUMBER)
            {
                this.reciveWMessage?.Invoke(this, new EventArgs());
            }
            handled = false;
            return IntPtr.Zero;
        }
    }
}

这样使用这个类:

        WMessage wMessage = new WMessage(this, 26);    //  26是各种Windows消息
        wMessage.reciveWMessage += borderBrushChange;


        // WMessager 跟随系统改变颜色
        private void borderBrushChange(object sender, EventArgs e)
        {
            Label.Text = "test";
        }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.