How to hide the minimize, restore and close button on a maximized form 
Author Message
 How to hide the minimize, restore and close button on a maximized form

This is a classic question that has given grey hairs to many Access
programmers.
Below is a methode that "removes" these buttons.

Make a new toolbar, move all menuitems to this toolbar
and make this toolbar behave as your menubar.
Make a dummy menubar that the forms are pointing to through the forms
menubar property and hide this menubar at startup.
CommandBars("My menubar").Enabled = False

Make the real toolbar and the toolbar that behaves as a menubar visible
with:
CommandBars("My toolbar").Enabled = True
CommandBars("My faiked menubar").Enabled = True

This should get rid of the close, resize, and minimize buttons once and for
all.

Kind regards
Hans-Christian Francke
www.master-office.com



Tue, 03 Aug 2004 17:10:32 GMT  
 How to hide the minimize, restore and close button on a maximized form
Thanks for posting this solution.
I had to abandon Microsoft's solution in Q210299 and Q128196.
Regards
Geoff


Sun, 08 Aug 2004 06:05:06 GMT  
 How to hide the minimize, restore and close button on a maximized form
The only unnormal behaviour I have had is that the Commandbars position is
varying.
To trap this behaviour use the .Left = 0 and .Position = 1 to position the
commandbars in the top left corner or use other values to position them in
other parts of the screen.

--

Kind regards
Hans-Christian Francke
www.master-office.com



Quote:
> Thanks for posting this solution.
> I had to abandon Microsoft's solution in Q210299 and Q128196.
> Regards
> Geoff



Mon, 09 Aug 2004 16:16:32 GMT  
 How to hide the minimize, restore and close button on a maximized form
Thanks for this additional information, which I've also saved for future
reference.
Geoff


Tue, 10 Aug 2004 06:25:50 GMT  
 How to hide the minimize, restore and close button on a maximized form
  > Thanks for posting this solution. I had to abandon Microsoft's solution
  > in Q210299 and Q128196. Regards Geoff

Hello,

The code in Q210299 needed a slight fix to make it work, and the
explanation of how to use it didn't really make sense. I prefer resizing
the form, rather than clunking about with a phantom toolbar that hides
the close button.

My solution and fix is as follows:

The error in Microsoft's code is on the 2nd last line, which contains
the "MoveWindow" command. Their original code had the parameters ending
with "+ 4", where they should have been "- 4", as I have them.

Also - don't forget to save and close your form and run it from the
closed state, or you will run into that Access quirk where it cannot
correctly resize a form if it is run by transitioning directly from
design view to form view. And in this case there is an additional depth
to this quirk in that the form resize takes place before the design
toolbars are removed, so there is a gap between the top of the form and
the bottom of the default toolbars. So you must run the form from the
closed state when using this code.

Overview of how to use this:

1) Put the code in the Form_Load event.

2) Set the form properties as follows: Border Style = None Control Box =
   No Min Max Buttons = None Close Button = No

3) Make sure the form is closed when you run it.

NOTE: If you cut and paste this, take out all the line wraps so each
      line of code is on its own line.

Type Rect X1 As Long Y1 As Long X2 As Long Y2 As Long End Type

Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect
As Rect) As Long Declare Function IsZoomed Lib "user32" (ByVal hwnd As
Long) As Long Declare Function ShowWindow Lib "user32" (ByVal hwnd As
Long, ByVal nCmdShow As Long) As Long Declare Function MoveWindow Lib
"user32" (ByVal hwnd As Long, ByVal X As Long, ByVal Y As Long, ByVal
nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long

Public Const SW_MAXIMIZE = 3 Public Const SW_SHOWNORMAL = 1

Sub Main(F As Form) Dim MDIRect As Rect If IsZoomed(F.hwnd) <> 0 Then
ShowWindow F.hwnd, SW_SHOWNORMAL End If GetWindowRect GetParent(F.hwnd),
MDIRect MoveWindow F.hwnd, 0, 0, MDIRect.X2 - MDIRect.X1 - 4, MDIRect.Y2
- MDIRect.Y1 - 4, True End Sub

Hope this helps everyone, Matt

--
Posted via dBforums
http://dbforums.com



Sat, 09 Oct 2004 05:10:54 GMT  
 How to hide the minimize, restore and close button on a maximized form
Matt:
Many thanks.
Saved in my library of solutions!
Geoff


Wed, 13 Oct 2004 06:37:38 GMT  
 How to hide the minimize, restore and close button on a maximized form

Quote:

>The code in Q210299 needed a slight fix to make it work, and the
>explanation of how to use it didn't really make sense.

Comments forwarded to Microsoft.

Thanks for posting, Tony
--
Tony Toews, Microsoft Access MVP
   Please respond only in the newsgroups so that others can
read the entire thread of messages.
   Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm



Fri, 15 Oct 2004 10:02:15 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. How to hide the maximize/restore and close-button on a maximized form

2. How to hide the maximize/restore and close-button on a maximized form

3. MS minimize,maximize, and close buttons-how to display on all form

4. Disable Close, Restore Buttons on Maximized Form

5. Minimize, restore and maximize vs hidden

6. Maximized form shows Restore button when maximized

7. Removing the minimize/maximize and restore buttons

8. Disable / Hide Close/Minimize/Maximize

9. Hide Close, Minimize and Maximize at top of access window

10. How to disable the Minimize, Maximize and Close buttons


 
Powered by phpBB® Forum Software © phpBB Group