鄙人想做个VB锁定计算机的程序

来源:百度知道 编辑:UC知道 时间:2024/07/04 17:43:56
然后需要输入密码到text1然后做到解除的作用,否则不能解除

你在窗体的LOSTFOCUS事件中编写
if text1<>"密码" then
me.show
end if
这样只要失去焦点又会回到这个窗体作为系统焦点

不用什么锁键盘、锁鼠标的一堆麻烦的代码,我这个完全能满足你的要求。。非常简单。。 你照抄就可以了。。

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 Long
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const HWND_TOPMOST = -1
'将窗口的BorderStyle设置为1 或者 0(使最大化最小化失效)
'同时将Moveable设置为False(窗口不可移动)
Private Sub Form_Load()
Me.Left = 0: Me.Top = 0
Me.Width = Screen.Width: Me.Height = Screen.Height
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, &H2 Or &H1
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Do: DoEvents
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, &H2 Or &H1
If Text1.Text <> "正确的密码" Then
Cancel = True: T