Пример #1
0
        public Display(Application application, WinApi.WndProc proc, DisplayStyle style)
        {
            m_application = application;
            m_instance    = WinApi.GetModuleHandle(null);

            m_windowProc = new WinApi.WndProc(proc);
            m_className  = "GRANITE_" + Guid.NewGuid().ToString("N");

            WinApi.WindowClass wc = new WinApi.WindowClass()
            {
                style           = WinApi.CS_OWNDC | WinApi.CS_VREDRAW | WinApi.CS_HREDRAW,
                windowProcedure = Marshal.GetFunctionPointerForDelegate(m_windowProc),
                instance        = m_instance,
                cursor          = WinApi.LoadCursor(IntPtr.Zero, WinApi.IDC_ARROW),
                className       = m_className
            };

            WinApi.RegisterClass(ref wc);

            uint s = WinApi.WS_POPUP;

            switch (style)
            {
            case DisplayStyle.Fixed:
                s = WinApi.WS_BORDER;
                break;

            case DisplayStyle.FixedWithTitle:
                s = WinApi.WS_CAPTION | WinApi.WS_SYSMENU;
                break;

            case DisplayStyle.Resizeable:
                s = WinApi.WS_POPUP | WinApi.WS_THICKFRAME;
                break;

            case DisplayStyle.ResizeableWithTitle:
                s |= WinApi.WS_CAPTION | WinApi.WS_SYSMENU | WinApi.WS_THICKFRAME | WinApi.WS_MINIMIZEBOX | WinApi.WS_MAXIMIZEBOX;
                break;
            }

            m_handle = WinApi.CreateWindowEx(
                0,
                m_className,
                "",
                s,
                0, 0, 800, 600,
                IntPtr.Zero, IntPtr.Zero,
                m_instance, IntPtr.Zero
                );

            m_deviceContext = WinApi.GetDC(m_handle);
        }
Пример #2
0
        public Display(Application application, WinApi.WndProc proc, DisplayStyle style)
        {
            m_application = application;
            m_instance = WinApi.GetModuleHandle(null);

            m_windowProc = new WinApi.WndProc(proc);
            m_className = "GRANITE_" + Guid.NewGuid().ToString("N");

            WinApi.WindowClass wc = new WinApi.WindowClass()
            {
                style = WinApi.CS_OWNDC | WinApi.CS_VREDRAW | WinApi.CS_HREDRAW,
                windowProcedure = Marshal.GetFunctionPointerForDelegate(m_windowProc),
                instance = m_instance,
                cursor = WinApi.LoadCursor(IntPtr.Zero, WinApi.IDC_ARROW),
                className = m_className
            };

            WinApi.RegisterClass(ref wc);

            uint s = WinApi.WS_POPUP;

            switch (style)
            {
                case DisplayStyle.Fixed:
                    s = WinApi.WS_BORDER;
                    break;
                case DisplayStyle.FixedWithTitle:
                    s = WinApi.WS_CAPTION | WinApi.WS_SYSMENU;
                    break;
                case DisplayStyle.Resizeable:
                    s = WinApi.WS_POPUP | WinApi.WS_THICKFRAME;
                    break;
                case DisplayStyle.ResizeableWithTitle:
                    s |= WinApi.WS_CAPTION | WinApi.WS_SYSMENU | WinApi.WS_THICKFRAME | WinApi.WS_MINIMIZEBOX | WinApi.WS_MAXIMIZEBOX;
                    break;
            }

            m_handle = WinApi.CreateWindowEx(
                0,
                m_className,
                "",
                s,
                0, 0, 800, 600,
                IntPtr.Zero, IntPtr.Zero,
                m_instance, IntPtr.Zero
            );

            m_deviceContext = WinApi.GetDC(m_handle);
        }
Пример #3
0
        private ushort RegisterClass(out WNDCLASSEX wndClass)
        {
            wndProc = WndProc;

            wndClass = new WNDCLASSEX
            {
                cbSize        = Marshal.SizeOf(typeof(WNDCLASSEX)),
                hInstance     = Marshal.GetHINSTANCE(this.GetType().Module),
                lpszClassName = "NCRawInputClass",
                lpfnWndProc   = Marshal.GetFunctionPointerForDelegate(wndProc)
            };

            ushort regResult = WinApi.RegisterClassEx(ref wndClass);

            Logger.WriteLine($"RegisterClass result = 0x{regResult:x}");

            return(regResult);
        }
 /// <summary>
 /// Constructs a new HookedProcInformation object
 /// </summary>
 /// <param name="ctl">The handle to the window being hooked</param>
 /// <param name="wndproc">The window procedure to replace the
 /// original one for the control</param>
 public HookedProcInformation(Control ctl, WinApi.WndProc wndproc)
 {
     control    = ctl;
     newWndProc = wndproc;
     messageMap = new Dictionary <uint, WndProcCallback>();
 }