In the application I'm working on I use F1 and also a right mouse click to close the application since the graphics display full screen and there's no control in the upper right corner to close with. I use a good number of different keypresses to control things and everything works fine. When I switch away from the form that the applications starts in to a different form I'm not getting any response from either a KeyDown or a KeyPress event. Maybe someone knows what's going on. The ButtonClick and MouseDown events are responding just fine but for some reason the KeyDown and KeyPress events aren't. Below is code for one of the Forms that is unresponsive in this way. I put Close() outside the If Thens below so that any
KeyPress or KeyDown would close but nothing happens.
Code:Option Strict On Public Class InstructionsForRayRover Inherits System.Windows.Forms.Form Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TellAboutwOn = 0 StartForm1 = 1 mainForm = New DisplayGraphics Me.Close() End Sub Private Sub InstructionsForRayRover_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing If mainForm Is Me Then mainForm = Nothing End If End Sub Private Sub InstructionsForRayRover_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown Close() If e.KeyCode = Keys.F1 Then End If End Sub Private Sub InstructionsForRayRover_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress Close() If e.KeyChar = "a"c Then End If End Sub Private Sub InstructionsForRayRover_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load ' This is just to center the text at the top of the form. There might be a more efficient way to to this st2 = My.Computer.Info.OSFullName b = st2.IndexOf("XP") ' b will = -1 if any version of Windows XP isn't being used If b >= 0 Then a = CInt((Hxlimit - 96) / 4.07) Else a = CInt((Hxlimit - 96) / 3) End If st1 = "" For i = 0 To a st1 = st1 & " " Next Me.Text = st1 & "Instructions On Using Ray Rover" Label1.Left = HxlimitI - 364 Label3.Left = HxlimitI - 364 Button1.Left = HxlimitI - 60 ButtonUpdate.Left = HxlimitI - 106 Label2.Width = XlimitI - 25 End Sub Private Sub InstructionsForRayRover_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown If MouseButtons = MouseButtons.Right Then Close() End If End Sub End Class




Make as many mistakes as you can as quickly as you can. We want to make sure that we make a great enough number of mistakes in a given amount of time so that we can be successful.
Reply With Quote