Disable close-button in windows titlebar 
Author Message
 Disable close-button in windows titlebar

Can anybody tell me how i can disable the close-button
in the window-titlebar or if it can be told to call subroutine
when pressed ?
(I still want to use a titlebar with min/max-buttons, but before
closing my programm i want to do something.)

Matthias G?bel



Mon, 13 Sep 2004 20:22:55 GMT  
 Disable close-button in windows titlebar
From several sources :

Subject:
        [VB] X on the form
    Date:
        Tue, 9 Jun 1998 10:11:40 -0400
   From:

Reply-To:
        "Visual Basic Beginner's List"

     To:

For an example that removes items from the system menu, go to
http://www.vb-helper.com/HowToInt.htm and click the "Remove items from a
form's system menu" link.

==============

Subject:
        Re: [VB] X on the form
    Date:
        Mon, 8 Jun 1998 10:50:32 -0400
   From:

Reply-To:
        "Visual Basic Beginner's List"

     To:

You can set the form to modal and that way the user has to perform some
function on the form before it can close.  The box will not appear on
the form.

myform.show vbmodal

Also, you can set a variable to be set to true when a form closes.

Here is how I used this:

Private Sub cmdClose_Click()

    On Error GoTo Error_cmdClose_Click

' indicates that it is time to reset the static variables
' to zero
    resetPeriod = True
    resetTime = True
' reset to zero for error trapping purposes
    TestNumber = 0

    Unload Me

Exit_cmdClose_Click:
    Exit Sub

Error_cmdClose_Click:
    MsgBox Err.Description, vbInformation, _
        "Error " & Err.Number & " - cmdClose_Click"
    Resume Exit_cmdClose_Click

End Sub

--- Jim

"Will the road you're on get you to My place ?" - God
                   _\|/_
                   (o o)
   ------oOO-{_}-OOo------



Mon, 13 Sep 2004 21:47:36 GMT  
 Disable close-button in windows titlebar
When you click the close button, the QueryUnload and Unload events are both fired (in that
order). QueryUnload has an argument which will tell you why the program is closing; both
events allow you to cancel the closing down of the Form via the Cancel argument.

Rick


Quote:
> Can anybody tell me how i can disable the close-button
> in the window-titlebar or if it can be told to call subroutine
> when pressed ?
> (I still want to use a titlebar with min/max-buttons, but before
> closing my programm i want to do something.)

> Matthias G?bel



Mon, 13 Sep 2004 21:57:34 GMT  
 Disable close-button in windows titlebar

Quote:
> Can anybody tell me how i can disable the close-button
> in the window-titlebar or if it can be told to call subroutine
> when pressed ?
> (I still want to use a titlebar with min/max-buttons, but before
> closing my programm i want to do something.)

> Matthias G?bel

Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long,
ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal
nPosition As Long, ByVal wFlags As Long) As Long
Private Const MF_BYPOSITION = &H400

Public Sub DisableCancelMenuItem(ByVal frm As Form)
'-------------------
Dim hSysMenu As Long
Dim retval As Long
'-------------------

On Error Resume Next

hSysMenu = GetSystemMenu(frm.hwnd, 0)

retval = RemoveMenu(hSysMenu, 6, MF_BYPOSITION)

retval = RemoveMenu(hSysMenu, 5, MF_BYPOSITION)

End Sub



Wed, 15 Sep 2004 06:27:19 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. disable close button without disabling make small button

2. Disable Close button on Application Window

3. Disable close button IE-window

4. Disable close button IE-window

5. disabling titlebar buttons

6. close [X] button in the titlebar word

7. validate a textbox when windows is closed by pressing close button [X]

8. How to: place a button over the titlebar of owner window

9. disable X button on a windows NT window

10. disable X button on a windows NT window

11. Closing a window from a button on another window

12. Disable Access close button

 

 
Powered by phpBB® Forum Software