Boas Tardes
Como novato nestas andanças de VBA's gostaria de saber se é possível neutralizar o Botão X = Fechar projecto do access, (Não dos formulários), mas do Access na barra principal para obrigar ao utilizador a fechar com botão programado com procedimentos obrigatórios?
Podem fechar o tópico, já consegui resolver. Obrigado por tudo. tomo a liberdade de colocar directamente. Se estiver a infringir alguma regra peço desculpa, mas a minha atitude é deixar ajuda.
Private Const GWL_STYLE = (-16)
Private Const WS_CAPTION = &HC00000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_SYSMENU = &H80000
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOZORDER = &H4
Public Const SWP_FRAMECHANGED = &H20
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" ( _
ByVal hwnd As Long, _
ByVal nIndex As Long _
) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" ( _
ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long _
) As Long
Private Declare Function SetWindowPos Lib "user32" ( _
ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal X As Long, _
ByVal Y As Long, _
ByVal CX As Long, _
ByVal CY As Long, _
ByVal wFlags As Long _
) As Long
Function ShowAccessCloseButton(Show As Boolean) As Long
Dim hwnd As Long
Dim nIndex As Long
Dim dwNewLong As Long
Dim dwLong As Long
hwnd = hWndAccessApp
nIndex = GWL_STYLE
Const wFlags = SWP_NOSIZE + SWP_NOZORDER + SWP_FRAMECHANGED + SWP_NOMOVE
Const FLAGS_COMBI = WS_MINIMIZEBOX Or WS_MAXIMIZEBOX Or WS_SYSMENU
dwLong = GetWindowLong(hwnd, nIndex)
If Show Then
dwNewLong = (dwLong Or FLAGS_COMBI)
Else
dwNewLong = (dwLong And Not FLAGS_COMBI)
End If
Call SetWindowLong(hwnd, nIndex, dwNewLong)
Call SetWindowPos(hwnd, 0&, 0&, 0&, 0&, 0&, wFlags)
End Function
Como novato nestas andanças de VBA's gostaria de saber se é possível neutralizar o Botão X = Fechar projecto do access, (Não dos formulários), mas do Access na barra principal para obrigar ao utilizador a fechar com botão programado com procedimentos obrigatórios?
Podem fechar o tópico, já consegui resolver. Obrigado por tudo. tomo a liberdade de colocar directamente. Se estiver a infringir alguma regra peço desculpa, mas a minha atitude é deixar ajuda.
Private Const GWL_STYLE = (-16)
Private Const WS_CAPTION = &HC00000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_SYSMENU = &H80000
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOZORDER = &H4
Public Const SWP_FRAMECHANGED = &H20
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" ( _
ByVal hwnd As Long, _
ByVal nIndex As Long _
) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" ( _
ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long _
) As Long
Private Declare Function SetWindowPos Lib "user32" ( _
ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal X As Long, _
ByVal Y As Long, _
ByVal CX As Long, _
ByVal CY As Long, _
ByVal wFlags As Long _
) As Long
Function ShowAccessCloseButton(Show As Boolean) As Long
Dim hwnd As Long
Dim nIndex As Long
Dim dwNewLong As Long
Dim dwLong As Long
hwnd = hWndAccessApp
nIndex = GWL_STYLE
Const wFlags = SWP_NOSIZE + SWP_NOZORDER + SWP_FRAMECHANGED + SWP_NOMOVE
Const FLAGS_COMBI = WS_MINIMIZEBOX Or WS_MAXIMIZEBOX Or WS_SYSMENU
dwLong = GetWindowLong(hwnd, nIndex)
If Show Then
dwNewLong = (dwLong Or FLAGS_COMBI)
Else
dwNewLong = (dwLong And Not FLAGS_COMBI)
End If
Call SetWindowLong(hwnd, nIndex, dwNewLong)
Call SetWindowPos(hwnd, 0&, 0&, 0&, 0&, 0&, wFlags)
End Function