0

I am making a simple game that the user selects two weapons (primary and secondary). In the game window the weapon is displayed in a picturebox (picWeapon) in the corner of the screen. I want the user to be able to scroll up (or down since there's only one other weapon) to select the secondary weapon. What code to I place to cycle through images using the mouse wheel?

1 Answers1

0
Private isPrimary As Boolean = True 'assumes the Primary image is already loaded
Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
    If e.Delta > 0 And isPrimary = False Then
        Debug.WriteLine("Scrolled up!")
        PicWeapon.Load(filepathOfPrimary)
        isPrimary = True
    ElseIF isPrimary = True Then
        Debug.WriteLine("Scrolled down!")
        PicWeapon.Load(filepathOfSecondary)
        isPrimary = False
    End If
End Sub
Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
  • 1
    It can't be the PicWeapon's event. The MouseWheel event is sent to the window with the focus, not the one that's hovered, a PictureBox can't receive the focus. More code is needed to find out where the cursor is located. – Hans Passant Jun 30 '12 at 09:55
  • and suppose they selected one weapon from a drop down of 3 on the previous page? How would I load the primary image and assign it as that type of weapon? What I had in mind was (in the select case of the drop down) to put: Dim selectedWeapon as image. then just insert "selectedWeapon" into the picweapon.load(selectedweapon) right? – SecurityForces Jul 01 '12 at 15:48