Ejemplo n.º 1
0
        public RubberduckHooks(VBE vbe, IGeneralConfigService config)
        {
            _vbe = vbe;
            _mainWindowHandle = (IntPtr)vbe.MainWindow.HWnd;
            _oldWndProc       = WindowProc;
            _newWndProc       = WindowProc;
            _oldWndPointer    = User32.SetWindowLong(_mainWindowHandle, (int)WindowLongFlags.GWL_WNDPROC, _newWndProc);
            _oldWndProc       = (User32.WndProc)Marshal.GetDelegateForFunctionPointer(_oldWndPointer, typeof(User32.WndProc));

            _config = config;
        }
Ejemplo n.º 2
0
        public RubberduckHooks(VBE vbe, IGeneralConfigService config)
        {
            _vbe = vbe;
            _mainWindowHandle = (IntPtr)vbe.MainWindow.HWnd;
            _oldWndProc = WindowProc;
            _newWndProc = WindowProc;
            _oldWndPointer = User32.SetWindowLong(_mainWindowHandle, (int)WindowLongFlags.GWL_WNDPROC, _newWndProc);
            _oldWndProc = (User32.WndProc)Marshal.GetDelegateForFunctionPointer(_oldWndPointer, typeof(User32.WndProc));

            _config = config;

        }
Ejemplo n.º 3
0
        public MessageWindow(string name, WndProcNullableRet wndProc)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new Exception("class_name is empty or null");
            }
            if (wndProc == null)
            {
                throw new ArgumentNullException("wndProc");
            }
            _name    = name;
            _wndProc = wndProc;

            //Log.General.Debug("MessageWindow() name: " + name);

            _hInstance = Marshal.GetHINSTANCE(GetType()
                                              .Module);
            if (_hInstance == new IntPtr(-1))
            {
                throw new Win32Exception("Couldn't get modules instance");
            }

            int UniqueID = 1;

            _className = _name + " class " + UniqueID;
            if (_className.Length > 255)
            {
                throw new ArgumentException("class name too long");
            }

            //Log.General.Debug("MessageWindow.Create classname: " + _className);

            _internalWndProc = WndProc;

            _wndClassEx = new User32.WNDCLASSEX
            {
                cbSize = (uint)Marshal.SizeOf(typeof(User32.WNDCLASSEX)),
                style  =
                    User32.CS.OWNDC | User32.CS.HREDRAW |
                    User32.CS.VREDRAW,
                lpfnWndProc   = _internalWndProc,
                cbClsExtra    = 0,
                cbWndExtra    = 0,
                hInstance     = _hInstance,
                hIcon         = IntPtr.Zero,
                hCursor       = IntPtr.Zero,
                hbrBackground = IntPtr.Zero,
                lpszMenuName  = null,
                lpszClassName = _className,
                hIconSm       = IntPtr.Zero
            };

            _classAtom = User32.RegisterClassEx(ref _wndClassEx);
            if (_classAtom.IsInvalid)
            {
                throw new Win32Exception("Could not register window class");
            }

            _windowName = _name + " wnd " + UniqueID;

            //Log.General.Debug("MessageWindow.Create windowname: " + _windowName);

            // Create window
            _handle =
                User32.StrongHWND.CreateWindowEx(
                    User32.WindowStylesEx.WS_EX_CLIENTEDGE | User32.WindowStylesEx.WS_EX_APPWINDOW,
                    _className,
                    _windowName,
                    User32.WindowStyles.WS_OVERLAPPEDWINDOW,
                    // position
                    0,
                    0,
                    // size
                    0,
                    0,
                    // no parent
                    User32.HWND.NULL,
                    // no menu
                    IntPtr.Zero,
                    _hInstance,
                    IntPtr.Zero);

            if (Handle.IsInvalid)
            {
                throw new Win32Exception("Could not create window");
            }
        }
Ejemplo n.º 4
0
 public CanvasWindow()
 {
     _bounds = new Rectangle(0, 0, 400, 300);
     _wndProc = wndProc;
     CreateWindow();
     //NoActivate = true;
     //IgnoreInput = true;
     
 }