# Re: 请问一下,如何锁住桌面????

Posted by 战豪 on July 09, 1999 at 01:10:48:

In Reply to: Re: 请问一下,如何锁住桌面???? posted by South Wind on July 08, 1999 at 12:54:26:

噢!看来你还需要收起TaskBar来禁止User切换程式呢!试试下面的Coding:

'公用模组宣告
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
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Const SWP_HIDEWINDOW = &H80
Const SWP_SHOWWINDOW = &H40
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2

'公用模组函数
'Code to Hanle Windows Taskbar
Function ShowTaskBar(sBal As Boolean)
Dim Thwnd As Long, Tstr As Long
If sBal Then
Tstr = SWP_SHOWWINDOW
Else
Tstr = SWP_HIDEWINDOW
End If
Thwnd = FindWindow("Shell_traywnd", "")
Call SetWindowPos(Thwnd, 0, 0, 0, 0, 0, Tstr)
End Function

'于程序中呼叫,如Form_Load或Sub Main事件
'Hide TaskBar & Enable TopMost
Call ShowTaskBar(False)
Call SetWindowPos(Me.hwnd, HWND_TOPMOST, 0&, 0&, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)

'于程序中呼叫,如Form_Unload事件
'Show TaskBar & Disable TopMost
Call ShowTaskBar(True)
Call SetWindowPos(Me.hwnd, HWND_NOTOPMOST, 0&, 0&, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)

如此,配合全营幕(表单)显示及TopMost,和取消Ctrl+Alt+Del & Alt+Tab等功能,便可满足你的要求啰!

Follow Ups: