|
-
Nov 22nd, 2000, 02:17 AM
#1
Thread Starter
Member
Got two questions.
One:
Whats the Disable Command for ALT+F4. I know the code for CTRL+ALT+DEL & ALT+TAB, & CTRL+ESC.
Second:
How Can I minimized & set A Program in the Start Up Tray. As Though its Still Running???
Thanks..
-
Nov 22nd, 2000, 03:05 AM
#2
Simply set the KeyPreview property of the form to True and add the following code:
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'prevent the ALT+F4 keystokes
If Shift = vbAltMask And KeyCode = vbKeyF4 Then
KeyCode = 0
End If
End Sub
Best regards
-
Nov 22nd, 2000, 03:13 AM
#3
Thread Starter
Member
Current Code for Disabling Keys
Didnt Work...
This is the Code I use for CTRL+ALT+DEL
_______________________________
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
Sub DisableCtrlAltDelete(bDisabled As Boolean)
Dim X As Long
X = SystemParametersInfo(97, bDisabled, CStr(1), 0)
End Sub
Private Sub Form_Load()
Call DisableCtrlAltDelete(True)
End Sub
_______________________________
Anything else??
Oh Yeah, Thanks Again...
-
Nov 22nd, 2000, 03:16 AM
#4
Thread Starter
Member
! ? !
???
On the Code you gave, Do I need to Declare anything??
-
Nov 22nd, 2000, 03:50 AM
#5
Q2: I assume you mean the system tray?
Code:
'Module code:
Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIM_DELETE = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const WM_LBUTTONUP = &H202
Public Const WM_RBUTTONUP = &H205
Public Const WM_MOUSEMOVE = &H200
Public Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uId As Long
uFlags As Long
ucallbackMessage As Long
hIcon As Long
szTip As String * 64
End Type
Public VBGTray As NOTIFYICONDATA
'Form Declarations:
Private Sub GoSystemTray()
VBGTray.cbSize = Len(VBGTray)
VBGTray.hwnd = Me.hwnd
VBGTray.uId = vbNull
VBGTray.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
VBGTray.ucallbackMessage = WM_MOUSEMOVE
VBGTray.hIcon = Me.Icon
'tool tip text
VBGTray.szTip = Me.Caption & vbNullChar
Call Shell_NotifyIcon(NIM_ADD, VBGTray)
App.TaskVisible = False 'remove application from taskbar
Me.Hide
End Sub
'Form Code:
Private Sub Form_MouseMove(button As Integer, Shift As Integer, X As Single, Y As Single)
Static lngMsg As Long
Static blnFlag As Boolean
Dim result As Long
lngMsg = X / Screen.TwipsPerPixelX
If blnFlag = False Then
blnFlag = True
Select Case lngMsg
'right-click
Case WM_RBUTTONUP
result = SetForegroundWindow(Me.hwnd)
PopupMenu MyPopUpMenu
Case WM_LBUTTONUP
result = SetForegroundWindow(Me.hwnd)
PopupMenu MyPopUpMenu
End Select
blnFlag = False
End If
End Sub
Private Sub Form_Resize()
If Me.WindowState = 1 Then
Call GoSystemTray
ElseIf Me.WindowState = 0 Then
VBGTray.cbSize = Len(VBGTray)
VBGTray.hwnd = Me.hwnd
VBGTray.uId = vbNull
Call Shell_NotifyIcon(NIM_DELETE, VBGTray)
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
VBGTray.cbSize = Len(VBGTray)
VBGTray.hwnd = Me.hwnd
VBGTray.uId = vbNull
Call Shell_NotifyIcon(NIM_DELETE, VBGTray)
Unload Me
Set Form1 = Nothing
End
End Sub
-
Nov 22nd, 2000, 05:00 AM
#6
Re: ! ? !
Originally posted by cfreiling
???
On the Code you gave, Do I need to Declare anything??
Nope! It doesn't use any api calls. Did you remeber to set the KeyPreview property to True?
I've tried this code on several mashines and it works.
Best regards
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
|