|
-
Sep 9th, 2000, 01:29 PM
#1
Thread Starter
New Member
Hello
Is there any way to make a window not to close even when alt+f4 is pressed . my work is for a multi document interface and i need to call one window over the other . when i call the other window to input some data my intention is to make sure that the pop up window remains focussed even though users pressed Alt+F4 to bypass it .
Please help .
-
Sep 9th, 2000, 01:50 PM
#2
_______
<?>
Code:
'This gets by F4 but I don't know how to get around
'alt esc unless you disfunction alt/ctrl/del
Option Explicit
' trap keys and use your code for their events
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF4: KeyCode = vbKeyF10
End Select
End Sub
Private Sub Form_Load()
Form1.KeyPreview = True
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
-
Sep 9th, 2000, 01:57 PM
#3
Hyperactive Member
way easier ...
in the form, there is UNLOAD function, all you need to do is:
Private Sub Form_Unload(Cancel As Integer)
Cancel = 1
End Sub
but when you want to unload the form, you will have to indicate that it comes from your program something like:
dim reallyclose as boolean ' this as a public variable
private function closewindow ()
reallyclose=true
end sub
Private Sub Form_Unload(Cancel As Integer)
if reallyclose<>true then
Cancel = 1
end if
End Sub
this will let you close the form ... otherwise you can't.
In the beginning the universe was created. This has made a lot of people very angry and is generally regarded as a bad idea.
- Douglas Adams
The Hitchhiker's Guide to the Galaxy
-
Sep 9th, 2000, 06:05 PM
#4
_______
<?>
no easier and has no effect on alt/Esc either
'This gets by F4 but I don't know how to get around
'alt esc unless you disfunction alt/ctrl/del
As a matter of fact you don't even need the select
I just left it in cause it was used where I checked
a series of keys.
Code:
Option Explicit
' trap keys and use your code for their events
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
if vbKeyF4 then KeyCode = vbKeyF10
End Sub
Private Sub Form_Load()
Form1.KeyPreview = True
End Sub
'disable alt/ctrl/delete
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
[Edited by HeSaidJoe on 09-09-2000 at 07:08 PM]
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 9th, 2000, 07:44 PM
#5
Use the QueryUnload event.
Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbFormControlMenu Then
'the user is trying to close the window by
'either keying ALT+F4 or by using the "X" button
Cancel = True
End If
End Sub
Good luck!
-
Sep 9th, 2000, 07:51 PM
#6
Hyperactive Member
that's exactly what I said to begin with ! :-)
In the beginning the universe was created. This has made a lot of people very angry and is generally regarded as a bad idea.
- Douglas Adams
The Hitchhiker's Guide to the Galaxy
-
Sep 9th, 2000, 07:57 PM
#7
_______
<?>
the object is to keep the window open even if f4 and alt is pressed. My way your way does that but neither protects against alt / esp being pressed and thus by passing the vbModal window.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 9th, 2000, 08:00 PM
#8
Originally posted by asabi
that's exactly what I said to begin with ! :-)
No you didn't! You suggested using the Unload event and not the QueryUnload event.
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
|