tfurnivall
Registered User.
- Local time
- Today, 04:54
- Joined
- Apr 19, 2012
- Messages
- 81
Hi!
I have a tab control on a form, and I want to use "Hotkeys' to get from one page to another (or more specifically, to toggle the visibility of the pages).
So, I set up the tab control with the pages I want hidden set with visible=No. Then I enable the Form.KeyPreview, so that the form will get a chance to look at all the key presses.
Lastly I have a Form.KeyDown handler, that looks like this:
This is early on in the design iteration - more will happen with the pages, but this is an easy way of reviewing various aspects of a project.
So what happens?
I put a breakpoint at the first If statement, and sure enough, it picks up the Ctrl key or the Alt key, whenever they are pressed. (I need to use the mouse to clear the msgbox, naturally!) When I press both of them (Ctrl/Alt) I get the required value of 6, but I never seem to get to the second msgbox. In addition, if I comment out the first message box, I also never seem to get to the second msgbox (ie the point where the combination has been detected.
KeyDown obviously has to fire for each component of a HotKey combination, and the Shift parameter has been shown to be cumulative. The only thing I can think of is that somehow I need to turn off keypress processing somewhere else (Used to be possible to use Cancel to do this, I seem to recall).
Any ideas on how I can implement these Hotkey like functions? I think my approach is sound - but I'm more than willing to learn why if it is not!
Thanks,
Tony
I have a tab control on a form, and I want to use "Hotkeys' to get from one page to another (or more specifically, to toggle the visibility of the pages).
So, I set up the tab control with the pages I want hidden set with visible=No. Then I enable the Form.KeyPreview, so that the form will get a chance to look at all the key presses.
Lastly I have a Form.KeyDown handler, that looks like this:
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
MsgBox "Key pressed (1): Shift value is " & Format(Shift)
' Detect Hot-keys for the pages in the MultiPage wizard, and make them Visible or not visible
' P/D/X/S/R/H/C
If Shift = acAltMask + acShiftMask Then
msgbox "Key pressed (2): Shift value is " & format(shift)
If KeyCode = vbkeyP Then ' Project Definition
' Can't be hidden!
ElseIf KeyCode = vbkeyD Then ' Source Definition
Me.pgSourceDefinition.Visible = Not Me.pgSourceDefinition.Visible
ElseIf KeyCode = vbkeyX Then ' Extract Phase
Me.pgExtract.Visible = Not Me.pgExtract.Visible
ElseIf KeyCode = vbkeyS Then ' Scoring Phase
Me.pgScoring.Visible = Not Me.pgScoring.Visible
ElseIf KeyCode = vbkeyR Then ' Review Phase
Me.pgReview.Visible = Not Me.pgReview.Visible
ElseIf KeyCode = vbkeyH Then ' Project History
Me.pgHistory.Visible = Not Me.pgHistory.Visible
ElseIf KeyCode = vbkeyC Then ' Project Configuration
Me.pgConfigure.Visible = Not Me.pgConfigure.Visible
Else
End If
Else
End If
End Sub
So what happens?
I put a breakpoint at the first If statement, and sure enough, it picks up the Ctrl key or the Alt key, whenever they are pressed. (I need to use the mouse to clear the msgbox, naturally!) When I press both of them (Ctrl/Alt) I get the required value of 6, but I never seem to get to the second msgbox. In addition, if I comment out the first message box, I also never seem to get to the second msgbox (ie the point where the combination has been detected.
KeyDown obviously has to fire for each component of a HotKey combination, and the Shift parameter has been shown to be cumulative. The only thing I can think of is that somehow I need to turn off keypress processing somewhere else (Used to be possible to use Cancel to do this, I seem to recall).
Any ideas on how I can implement these Hotkey like functions? I think my approach is sound - but I'm more than willing to learn why if it is not!
Thanks,
Tony