DISABLE close button when MAXIMIZE? 
Author Message
 DISABLE close button when MAXIMIZE?

How to write a code to the form to be disable the close (x) button
(near min & max on the upper right side) of the form and access application.

I want user only to be able to close the application through (handmade)
close button.

Thanks for any help,



Mon, 13 Aug 2001 03:00:00 GMT  
 DISABLE close button when MAXIMIZE?
It's much easier to trap the user trying to close the application through a
form, if the conditions don't match your criteria you can cancel the unload
event of your form and that will prevent Access from closing.

Quote:

>How to write a code to the form to be disable the close (x) button
>(near min & max on the upper right side) of the form and access
application.

>I want user only to be able to close the application through (handmade)
>close button.

>Thanks for any help,



Mon, 13 Aug 2001 03:00:00 GMT  
 DISABLE close button when MAXIMIZE?
If you need the Close button to be disabled all the time, set the form's
'Close Button' property to No.

Simon Lewis



Mon, 13 Aug 2001 03:00:00 GMT  
 DISABLE close button when MAXIMIZE?
[Posted & E-Mailed]

On the form properties, set 'Close Button' to 'No.'  Couldn't be
easier.

j----- k-----



Quote:
>How to write a code to the form to be disable the close (x) button
>(near min & max on the upper right side) of the form and access application.

>I want user only to be able to close the application through (handmade)
>close button.

>Thanks for any help,

-
Joshua J. Kugler

All opinions are mine, and not my employer's, unless otherwise stated.
I read this news group. Sometimes my ISP doesn't. Please e-mail too.


Mon, 13 Aug 2001 03:00:00 GMT  
 DISABLE close button when MAXIMIZE?
Hi Gattaga,

It's far easier to trap the close event by using the OnUnload event.  But
the only way currently to remove the buttons is to get rid of the caption
bar altogether. Try these links.

< http://home.att.net/~dashish/general/gen0005.htm >
< http://home.att.net/~dashish/api/api0022.htm >

HTH
--
Dev Ashish (Just my $.001)
---------------
The Access Web ( http://home.att.net/~dashish )
---------------

:How to write a code to the form to be disable the close (x) button
:(near min & max on the upper right side) of the form and access
application.
:
:I want user only to be able to close the application through (handmade)
:close button.
:
:Thanks for any help,
:
:



Mon, 13 Aug 2001 03:00:00 GMT  
 DISABLE close button when MAXIMIZE?
1: Change the form "Border Style" property to "None".
2: Call the sub from the Form "On Open" event.

Private sub Form_open(Cancel as Integer)
Call MaximizeRestoredForm(Me)
end sub
--
Doug
Reply to is anti-spammed remove the "z" from email

Quote:

>Thanks for your help, I have saved the code in the module tab
>and in the form activate option I try to call function MaximizeRestoredForm
>and it is doesn't work please be so kind to advice how to apply this code
>to the form and in which form action.

>Thanks a lot.



Mon, 13 Aug 2001 03:00:00 GMT  
 DISABLE close button when MAXIMIZE?
Thanks for your help, I have saved the code in the module tab
and in the form activate option I try to call function MaximizeRestoredForm
and it is doesn't work please be so kind to advice how to apply this code
to the form and in which form action.

Thanks a lot.


Quote:
>Hi Gattaga,

>It's far easier to trap the close event by using the OnUnload event.  But
>the only way currently to remove the buttons is to get rid of the caption
>bar altogether. Try these links.

>< http://home.att.net/~dashish/general/gen0005.htm >
>< http://home.att.net/~dashish/api/api0022.htm >

>HTH
>--
>Dev Ashish (Just my $.001)
>---------------
>The Access Web ( http://home.att.net/~dashish )
>---------------


>:How to write a code to the form to be disable the close (x) button
>:(near min & max on the upper right side) of the form and access
>application.
>:
>:I want user only to be able to close the application through (handmade)
>:close button.
>:
>:Thanks for any help,
>:
>:



Tue, 14 Aug 2001 03:00:00 GMT  
 DISABLE close button when MAXIMIZE?
I have tried as your advise, when compile and run form
the following error occured. (still not work)   :)

Complil error:
Expected variable or procedure, not module

I have the following code in the module and named as MaximizeRestoredForm

'*************************** Code Start ************************
'This code was originally written by Terry Kreft.
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
'Code courtesy of
'Terry Kreft
'
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 ************************


Quote:
>1: Change the form "Border Style" property to "None".
>2: Call the sub from the Form "On Open" event.

>Private sub Form_open(Cancel as Integer)
>Call MaximizeRestoredForm(Me)
>end sub
>--
>Doug
>Reply to is anti-spammed remove the "z" from email


>>Thanks for your help, I have saved the code in the module tab
>>and in the form activate option I try to call function

MaximizeRestoredForm
Quote:
>>and it is doesn't work please be so kind to advice how to apply this code
>>to the form and in which form action.

>>Thanks a lot.



Tue, 14 Aug 2001 03:00:00 GMT  
 DISABLE close button when MAXIMIZE?
Hi Gattaga,

The error usually means that you have the module named the same as the
function.  Try renaming the module to something different.

    HTH
    -- Dev

:I have tried as your advise, when compile and run form
:the following error occured. (still not work)   :)
:
:Complil error:
:Expected variable or procedure, not module
:
:I have the following code in the module and named as MaximizeRestoredForm
:
<snip>



Tue, 14 Aug 2001 03:00:00 GMT  
 DISABLE close button when MAXIMIZE?
Hi Gattaga,

The error usually means that you have the module named the same as the
function.  Try renaming the module to something different.

    HTH
    -- Dev

:I have tried as your advise, when compile and run form
:the following error occured. (still not work)   :)
:
:Complil error:
:Expected variable or procedure, not module
:
:I have the following code in the module and named as MaximizeRestoredForm
:
<snip>



Wed, 15 Aug 2001 03:00:00 GMT  
 DISABLE close button when MAXIMIZE?
Thank you everybody for your kind help, the following is post from
other newgroup which I had also post the question.

To disable Access's X button U need to call API

Public Const MF_BYPOSITION = &H400
Public Const MF_REMOVE = &H1000
Public Declare Function DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long
Public Declare Function GetMenuItemCount Lib "user32" _
(ByVal hMenu As Long) As Long
Public Declare Function GetSystemMenu Lib "user32" _
(ByVal hwnd As Long, _
ByVal bRevert As Long) As Long
Public Declare Function RemoveMenu Lib "user32" _
(ByVal hMenu As Long, _
ByVal nPosition As Long, _
ByVal wFlags As Long) As Long

Sub DisableX(fhWnd As Long)
Dim hMenu As Long
Dim menuItemCount As Long
'Obtain the handle to the form's system menu
hMenu = GetSystemMenu(fhWnd, 0)
If hMenu Then
'Obtain the number of items in the menu
menuItemCount = GetMenuItemCount(hMenu)
'Remove the system menu Close menu item.
'The menu item is 0-based, so the last
'item on the menu is menuItemCount - 1
Call RemoveMenu(hMenu, menuItemCount - 1, _
MF_REMOVE Or MF_BYPOSITION)
'Remove the system menu separator line
Call RemoveMenu(hMenu, menuItemCount - 2, _
MF_REMOVE Or MF_BYPOSITION)
'Force a redraw of the menu. This
'refreshes the titlebar, dimming the X
Call DrawMenuBar(fhWnd)
End If
End Sub
=========================================
To use it call following:
DisableX Application.hWndAccessApp
=========================================
But for X button on the form if U didn't maximize it U can set properties
"Close button = No" "Pop Up = Yes"


Quote:

>How to write a code to the form to be disable the close (x) button
>(near min & max on the upper right side) of the form and access
application.

>I want user only to be able to close the application through (handmade)
>close button.

>Thanks for any help,



Fri, 17 Aug 2001 03:00:00 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Disabling close button on maximized form - How?

2. Disable close button on maximized forms

3. DISABLE close button when MAXIMIZE?

4. How Disable close button on maximized form?

5. DISABLE close button when MAXIMIZE?

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

7. Disable Close, Restore Buttons on Maximized Form

8. Disable the close button when maximized

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

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


 
Powered by phpBB® Forum Software © phpBB Group