Ocultar el Boton Cerrar y Desactivar el Boton Minimizar en Access 2007
Este Modulo tambien funciona con Access 2000 en Adelante
Option Compare Database
Option Explicit
'***************************************************************
'& &*
'& &*
'& &*
'& &*
'& Jefferson Jimenez (JJJT) &*
'& Cabimas - Venezuela &*
'& Octubre - 2009 &*
'& &*
'& &*
'& &*
'& &*
'& &*
'***************************************************************
'Declaraciones al API de Windows
Declare Function GetSystemMenu Lib "user32" _
(ByVal hwnd As Long, ByVal bRevert As Long) As Long
Declare Function GetMenuItemCount Lib "user32" _
(ByVal hMenu As Long) As Long
Declare Function DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long
Declare Function RemoveMenu Lib "user32" _
(ByVal hMenu As Long, ByVal nPosition 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
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
'Establezco las Constantes
Const WS_MINIMIZEBOX = &H20000
Const GWL_STYLE = (-16)
Const MF_BYPOSITION = &H400&
Const MF_REMOVE = &H1000&
'Creo la Funcion de los Botones y Elimino el Boton Minimizar
Function CargaFuncionBtn_JJJT(frm As Form)
Dim lngVentana As Long, _
lngManejador As Long, _
lngCuenta As Long, _
strTitulo As String, _
CurStyle As Long, _
hwnd As Long
'Si es Access 2007 y quieres ocultar la cinta de opcione tambien
' If SysCmd(acSysCmdAccessVer) = "12.0" Then
' Me.Properties.Item("RibbonName") = "rbbInicio"
' DoCmd.ShowToolbar "Ribbon", acToolbarNo
' End If
lngVentana = FindWindow(vbNullString, strTitulo)
hwnd = Access.hWndAccessApp
CurStyle = GetWindowLong(hwnd, GWL_STYLE)
lngManejador = GetSystemMenu(lngVentana, False)
If (CurStyle And WS_MINIMIZEBOX) = WS_MINIMIZEBOX Then
CurStyle = CurStyle - WS_MINIMIZEBOX
End If
If lngManejador Then
lngCuenta = GetMenuItemCount(lngManejador)
If lngCuenta Then
RemoveMenu lngManejador, lngCuenta - 1, MF_BYPOSITION Or MF_REMOVE
RemoveMenu lngManejador, lngCuenta - 2, MF_BYPOSITION Or MF_REMOVE
DrawMenuBar frm.hwnd
End If
End If
Call SetWindowLong(hwnd, GWL_STYLE, CurStyle)
Call DrawMenuBar(hwnd)
End Function
y Para llamar la funcion en tu formulario Incio
Option Compare Database
Option Explicit
Public BtnCerrar As Boolean
Private Sub Form_Open(Cancel As Integer)
'Cargo el proceso y elimino el Boton Minimizar
CargaFuncionBtn_JJJT Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Elimino el Boton Cerrar
Cancel = Not Me.BtnCerrar
End Sub
'Crea un Boton de Comando para poder salir de la Aplicacion
Private Sub Comando2_Click()
DoCmd.Quit
End Sub