Question Is it possible to hide the Access 'X' close button?

mattkorguk

Registered User.
Local time
Today, 08:54
Joined
Jun 26, 2007
Messages
301
Hi All,
I have a 'user friendly' close button on the front screen which I've asked users to use as it logs when they've exited the Db. But some are still intent on using that little 'x' int he top right corner!!:eek:

Is there anyway to hide this little critter?? :confused:

Thanks
 
Hi,

im not entirely sure if you can hide it but i do have a module that can disable it and prompt user user to close via the button instead.

i will dig it today & post it for you.

NS
 
No.









but you can program the application not to close when clicked. See the attachment for an example.

Share and Enjoy!
 

Attachments

That's great guys, thanks for your prompt replies. Have a great weekend.
 
No.

but you can program the application not to close when clicked. See the attachment for an example.

Share and Enjoy!

Thankyou for sharing and I have enjoyed.

That will teach the buggers

Len
 
I have also since found this:

http://support.microsoft.com/?id=300688

Module: to use: Call SetEnabledState(True) or (False)

Code:
Option Compare Database
Option Explicit
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, _
    ByVal bRevert As Long) As Long
Private Declare Function EnableMenuItem Lib "user32" (ByVal hMenu As _
    Long, ByVal wIDEnableItem As Long, ByVal wEnable As Long) As Long
Const MF_GRAYED = &H1&
Const MF_BYCOMMAND = &H0&
Const SC_CLOSE = &HF060&
Public Function SetEnabledState(blnState As Boolean)
    Call CloseButtonState(blnState)
    Call ExitMenuState(blnState)
End Function
'Disable the Menu Option
Sub ExitMenuState(blnExitState As Boolean)
    Application.CommandBars("File").Controls("Exit").Enabled = blnExitState
End Sub
'Disable the Close Button Option
Sub CloseButtonState(boolClose As Boolean)
    Dim hWnd As Long
    Dim wFlags As Long
    Dim hMenu As Long
    Dim result As Long
       
    hWnd = Application.hWndAccessApp
    hMenu = GetSystemMenu(hWnd, 0)
    If Not boolClose Then
        wFlags = MF_BYCOMMAND Or MF_GRAYED
    Else
        wFlags = MF_BYCOMMAND And Not MF_GRAYED
    End If
    
    result = EnableMenuItem(hMenu, SC_CLOSE, wFlags)
End Sub

It's another way, just a little more complicated. :D
 
Hi,
This module does actually hide the main Access close button!
A few other ideas found here:
http://www.accessmvp.com/JConrad/accessjunkie/closebutton.html

Paste the following code into a module, then call it with
Call Buttons(false)

To turn them off and
Call Buttons(True)


Code:
[SIZE=1][COLOR=#0000ff]Option Explicit

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
[/COLOR][COLOR=#008000]' **************************************************[/COLOR]

[/SIZE][SIZE=1][COLOR=#0000ff]Function AccessTitleBar(Show As Boolean) As Long
  Dim hwnd As Long
  Dim nIndex As Long
  Dim dwNewLong As Long
  Dim dwLong As Long
  Dim wFlags As Long

  hwnd = hWndAccessApp
  nIndex = GWL_STYLE
  wFlags = SWP_NOSIZE + SWP_NOZORDER + SWP_FRAMECHANGED + SWP_NOMOVE

  dwLong = GetWindowLong(hwnd, nIndex)

  If Show Then
    dwNewLong = (dwLong Or WS_CAPTION)
  Else
    dwNewLong = (dwLong And Not WS_CAPTION)
  End If

  Call SetWindowLong(hwnd, nIndex, dwNewLong)
  Call SetWindowPos(hwnd, 0&, 0&, 0&, 0&, 0&, wFlags)
End Function


Function Buttons(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[/COLOR][/SIZE]
 
I stand corrected.

Thank you for getting back with a solution.
 
No worries, Guus2005, I hoped it was possible. Is that a Fazer in your Sig?
 
On form, CLOSE BUTTON properties put NO.
 
MStef - Thank you, but that doesn't remove the actual Access close button, only the forms one.

Guus2005 - I'm more a Honda NC30 person. :D
 
mattkorguk, yes you are right. My mistake.
But the Access window can be hidden.
 
I beleive the solution posted on the MS website will not work in A2007 ... I personally just make that little button useless, presumably in the same manner as in the post above (I have not D/L'd ... I'm on a machine with out Access installed) ... but the post found here is similar to your posted topic and it has a link to a "complex" app that works in A2007 ... plus the "poor mans approach", which I prefer because its simple and works in all versions, and is completely contained in Access:
http://www.access-programmers.co.uk/forums/showthread.php?t=151649

Again, I did not D/L the zip file above, so if the method I suggested (the poor mans approach) is a virtual duplicate, I'm sorry about that!!!...
 

Users who are viewing this thread

Back
Top Bottom