I am writing an application in VisualStudio Express 2010 (C #). There is a Panel in which the PictureBox is located. The MouseWheel event is hung on the panel, when triggered, the PictureBox image is scaled. Looks like that:

//Объявление события this.Panel.MouseWheel += new MouseEventHandler(this.Panel_MouseWheel); //Обработчик private void Panel_MouseWheel(object sender, MouseEventArgs e) { //масштабирование } 

So, everything works fine on my laptop. I tried on a friend's laptop - the mouse does not intercept the scroll, the scroll with the dotpad intercepts. Scroll on the mouse from a friend's worker. Tell me what could be the problem.

  • five
    Run Spy ++ and see what messages come in the window when the wheel moves. - Athari

1 answer 1

PictureBox may not receive WM_MOUSEWHEEL.

You can check this:

 var f = new Form() { Height = 500, Width = 800 }; var p = new PictureBox() { Parent = f, Dock = DockStyle.Top, Height = 100 }; var v = new MessageView(p) { Dock = DockStyle.Fill, Parent = f }; Application.AddMessageFilter(v); f.ShowDialog(); // ... class MessageView : RichTextBox, IMessageFilter { private Control c; public MessageView(Control c) { this.c = c; } public bool PreFilterMessage(ref Message m) { if(m.HWnd == c.Handle) this.AppendText(m + "\n"); // m.Msg = 0x20a (WM_MOUSEWHEEL) return false; } }