|
-
Aug 16th, 2000, 08:45 AM
#1
Thread Starter
New Member
Hi,
Fairly new to VB...
I have a single form application that is executed via an NT login script when a user logs in. The form (always on top) shows our rules and regulations for our systems and asks the user to accept or decline them (similar to a software license agreement). If they decline they are logged out - if they accept it is recorded and they can continue.
However, they can bypass in various ways such as clicking the login script cmd window behind the form and manually stopping the login script, or killing the VB app from task manager.
Is there a way to suspend the rest of the system while this form is displayed until a user has pressed 'Accept' or 'Decline'? i.e. the user can do nothing (maybe not even task manager???) until they have hit one of the two buttons.
Many thanks,
PhilVee
-
Aug 16th, 2000, 09:04 AM
#2
_______
<?>
This might work.
display your form as vbModal/Topmost/ and disable
the alt/tab/delete
don't forget to re-enable it after admission
Code:
'this code will disable [Alt-Tab ] or [ Ctrl-Alt-Del ]
'
'build a bas module and put this in it.
'
Private Declare Function EnableWindow Lib "user32" (ByVal hWnd As Integer, ByVal aBOOL As Integer) As Integer
Private Declare Function IsWindowEnabled Lib "user32" (ByVal hWnd As Integer) As Integer
Private Declare Function GetMenu Lib "user32" (ByVal hWnd As Integer) As Integer
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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 TaskBarhWnd As Long
Private IsTaskBarEnabled As Integer
Private TaskBarMenuHwnd As Integer
Sub FastTaskSwitching(bEnabled As Boolean)
Dim X As Long, bDisabled As Long
bDisabled = Not bEnabled
X = SystemParametersInfo(97, bDisabled, CStr(1), 0)
End Sub
Public Sub DisableTaskBar()
Dim EWindow As Integer
TaskBarhWnd = FindWindow("Shell_traywnd", "")
If TaskBarhWnd <> 0 Then
'check to see if window is enabled
EWindow = IsWindowEnabled(TaskBarhWnd)
If EWindow = 1 Then 'need to disable it
IsTaskBarEnabled = EnableWindow(TaskBarhWnd, 0)
End If
End If
End Sub
Public Sub EnableTaskBar()
If IsTaskBarEnabled = 0 Then
IsTaskBarEnabled = EnableWindow(TaskBarhWnd, 1)
End If
End Sub
'
'
' put 2 option buttons on your form
' option 1 = enable ....option 2 = disable
' code for click event of option buttons
Private Sub Option1_Click()
EnableTaskBar
FastTaskSwitching True
End Sub
Private Sub Option2_Click()
DisableTaskBar
FastTaskSwitching False
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 16th, 2000, 09:13 AM
#3
_______
<?>
Just in case you are in doubt as to
showing your form as vbModal
set your project properties to start
up Sub Main and not your form.
[code]
'create a bas module and put this in it
'use your form name in place of Form1
Sub Main()
Form1.Show (vbModal)
End Sub
[code}
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 16th, 2000, 09:33 AM
#4
Thread Starter
New Member
Many thanks for that - I'll give it a go...
-
Aug 16th, 2000, 10:23 AM
#5
Thread Starter
New Member
Getting an overflow error on the line:
EWindow = IsWindowEnabled(TaskBarhWnd)
Any thoughts, or could I be doing this wrong. Put the code in a bas module - then to try put 2 buttons on the form with the given click code.
-
Aug 16th, 2000, 11:00 AM
#6
you could use a SystemModal Message box with a yes and a no button...
Code:
Private Sub Command1_Click()
MsgBox "do you accept?", vbYesNo + vbCritical + vbSystemModal
End Sub
-
Aug 16th, 2000, 11:12 AM
#7
_______
<?>
I don't know why...did you copy and paste the code
or type it in...
I copied and pasted the code and it works fine on my system
Changed the form name, etc without problems.
the code for the option buttons or command buttons
goes in your form not the module.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 17th, 2000, 07:27 AM
#8
Thread Starter
New Member
Copy and pasted, and then put the button code in the form. Can't quite work it out. Using VB5 - could that be a problem?
-
Aug 17th, 2000, 07:50 AM
#9
_______
<?>
I guess it could be possible but I can't test the theory as all I have is VB6.
Is it still the same error. and can you cut and paste your module code and your form code so I can run it?
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 17th, 2000, 08:26 AM
#10
Thread Starter
New Member
Yep, same error.
I've created a very basic app to try this out, i.e. a form and two buttons. Below is the code i have put into the form:
Code:
Private Sub Command1_Click()
MsgBox "do you accept?", vbYesNo + vbCritical + vbSystemModal
End Sub
Private Sub Command2_Click()
DisableTaskBar
FastTaskSwitching False
End Sub
The following is in another module to start the form in modal:
Code:
Sub Main()
Form1.Show (vbModal)
End Sub
The following code is in another module, and is simple copied and pasted from your code:
Code:
'this code will disable [Alt-Tab ] or [ Ctrl-Alt-Del ]
'
'build a bas module and put this in it.
'
Private Declare Function EnableWindow Lib "user32" (ByVal hWnd As Integer, ByVal aBOOL As Integer) As Integer
Private Declare Function IsWindowEnabled Lib "user32" (ByVal hWnd As Integer) As Integer
Private Declare Function GetMenu Lib "user32" (ByVal hWnd As Integer) As Integer
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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 TaskBarhWnd As Long
Private IsTaskBarEnabled As Integer
Private TaskBarMenuHwnd As Integer
Sub FastTaskSwitching(bEnabled As Boolean)
Dim X As Long, bDisabled As Long
bDisabled = Not bEnabled
X = SystemParametersInfo(97, bDisabled, CStr(1), 0)
End Sub
Public Sub DisableTaskBar()
Dim EWindow As Integer
TaskBarhWnd = FindWindow("Shell_traywnd", "")
If TaskBarhWnd <> 0 Then
'check to see if window is enabled
EWindow = IsWindowEnabled(TaskBarhWnd)
If EWindow = 1 Then 'need to disable it
IsTaskBarEnabled = EnableWindow(TaskBarhWnd, 0)
End If
End If
End Sub
Public Sub EnableTaskBar()
If IsTaskBarEnabled = 0 Then
IsTaskBarEnabled = EnableWindow(TaskBarhWnd, 1)
End If
End Sub
Once again many thanks for this - please bear with me as I'm only a beginner!
-
Aug 17th, 2000, 08:37 AM
#11
Thread Starter
New Member
Code for form was wrong - that was when I was trying out the system modal message box. Below is the form code:
Code:
Private Sub Option1_Click()
EnableTaskBar
FastTaskSwitching True
End Sub
Private Sub Option2_Click()
DisableTaskBar
FastTaskSwitching False
End Sub
Cheers,
-
Aug 17th, 2000, 09:57 AM
#12
_______
<?>
Sorry it took a little, I'm at work.
Ok..I have removed subMain so now all you need do to
test this out is start a new app.(standard)
Add a module and paste the module code into it.
Call your form frmMain and then paste the code for
frmMain into it
Add a form and call it frmInside and post the code
for it inside it.
This does exactly as you want and works..tested!
If it gives you problems then it must be because
you can't use the alt/ctrl/delete functions in vb5
That might be your new question...how to kill alt/ctrl delete in vb5
Code:
'<<<<<<<<<<<this is the bas module code>>>>>>>>>>>>>
Option Explicit
'disable the alt tab delete functions..no way to get to task list
Public Declare Function EnableWindow Lib _
"user32" (ByVal hWnd As Integer, ByVal aBOOL As Integer) _
As Integer
Public Declare Function IsWindowEnabled Lib _
"user32" (ByVal hWnd As Integer) As Integer
Public Declare Function GetMenu Lib "user32" _
(ByVal hWnd As Integer) As Integer
Public Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Public 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
Public TaskBarhWnd As Long
Public IsTaskBarEnabled As Integer
Public TaskBarMenuHwnd As Integer
Sub FastTaskSwitching(bEnabled As Boolean)
Dim X As Long, bDisabled As Long
bDisabled = Not bEnabled
X = SystemParametersInfo(97, bDisabled, CStr(1), 0)
End Sub
Public Sub DisableTaskBar()
Dim EWindow As Integer
TaskBarhWnd = FindWindow("Shell_traywnd", "")
If TaskBarhWnd <> 0 Then
'check to see if window is enabled
EWindow = IsWindowEnabled(TaskBarhWnd)
If EWindow = 1 Then 'need to disable it
IsTaskBarEnabled = EnableWindow(TaskBarhWnd, 0)
End If
End If
End Sub
Public Sub EnableTaskBar()
If IsTaskBarEnabled = 0 Then
IsTaskBarEnabled = EnableWindow(TaskBarhWnd, 1)
End If
End Sub
Public Sub UnloadForms()
'enable the alt/ctrl/del functions
EnableTaskBar
FastTaskSwitching True
Dim Form As Form
For Each Form In Forms
Unload Form
Set Form = Nothing
Next Form
End Sub
'<<<<<<<<< this is frmMain code >>>>>>>>>>>>
'this form controls the alt/ctrl/delete and exit routines
'This code goes in frmMain
'frmMain is set to invisible in form active and is
'never shown
Option Explicit
Private Sub Form_Activate()
frmmain.Visible = False
Dim sResult As Single
'kill alt/ctrl/delete functions
DisableTaskBar
FastTaskSwitching False
sResult = MsgBox("Do you accept?", vbYesNo, "Entrance Exam")
'if accepted then enable and go onward
If sResult = 6 Then
EnableTaskBar
FastTaskSwitching True
frmInside.Show
Else
'else quit
Call UnloadForms
End If
End Sub
'<<<<<<<<<<<<<<< this is frmInside code >>>>>>>>>>>>>>>>
'this is your form once you get past the yes/no
Option Explicit
Private Sub Command1_Click()
Call UnloadForms
End Sub
Private Sub Form_Activate()
End Sub
[Edited by HeSaidJoe on 08-17-2000 at 11:00 AM]
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 17th, 2000, 10:04 AM
#13
Thread Starter
New Member
Many thanks for all your time on this - I'll be trying it out tomorrow (finish work soon). If indeed it does not work then we know it's a VB5 issue, and I'll look to upgrade to VB6.
Thanks again - I will post just to let you know the result
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
|