예제 #1
0
        protected override void Dispose(bool disposing)
        {
            if (_core != null && disposing)
            {
                _core.Close();
            }

            _core = null;
            _browserWindowHandle = IntPtr.Zero;

            base.Dispose(disposing);
        }
예제 #2
0
        public CefWebBrowser(IWebWindowImplementation window, int initialWidth = 200, int initialHeight = 100)
        {
            _window = window;
            SetStyle(
                ControlStyles.ContainerControl
                | ControlStyles.ResizeRedraw
                //| ControlStyles.FixedWidth
                //| ControlStyles.FixedHeight
                | ControlStyles.StandardClick
                | ControlStyles.UserMouse
                | ControlStyles.SupportsTransparentBackColor
                | ControlStyles.StandardDoubleClick
                | ControlStyles.OptimizedDoubleBuffer
                | ControlStyles.CacheText
                | ControlStyles.EnableNotifyMessage
                | ControlStyles.DoubleBuffer
                | ControlStyles.OptimizedDoubleBuffer
                | ControlStyles.UseTextForAccessibility
                | ControlStyles.Opaque,
                false);

            SetStyle(
                ControlStyles.UserPaint
                | ControlStyles.AllPaintingInWmPaint
                | ControlStyles.Selectable,
                true);

            _initialWidth  = initialWidth;
            _initialHeight = initialHeight;

            var settings = new CefBrowserSettings();

            _core = new WebBrowser(this, settings, "about:blank");
            _core.OnProcessMessage += (a, b) =>
            {
                if (OnProcessMessage != null)
                {
                    return(OnProcessMessage(a, b));
                }
                return(false);
            };
            _core.Created += new EventHandler(BrowserCreated);
        }