干脆锁住屏幕算了。'用到的API Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long 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 SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As LongDim nPreviousState As Long '保存系统环境状态'给屏幕加锁的函数 Public Sub LockScreen(ByVal szMsg As String) Me.Move 0, 0, Screen.Width, Screen.Height SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 1 Or 2 BitBlt Me.hDC, 0, 0, Screen.Width, Screen.Height, GetDC(0), 0, 0, vbSrcCopy Me.ForeColor = vbYellow Print szMsg Me.ForeColor = vbBlue Print szMsg Me.ForeColor = vbRed Print szMsg Me.Show SystemParametersInfo 97, True, nPreviousState, 0 End Sub'给屏幕解锁的函数 Public Sub UnlockScreen() SystemParametersInfo 97, False, nPreviousState, 0 Me.Hide End Sub'这个函数仅在调试程序时使用 Private Sub Command1_Click() UnlockScreen End Sub
霸屏加屏蔽系统热键 Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As LongSub DisableCtrlAltDelete(bDisabled As Boolean) Dim x As Long x = SystemParametersInfo(97, bDisabled, CStr(1), 0) End SubPrivate Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Call DisableCtrlAltDelete(False) Unload Me
End Sub Private Sub Form_Load() Call DisableCtrlAltDelete(True) Dim i i = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3) End Sub
太复杂了,有没有更简单一点的,比如在 Form_KeyDown、下面加上一个不响应的参数?
设置Form的KeyPreview=True Private Sub Form_KeyPress(KeyAscii As Integer) KeyAscii = 0 End Sub
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
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 SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As LongDim nPreviousState As Long '保存系统环境状态'给屏幕加锁的函数
Public Sub LockScreen(ByVal szMsg As String)
Me.Move 0, 0, Screen.Width, Screen.Height
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 1 Or 2
BitBlt Me.hDC, 0, 0, Screen.Width, Screen.Height, GetDC(0), 0, 0, vbSrcCopy
Me.ForeColor = vbYellow
Print szMsg
Me.ForeColor = vbBlue
Print szMsg
Me.ForeColor = vbRed
Print szMsg
Me.Show
SystemParametersInfo 97, True, nPreviousState, 0
End Sub'给屏幕解锁的函数
Public Sub UnlockScreen()
SystemParametersInfo 97, False, nPreviousState, 0
Me.Hide
End Sub'这个函数仅在调试程序时使用
Private Sub Command1_Click()
UnlockScreen
End Sub
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As LongSub DisableCtrlAltDelete(bDisabled As Boolean)
Dim x As Long
x = SystemParametersInfo(97, bDisabled, CStr(1), 0)
End SubPrivate Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Call DisableCtrlAltDelete(False)
Unload Me
End Sub
Private Sub Form_Load()
Call DisableCtrlAltDelete(True)
Dim i
i = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub
OK,确实如此而已!