Hiding and disabling things

striker

Useless and getting worse
Local time
Today, 21:35
Joined
Apr 4, 2002
Messages
65
I have two questions for the vb guru's out there:

1: How do I disable the close X in the access. The one in the top right of the screen.

and


2: How do i hide the access system window the one that lists all of the tables forms queries etc.


Thanks in advance

Steve
 
This will allow you to disable the 'X' to prevent the user from closing
your application...

'Copy this function into a new module...
'Courtesy of Calvin Smith
Option Compare Database
Option Explicit
Public Declare Function apiEnableMenuItem Lib "user32" Alias "EnableMenuItem" (ByVal hMenu As Long, ByVal wIDEnableMenuItem As Long, ByVal wEnable As
Long) As Long
Public Declare Function apiGetSystemMenu Lib "user32" Alias "GetSystemMenu" (ByVal hWnd As Long, ByVal flag As Long) As Long

Public Function EnableDisableControlBoxX(bEnable As Boolean, Optional ByVal lhWndTarget As Long = 0) As Long
On Error GoTo Err_EnableDisableControlBoxX

Const MF_BYCOMMAND = &H0&
Const MF_DISABLED = &H2&
Const MF_ENABLED = &H0&
Const MF_GRAYED = &H1&
Const SC_CLOSE = &HF060&

Dim lhWndMenu As Long
Dim lReturnVal As Long
Dim lAction As Long

lhWndMenu = apiGetSystemMenu(IIf(lhWndTarget = 0, Application.hWndAccessApp, lhWndTarget), False)

If lhWndMenu <> 0 Then
If bEnable Then
lAction = MF_BYCOMMAND Or MF_ENABLED
Else
lAction = MF_BYCOMMAND Or MF_DISABLED Or MF_GRAYED
End If
lReturnVal = apiEnableMenuItem(lhWndMenu, SC_CLOSE, lAction)
End If

EnableDisableControlBoxX = lReturnVal

Exit_EnableDisableControlBoxX:
Exit Function

Err_EnableDisableControlBoxX:
ErrorMsg "dProgramFunctions", "EnableDisableControlBoxX", Err.Number, Err.Description
Resume Exit_EnableDisableControlBoxX

End Function

'I test if the current user is me (the programmer). Use this in a forms OnOpen event or a transparent command button...
If CurrentUser <> "programmer" Then
EnableDisableControlBoxX (True)
Exit Sub
Else
EnableDisableControlBoxX (False) 'Disable the programs X (close) function
End If

'HTH
 

Users who are viewing this thread

Back
Top Bottom