ola Pessoal
nao consegui desabilitar ou bloquer o botao
por favor se tiver um exemplo me ajuda access 2016
obrigado
nao consegui desabilitar ou bloquer o botao
por favor se tiver um exemplo me ajuda access 2016
obrigado
Option Compare Database
Option Explicit
Const SC_CLOSE As Long = &HF060&
Const MIIM_STATE As Long = &H1&
Const MIIM_ID As Long = &H2&
Const MFS_GRAYED As Long = &H3&
Const MFS_CHECKED As Long = &H8&
Const WM_NCACTIVATE As Long = &H86
Type MENUITEMINFO
cbSize As Long
fMask As Long
fType As Long
fState As Long
wID As Long
hSubMenu As Long
hbmpChecked As Long
hbmpUnchecked As Long
dwItemData As Long
dwTypeData As String
cch As Long
End Type
Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal B As Boolean, lpMenuItemInfo As MENUITEMINFO) As Long
Declare Function SetMenuItemInfo Lib "user32" Alias "SetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal bool As Boolean, lpcMenuItemInfo As MENUITEMINFO) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As Long) As Long
Const xSC_CLOSE As Long = -10
Const SwapID As Long = 1
Const ResetID As Long = 2
Private hMenu As Long
Private MII As MENUITEMINFO
Sub Disable()
Dim Ret As Long
Ret = SetId(SwapID)
If [Ret] = 0 Then
If MII.fState = (MII.fState Or MFS_GRAYED) Then
MII.fState = MII.fState - MFS_GRAYED
Else
MII.fState = (MII.fState Or MFS_GRAYED)
End If
MII.fMask = MIIM_STATE
Ret = SetMenuItemInfo(hMenu, MII.wID, False, MII)
If Ret = 0 Then
Ret = SetId(ResetID)
End If
Ret = SendMessage(Application.hWndAccessApp, WM_NCACTIVATE, True, 0)
End If
End Sub
Private Function SetId(Action As Long) As Long
Dim MenuID As Long
Dim Ret As Long
MenuID = MII.wID
If MII.fState = (MII.fState Or MFS_GRAYED) Then
If Action = SwapID Then
MII.wID = SC_CLOSE
Else
MII.wID = xSC_CLOSE
End If
Else
If Action = SwapID Then
MII.wID = xSC_CLOSE
Else
MII.wID = SC_CLOSE
End If
End If
MII.fMask = MIIM_ID
Ret = SetMenuItemInfo(hMenu, MenuID, False, MII)
If Ret = 0 Then
MII.wID = MenuID
End If
SetId = Ret
End Function
Sub DesabilitaBotFechar()
Dim Ret As Long
Dim hwnd As Long
hMenu = GetSystemMenu(Application.hWndAccessApp, 0)
MII.cbSize = Len(MII)
MII.dwTypeData = String(80, 0)
MII.cch = Len(MII.dwTypeData)
MII.fMask = MIIM_STATE
MII.wID = SC_CLOSE
Ret = GetMenuItemInfo(hMenu, MII.wID, False, MII)
Disable
End Sub