Win32 API functions.
See the MSDN Windows SDK documentation for more information about these functions.
Exemple #1
0
 protected virtual void Dispose(bool disposing)
 {
     if (!disposed)
     {
         W32API.ReleaseActCtx(contextHandle);
         disposed = true;
     }
 }
        /// <summary>
        /// Processes a command key.  Overridden in WebKitBrowser to forward key events to the WebKit window.
        /// </summary>
        /// <param name="msg">The window message to process.</param>
        /// <param name="keyData">The key to process.</param>
        /// <returns>Success value.</returns>
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            Keys key = (Keys)msg.WParam.ToInt32();

            if (key == Keys.Left || key == Keys.Right || key == Keys.Up ||
                key == Keys.Down || key == Keys.Tab)
            {
                W32API.SendMessage(webViewHWND, msg.Msg, msg.WParam, msg.LParam);
                return(true);
            }

            return(base.ProcessCmdKey(ref msg, keyData));
        }
Exemple #3
0
 /// <summary>
 /// Deactivates the activation context, activating the next one down
 /// on the 'stack'.
 /// </summary>
 public void Deactivate()
 {
     if (disposed)
     {
         throw new ObjectDisposedException(this.ToString());
     }
     if (!Initialized)
     {
         throw new InvalidOperationException("ActivationContext has not been initialized");
     }
     if (Activated)
     {
         if (!W32API.DeactivateActCtx(0, lastCookie))
         {
             throw new Win32Exception(Marshal.GetLastWin32Error(), "Failed to deactivate activation context");
         }
         Activated = false;
     }
 }
Exemple #4
0
        /// <summary>
        /// Activates the activation context.
        /// </summary>
        public void Activate()
        {
            if (disposed)
            {
                throw new ObjectDisposedException(this.ToString());
            }
            if (!Initialized)
            {
                throw new InvalidOperationException("ActivationContext has not been initialized");
            }
            if (!Activated)
            {
                lastCookie = 0;
                Activated  = W32API.ActivateActCtx(contextHandle, out lastCookie);

                if (!Activated)
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error(), "Failed to activate activation context");
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Initializes the activation context.
        /// </summary>
        public void Initialize()
        {
            if (disposed)
            {
                throw new ObjectDisposedException(this.ToString());
            }
            if (!Initialized)
            {
                activationContext          = new W32API.ACTCTX();
                activationContext.cbSize   = Marshal.SizeOf(typeof(W32API.ACTCTX));
                activationContext.lpSource = this.ManifestFileName;

                contextHandle = W32API.CreateActCtx(ref activationContext);

                Initialized = (contextHandle != (IntPtr)W32API.INVALID_HANDLE_VALUE);

                if (!Initialized)
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error(), "Failed to initialize activation context");
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the WebKitBrowser control.
        /// </summary>
        public WebKitBrowser()
        {
            InitializeComponent();

            if (LicenseManager.UsageMode != LicenseUsageMode.Designtime)
            {
                // Control Events
                this.Load   += new EventHandler(WebKitBrowser_Load);
                this.Resize += new EventHandler(WebKitBrowser_Resize);

                // If this is the first time the library has been loaded,
                // initialize the activation context required to load the
                // WebKit COM component registration free
                if ((actCtxRefCount++) == 0)
                {
                    activationContext = new ActivationContext("WebKitBrowser.dll.manifest");
                    activationContext.Initialize();

                    // TODO: more error handling here

                    // Enable OLE for drag and drop functionality - WebKit
                    // will throw an OutOfMemory exception if we don't...
                    Application.OleRequired();
                }

                // If this control is brought to focus, focus our webkit child window
                this.GotFocus += (s, e) =>
                {
                    W32API.SetFocus(webViewHWND);
                };

                activationContext.Activate();
                webView = new WebViewClass();
                activationContext.Deactivate();
            }
        }
 private void WebKitBrowser_Resize(object sender, EventArgs e)
 {
     // Resize the WebKit control
     W32API.MoveWindow(webViewHWND, 0, 0, this.Width - 1, this.Height - 1, true);
 }