How can I remove the 'Restore Window' button from a form?

C

Crossh

I have a form that I set the control box property set to 'No', but when the
form is maximized, it still appears. How can I remove it? If I leave it on
the form, and you click it, it slightly minimizes the form and the box
disappears! I already got rid of the close button, minimize button & the help
box .

I created a custom toolbar and removed all other tool & menu bars.

Thanks
 
D

Dirk Goldgar

Crossh said:
I have a form that I set the control box property set to 'No', but
when the form is maximized, it still appears. How can I remove it? If
I leave it on the form, and you click it, it slightly minimizes the
form and the box disappears! I already got rid of the close button,
minimize button & the help box .

I created a custom toolbar and removed all other tool & menu bars.

Instead of maximizing the form, try the MaximizeRestoredForm() function
posted on this page:

http://www.mvps.org/access/api/api0022.htm
API: Remove Close button from maximized forms
 
C

Crossh

Thanks for the quick response! Works like a charm. One more question, should
I do this on the Form Activate event?
 
D

Dirk Goldgar

Crossh said:
Thanks for the quick response! Works like a charm. One more question,
should I do this on the Form Activate event?

Depends on the circumstances, I think. I've never used it in practice,
but I've tested it by putting code in the form's Open event:

Private Sub Form_Open(Cancel As Integer)

MaximizeRestoredForm Me

End Sub

But if the application is already in a maximized state, you probably
want to ensure that it's restored before you run that:

Private Sub Form_Open(Cancel As Integer)

DoCmd.Restore
DoEvents
MaximizeRestoredForm Me

End Sub

On the other hand, if you're going to be running other forms from this
form, and those forms may execute DoCmd.Maximize, then you may need to
put the code in this form's Activate event. I'm not sure how that's
going to look in practice, though. You may have to tinker with it, and
you may find that it doesn't work well for an app that opens lots of
forms and maximizes some of them.
 
V

Van T. Dinh

I always use MaximizeRestoredForm in the Activate Event since this means
that whenever the Form gets activated, it will be "restored" to occupy the
whole Access application window.
 
C

Crossh

Thanks for your help. I did notice that the Form that gets loaded on Startup
has a grey bar where the standard menu would've been. I'm using my own custom
menu bar on startup. Any ideas for getting rid of this at startup? When I
leave the form and return, the On Activate event resizes the form correctly.
 
C

Crossh

It displays where the regular menu bar would normally be. It appears that the
form resizes after the Custom Menubar is added but before it removes the
regular Menu Bar.
 
V

Van T. Dinh

Not sure (I had a similar problem but it dissapeared and I couldn't remember
what I did to fix it) but try:

Docmd.ShowToolbar "Menu Bar", acToolbarNo
DoEvents

before using MaximizeRestoredForm.
 
C

Crossh

This didn't work, I think the ShowToolbar action only works for Toolbars, not
Menubars. It appears that the removal of the standard Menubar is the last
thing that occurs, even after the Current event. I even tried to use the
GotFocus event, no luck. At this point, I'm ready to give up. Thanks for all
your help.
 
V

Van T. Dinh

MenuBar is actually one of the ToolBars.

I don't think the problem is the MenuBar. From my testing, the problem is
whichever the ToolBar (excluding the MenuBar) visible just before the Form
is activated that leaves the blank / grey area.

If you really want to try , do the following:

1. In the Startup Options, make sure the option "Display Database Window" is
unchecked.

2. Don't even bother set the "Menu Bar" property of the Form.

3. Add Microsoft Office Library into the References Collection of your
database and code your StartUp Form_Activate Event something like:

********
Dim tb As office.CommandBar

For Each tb In Application.CommandBars
If (tb.Visible) Then
DoCmd.ShowToolbar tb.Name, acToolbarNo
End If
Next

' Replace with your custom Menubar name in the next statement
Me.MenuBar = "Custom 1"
Call MaximizeRestoredForm(Me)
********

I tested it in A2003 and it works fine.
 
V

Van T. Dinh

Thanks for the compliment, Dirk.

Remember to jump in threads that I involve anytime as I may disappear from
these newsgroups suddenly for extended periods of time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top