|
-
Feb 18th, 2000, 07:51 PM
#1
Thread Starter
Junior Member
I am having major problems with my project at the moment. I have posted before, but I need a little more help.
What I need to do is detect when Ctrl Alt and Del are being pressed (Ctrl Alt Del is disable). I need to know this so that I can show a fake End Task dialogue.
I have the following code for detecting all three keys are pressed.
Option Explicit
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private mblnAltState As Boolean
Private mblnCtrlState As Boolean
Private mblnDelState As Boolean
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
mblnAltState = (Shift And vbAltMask)
mblnCtrlState = (Shift And vbCtrlMask)
If GetAsyncKeyState(vbKeyDelete) <> 0 Then
mblnDelState = True
Else
mblnDelState = False
End If
Update
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
mblnAltState = (Shift And vbAltMask)
mblnCtrlState = (Shift And vbCtrlMask)
mblnDelState = (vbKeyDelete)
If GetAsyncKeyState(vbKeyDelete) <> 0 Then
mblnDelState = True
Else
mblnDelState = False
End If
Update
End Sub
Private Function Update()
Cls
Print "Ctrl = "; mblnCtrlState
Print "Alt = "; mblnAltState
Print "Del = "; mblnDelState
If (mblnCtrlState = True) And (mblnAltState = True) Then
If GetAsyncKeyState(vbKeyDelete) <> 0 Then
MsgBox ("All three pressed!")
End If
End If
End Function
Private Sub Form_Load()
Me.KeyPreview = True
DisableCtrlAltDelete (True)
End Sub
Public Sub DisableCtrlAltDelete(bDisabled As Boolean)
Dim x As Long
x = SystemParametersInfo(97, bDisabled, CStr(1), 0)
End Sub
Private Sub Form_Unload(Cancel As Integer)
DisableCtrlAltDelete (False)
End Sub
The problem is when i press the crtl or alt keys first, then press Delete, the delete key doesn't register! But if I press Delete first, then Ctrl and Alt, I get all htree keys registering. I am puzzled .
Can anyone help me. I was wondering about setting up a hook or something for detecting the key presses. Can anyone shed any light on this?
Thanks
David Richardson 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|