policechiefwiggum
Programmer
Hi All,
I want to disable to access main window close button.
i have password validation on my own "Exit" button, which is not invoked with the X.
I found this on the web -
which works so well it just removes all the buttons!
what i'd like is for either my password validation to work when the close button is clicked, or for just the close button to be diabled/removed. with the above code everything disapears meaning users are unable to minimize the appication
Thanks as always
Policechiefwiggum
I want to disable to access main window close button.
i have password validation on my own "Exit" button, which is not invoked with the X.
I found this on the web -
Code:
Option Compare Database
Option Explicit
Private Const GWL_EXSTYLE = (-20)
Private Const GWL_STYLE = (-16)
'Private Const WS_MAXIMIZEBOX = &H10000
'Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_SYSMENU = &H80000
Private Const HWND_TOP = 0
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED
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 GetWindowLong Lib "user32" _
Alias "GetWindowLongA" (ByVal hWnd As Long, _
ByVal nIndex 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
Sub HideAccessCloseButton()
Dim lngStyle As Long
lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE)
lngStyle = lngStyle And Not WS_SYSMENU
Call SetWindowLong(hWndAccessApp, GWL_STYLE, lngStyle)
Call SetWindowPos(hWndAccessApp, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_DRAWFRAME)
End Sub
which works so well it just removes all the buttons!
what i'd like is for either my password validation to work when the close button is clicked, or for just the close button to be diabled/removed. with the above code everything disapears meaning users are unable to minimize the appication
Thanks as always
Policechiefwiggum