Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

i disabled my Close button, but if the form is maximized, it's enabled 1

Status
Not open for further replies.

ruthcali

Programmer
Joined
Apr 27, 2000
Messages
470
Location
US
i am using Access 97.

i disabled my Close button (Close button = no on the form's property sheet.)

But when my form is maximized (like it always is), the X is still enabled and is in the upper right corner.

If the form isn't maximized, the X is grayed out like it should be.

How can i make the X gray and disabled even if the form is maximized?
 
Disable the Command Box... This will remove the greyed out close button, and hopefully, will only leave the application close button.

Hope this helps..

Phooey
Andrew.j.harrison@capgemini.co.uk
Otherwise known as Windy Bottom.
 
Thanks for writing. What and where is the command box?

But, i want to disable the application Close button. i have some code that i want to run when the user closes a window. so i created a command button called Close and put the code for the on_click event of that button. i want to make sure the user can ONLY use that button to close the form.

Your advice: "This will remove the greyed out close button, and hopefully, will only leave the application close button." does the opposite of what i want.

Thanks,

 
you can't disable the application close button. You can write code to maximize the form window without using the DoCmd.Maximize statement (which causes the Close button to appear), but as far as the Access Application close button, no can do. What you can do is write code in your form's Close or Deactivate or Unload event to check to see if the command button was clicked, and take action to cleanup your process if it wasn't.

PaulF
 
Thanks for writing. well, at least now i know that you can't disable the application close button. that clears a lot of things up!

To get around that, i took your advice and put the code in the on_close event of the form. I actually put the code in both places, the cmdClose button and the on_close event of the form. (The code is just one IF statement that eithers marks a check box as true or false).

Do you see any problems with putting the code twice?

thanks Paul,
Ruth
PS-did you have a nice thanksgiving?
 
PaulF:

I know this post is from a long time ago, but how would you write code to maximize the form without using the DoCmd.Maximize command. I'm currently using a macro to maximize a form when it opens but, like ruthcali, I don't want the close-window option to be available for the user.

-- jallan71
 
here is some code I picked up out there on the net

Just add this to the form

Option Compare Database
Option Explicit

Private Sub Form_Load()
Call MaximizeRestoredForm(Me)
End Sub

Sub MaximizeRestoredForm(f As Form)
Dim MDIRect As Rect
' If the form is maximized, restore it.
If IsZoomed(f.hwnd) <> 0 Then
ShowWindow f.hwnd, Max_SW_SHOWNORMAL
End If
' Get the screen coordinates and window size of the
' MDIClient area.
'This is the line which is different
GetClientRect GetParent(f.hwnd), MDIRect
' Move the form to the upper left corner of the MDIClient
' window (0,0) and size it to the same size as the
' MDIClient window.
MoveWindow f.hwnd, 0, 0, MDIRect.x2 - MDIRect.x1, MDIRect.y2 - MDIRect.y1, True
End Sub
Sub MinimizeRestoredForm(f As Form)
Dim MDIRect As Rect
' If the form is maximized, restore it.
If IsZoomed(f.hwnd) <> 0 Then
ShowWindow f.hwnd, Max_SW_SHOWNORMAL
End If
' Get the screen coordinates and window size of the
' MDIClient area.
'This is the line which is different
GetClientRect GetParent(f.hwnd), MDIRect
' Move the form to the upper left corner of the MDIClient
' window (0,0) and size it to the same size as the
' MDIClient window.
'MoveWindow F.hWnd, 0, 0, MDIRect.x2 - MDIRect.x2 / 4, MDIRect.y2 - MDIRect.y2 / 4, True
Dim lngWidth As Long
lngWidth = (Me.Width)

MoveWindow f.hwnd, 24, 24, MDIRect.x2 - MDIRect.x2 / 4, MDIRect.y2 - MDIRect.y2 / 4, True
End Sub
'*************************** Code End ************************

PaulF
 
Resize the form to the maximum size you want and then disable the min/max and close buttons. That way, they can't maximize the form. Make the form resizable if you want to have the ability to resize it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top