Disabling close button on maximized form - How? 
Author Message
 Disabling close button on maximized form - How?

Hi,

I'm trying to find a way to get rid of the close button on a maximized form
(Access 97).  I have picked up the following code from Terry Kreft, but
don't know how to call it in the form:

Can anyone tell me how to use it

Cheers

Paul

'===========================================================================
=
(A)    The reappearence of Close button on maximized forms is typical
behavior of maximized windows.  Solution is either not to maximize the form,
or instead of Docmd.Maximize, use the function provided by Terry Kreft from
the Access Web FAQ site:

Type Rect
    x1 As Long
    y1 As Long
    x2 As Long
    y2 As Long
End Type
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
'Use following instead of GetWindowRect
Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect _
    As Rect) As Long

Public Const SW_MAXIMIZE = 3
Public Const SW_SHOWNORMAL = 1

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, 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
'*************************** Code End ************************



Fri, 01 Jul 2005 04:22:09 GMT  
 Disabling close button on maximized form - How?
Hi,
MaximizeRestoredForm Me

--
HTH
Dan Artuso, MVP

"a problem well stated is a problem half solved"


Quote:
> Hi,

> I'm trying to find a way to get rid of the close button on a maximized
form
> (Access 97).  I have picked up the following code from Terry Kreft, but
> don't know how to call it in the form:

> Can anyone tell me how to use it

> Cheers

> Paul

'===========================================================================
Quote:
> =
> (A)    The reappearence of Close button on maximized forms is typical
> behavior of maximized windows.  Solution is either not to maximize the
form,
> or instead of Docmd.Maximize, use the function provided by Terry Kreft
from
> the Access Web FAQ site:

> Type Rect
>     x1 As Long
>     y1 As Long
>     x2 As Long
>     y2 As Long
> End Type
> 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
> 'Use following instead of GetWindowRect
> Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect _
>     As Rect) As Long

> Public Const SW_MAXIMIZE = 3
> Public Const SW_SHOWNORMAL = 1

> 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, 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
> '*************************** Code End ************************



Fri, 01 Jul 2005 04:50:09 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Disable close button on maximized forms

2. How Disable close button on maximized form?

3. Disable Close, Restore Buttons on Maximized Form

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

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

6. Disable Access Close Button not Form Close Button?

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

8. DISABLE close button when MAXIMIZE?

9. DISABLE close button when MAXIMIZE?

10. Disable the close button when maximized


 
Powered by phpBB® Forum Software © phpBB Group