• 0

[WPF] PictureBox MouseWheel event not working


Question

I have a Windows.Forms.PictureBox inside a WindowsFormHost in my WPF app. I need that to get a handle to give to my 3D engine and have it display something in there (and no I'm not responsible for that stupid architecture, academic requirements *sigh*).

So, I need to get all the mouse and keyboard events on that picturebox, which works fine except, for some weird reason, for the mouse wheel.

        <WindowsFormsHost Grid.Row="0e="m_windowFormsHost">   
            <wf:PictureBox x:Name="m_pictureBox" BackColor="AliceBlue" KeyDown="Window_KeyDown" KeyUp="Window_KeyUp"
               MouseDown="Window_MouseDown" MouseUp="Window_MouseUp" MouseWheel="Window_MouseWheel" MouseMove="Window_MouseMove" />
        </WindowsFormsHost>

All the events listed here are called fine, except for Window_MouseWheel. And I've tried putting the event handler higher up in the hierarchy, on the WindowsFormsHost, then on the Grid container that holds it, then on the view itself.... nothing works. Any idea what's going on?

2 answers to this question

Recommended Posts

  • 0

Well, it seems like a conflict with another control in the view, which is a scrollable textbox. So I made a few assumptions in my OP which didn't turn out to be true. The only events to be captured by the picturebox are the clicks directly in it. Keyboard presses are not, and when I press UpArrow or DownArrow it selects the textbox automatically.

So now my question becomes: is there a way I can tell which control should capture specific events? Sometimes I will want the textbox to capture keyboard inputs, sometimes I will the picturebox to do it.

  • 0

Hum so let me rephrase that.

In my WPF window I have two controls, one that displays the game and the other that acts as a chat window (textbox).

The user should be able to use the keyboard to control the game AND to send messages on the chat.

Therefore I need a way to handle keyboard events so that depending on some state variable, they are handled by the game or by the textbox. I need the same thing for the mousewheel basically.

Thanks!

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.