UtterAccess.com

Welcome Guest ( Log In | Register ) · View New Posts · View Unanswered Topics

 
Reply to this topicStart new topic
> Close button X
 
   
JAVIRAFY
post Dec 10 2004, 05:06 PM
Post #1

UtterAccess Addict
Posts: 168



How can I disable the minimize, maximize and close button of Access application?
Go to the top of the page
 
+
donpayseur
post Dec 10 2004, 05:12 PM
Post #2

UtterAccess Veteran
Posts: 235
From: Charlotte, NC



Go to the Properties of the form and simply choose what features you would like the form to have. i.e.
min,max buttons, close etc.
Go to the top of the page
 
+
asmall
post Dec 10 2004, 05:13 PM
Post #3

UtterAccess Addict
Posts: 61



Open your form in design view, then set the "Min Max Buttons" to NONE and then set the "Close Button" to NO.

Alton
Go to the top of the page
 
+
JAVIRAFY
post Dec 10 2004, 05:16 PM
Post #4

UtterAccess Addict
Posts: 168



I meant the Access program min, max and close buttons, not my form
Go to the top of the page
 
+
JAVIRAFY
post Dec 10 2004, 05:59 PM
Post #5

UtterAccess Addict
Posts: 168



Can anyone help?
Go to the top of the page
 
+
Jack Cowley
post Dec 10 2004, 06:46 PM
Post #6

UA Editor + Utterly Certified
Posts: 37,677
From: The San Francisco Bay Area



The attached demo will not affect the minimize and restore buttons but will keep the X button from closing Access. Open the demo (Access2000) and after the splash screen try to click the Access X button. Click on the Enable X button on the form and then the X button will work...

hth,
Jack
Go to the top of the page
 
+
R. Hicks
post Dec 10 2004, 06:48 PM
Post #7

UA Forum Administrator
Posts: 37,112
From: Birmingham, Alabama USA



Place the following code in a new module:
CODE
Private Declare Function apiEnableMenuItem Lib "user32" Alias _

"EnableMenuItem" (ByVal hMenu As Long, ByVal wIDEnableMenuItem As Long, _

ByVal wEnable As Long) As Long



Private Declare Function apiGetSystemMenu Lib "user32" Alias _

"GetSystemMenu" (ByVal hwnd As Long, ByVal Flag As Long) As Long



Function EnableDisableCloseButton(bEnable As Boolean, _

Optional ByVal lhWndTarget As Long = 0) As Long

Dim lhWndMenu As Long

Dim lReturnVal As Long

Dim lAction As Long



Const MF_BYCOMMAND = &H0&

Const MF_DISABLED = &H2&

Const MF_ENABLED = &H0&

Const MF_GRAYED = &H1&

Const SC_CLOSE = &HF060&



lhWndMenu = apiGetSystemMenu(IIf(lhWndTarget = 0, Application.hWndAccessApp, lhWndTarget), False)



If lhWndMenu <> 0 Then

  If bEnable Then

    lAction = MF_BYCOMMAND Or MF_ENABLED

  Else

    lAction = MF_BYCOMMAND Or MF_DISABLED Or MF_GRAYED

  End If

  lReturnVal = apiEnableMenuItem(lhWndMenu, SC_CLOSE, lAction)

End If



EnableDisableCloseButton = lReturnVal



ErrorHandling_Err:

  If Err Then

    MsgBox Err.Number & ":" & Err.Description

  End If

  

End Function

Now ... in the first form of your application that opens .. place the following in the "On Load" event of the form:
CODE
Private Sub Form_Load()

EnableDisableCloseButton False

End Sub

The above code will disable the Close Button in Access.

Now add the following code to your Exit or Close button in your application:
CODE
Private Sub cmdExit_Click()

EnableDisableCloseButton True

DoCmd.Quit

End Sub

RDH


--------------------
Ricky Hicks
Birmingham, Alabama USA
Go to the top of the page
 
+
donpayseur
post Dec 11 2004, 09:33 AM
Post #8

UtterAccess Veteran
Posts: 235
From: Charlotte, NC



Wow, good stuff Jack, you are awesome!
Go to the top of the page
 
+
Jack Cowley
post Dec 11 2004, 12:13 PM
Post #9

UA Editor + Utterly Certified
Posts: 37,677
From: The San Francisco Bay Area



The thanks go to Richard Rensel for creating the demo and posting it here at Utter Access.... Continued success with your project...

Jack
Go to the top of the page
 
+

Reply to this topicStart new topic

 



RSS Lo-Fi Version Time is now: 2nd September 2010 - 11:26 AM