Disabling "close button" in a form 
Author Message
 Disabling "close button" in a form

Please help!!!!!!!
How can I disable that X in upper-right corner of a form but leaving the
Minimize button enabled & visible??

Thanx in advance,  Ike

--
ICQ: 8679454



Thu, 24 Aug 2000 03:00:00 GMT  
 Disabling "close button" in a form

Put the appropriate code in the query unload section of the form that has
the 'X' clicked.

Dave

Quote:

>Please help!!!!!!!
>How can I disable that X in upper-right corner of a form but leaving the
>Minimize button enabled & visible??

>Thanx in advance,  Ike

>--
>ICQ: 8679454



Fri, 25 Aug 2000 03:00:00 GMT  
 Disabling "close button" in a form

Hi, Ike,

This won't disable the button, but it will prevent the user from closing
the form.

Hope this helps,
Annette Gates

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

  Const vbFormControlMenu = 0 'the user chose the Close command from the
Control menu on the form.
  Const vbFormCode = 1  'the Unload statement is invoked from code.
  Const vbAppWindows = 2 'the current Microsoft Windows operating
environment session is ending.
  Const vbAppTaskManager = 3  'the Microsoft Windows Task Manager is
closing the application.
  Const vbFormMDIForm = 4  'an MDI child form is closing because the MDI
form is closing.

  If UnloadMode = vbFormControlMenu Then
    MsgBox "Sorry, but you can't close this form using the Control Menu"
    Cancel = True
  End If

End Sub


Quote:
> Please help!!!!!!!
> How can I disable that X in upper-right corner of a form but leaving the
> Minimize button enabled & visible??

> Thanx in advance,  Ike

> --
> ICQ: 8679454



Fri, 25 Aug 2000 03:00:00 GMT  
 Disabling "close button" in a form

This requires removing the close from the system menu, and forcing a menubar redraw.  The
API and constants can be found in the API viewer....

Private Sub Command5_Click()

  Dim hMenu As Long
  Dim MenuItems As Long
  Dim r As Long

  hMenu = GetSystemMenu(Form1.hwnd, 0)
  MenuItems = GetMenuItemCount(hMenu)

 'remove the system menu separator line
  r = RemoveMenu(hMenu, MenuItems - 1, MF_REMOVE Or MF_BYPOSITION)

 'remove the system menu Close menu item
  r = RemoveMenu(hMenu, MenuItems - 2, MF_REMOVE Or MF_BYPOSITION)

 'force a redraw of the menu,
 'this also refreshes the caption, dimming the X
  r = DrawMenuBar(Form1.hwnd)

End Sub

--

Randy Birch, MVP Visual Basic
VBnet, The Visual Basic Developers Resource Centre
http://home.sprynet.com/sprynet/rasanen/vbnet/default.htm

:Please help!!!!!!!
:How can I disable that X in upper-right corner of a form but leaving the
:Minimize button enabled & visible??
:
:Thanx in advance,  Ike
:
:--
:ICQ: 8679454
:
:



Fri, 25 Aug 2000 03:00:00 GMT  
 Disabling "close button" in a form

I used this method. It is work.
I need to remove(disabled) Form1.MaxButton at runtime.
I tried to apply this method to the decision of my problem.
MenuItems =7
I tried to use ...(hMenu, MenuItems - (value for 3 to 6)...), but positive
result has fail.. My error?

Thanks.
Vladimir.
*****************************

Quote:

>This requires removing the close from the system menu, and forcing a

menubar redraw.  The
Quote:
>Private Sub Command5_Click()
>  Dim hMenu As Long
>  Dim MenuItems As Long
>  Dim r As Long
>  hMenu = GetSystemMenu(Form1.hwnd, 0)
>  MenuItems = GetMenuItemCount(hMenu)
>  r = RemoveMenu(hMenu, MenuItems - 1, MF_REMOVE Or MF_BYPOSITION)
>  r = RemoveMenu(hMenu, MenuItems - 2, MF_REMOVE Or MF_BYPOSITION)
>  r = DrawMenuBar(Form1.hwnd)
>End Sub



Sat, 26 Aug 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. How to disable the "close" button

2. disable "X" (close button) in ControlBox

3. Disabling "BACK"/"FORWARD" buttons

4. Disabling "BACK"/"FORWARD" buttons

5. Disable Application Quit ("X") Button

6. Disable "Add button" from toolbar

7. Disable the "Insert" Button

8. How to disable "PrintScreen" button

9. Disable "Back" Button

10. How to disable the "Back" button

11. Prevent Close ("X") Button under 95

12. newbie "Form Maximize" disable

 

 
Powered by phpBB® Forum Software