Results 1 to 3 of 3
  1. #1
    mjhd786 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    2

    How to disable just close button but keep min/max?

    I have code to disable all three options. How do I keep the min max buttons though?

    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

  2. #2
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    If you got into the Code Behind for the Unload Event on the form you can make it read.

    Private Sub Form_Unload(Cancel As Integer)
    Cancel = True
    End Sub

  3. #3
    mjhd786 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    2
    Quote Originally Posted by Perceptus View Post
    If you got into the Code Behind for the Unload Event on the form you can make it read.

    Private Sub Form_Unload(Cancel As Integer)
    Cancel = True
    End Sub
    I removed the code and tried this but it didn't do anything. I'm trying to disable the close button in Access main window but keep the min max buttons.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to disable the "close" button in Access
    By Demerit in forum Access
    Replies: 7
    Last Post: 12-08-2013, 07:08 PM
  2. How to disable save/close window in form
    By Kivan in forum Access
    Replies: 2
    Last Post: 08-16-2012, 02:52 AM
  3. Disable command button
    By rajulasb in forum Access
    Replies: 2
    Last Post: 08-04-2011, 05:32 AM
  4. Disable master form close button
    By Carpy01 in forum Forms
    Replies: 3
    Last Post: 12-31-2010, 05:41 PM
  5. Disable App Close button in 2007
    By ajetrumpet in forum Programming
    Replies: 3
    Last Post: 09-05-2010, 11:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums