Hello everybody,
I hope somebody can help me. That's my problem: i want to capture the
mouse wheel pressure in a webbrowser component and activate the exit
function.
I've written some code below; in this code the exit procedure is
generated by the pressure of the X keyboard button and i want this
procedure to start with the pressure of the middle mouse button
(wheel).

Any help please?

public class Form1 : System.Windows.Forms.Form
    {
        private System.ComponentModel.Container components = null;
        private WebBrowser webBrowser2;
        private PictureBox pictureBox1;
        private PictureBox pictureBox2;

        private static bool RunApplication = true;

        public Form1()
        {
            InitializeComponent();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code
        private void InitializeComponent()
        {
            this.webBrowser2 = new System.Windows.Forms.WebBrowser();
            this.SuspendLayout();
            //
            // webBrowser2
            //
            this.webBrowser2.AllowWebBrowserDrop = false;
            this.webBrowser2.CausesValidation = false;
            this.webBrowser2.Location = new System.Drawing.Point(0,
0);
            this.webBrowser2.Margin = new
System.Windows.Forms.Padding(0);
            this.webBrowser2.Name = "webBrowser2";
            this.webBrowser2.ScriptErrorsSuppressed = true;
            this.webBrowser2.ScrollBarsEnabled = false;
            this.webBrowser2.Size = new System.Drawing.Size(1024,
768);
            this.webBrowser2.TabIndex = 0;
            this.webBrowser2.Url = new System.Uri("",
System.UriKind.Relative);
            this.webBrowser2.PreviewKeyDown += new
System.Windows.Forms.PreviewKeyDownEventHandler(this.webBrowser2_PreviewKeyDown);

            //
            // Form1
            //
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.AutoSize = true;
            this.ClientSize = new System.Drawing.Size(1024, 768);
            this.Controls.Add(this.webBrowser2);
            this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.None;
            this.KeyPreview = true;
            this.Name = "Form1";
            this.StartPosition =
System.Windows.Forms.FormStartPosition.Manual;
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false);

        }
        #endregion

        [STAThread]
        static void Main()
        {
            Application.Run(new Form1());
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string[] args = Environment.GetCommandLineArgs();

            if (args.GetLength(0) > 1)
            {
                webBrowser2.Navigate(args[1]);
            }
            else
                webBrowser2.Navigate("http://serghei.net/humor/swf/
3kines.swf");

            if (args.GetLength(0) > 2)
            {
                if (args[2].Equals("1"))
                    webBrowser2.ScrollBarsEnabled = true;
            }
        }

        private void webBrowser2_PreviewKeyDown(object sender,
PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode != Keys.X) return;
            RunApplication = false;
            Application.Exit();
        }
    }

Reply via email to