DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: How to disable the form Close button only on a VB form

  1. #1
    santosh Guest

    How to disable the form Close button only on a VB form


    hi !

    Can anybody tell me how to disable the Close button on a VB form . If I try
    to disable the control box , then maximise and minimise button are also gone.

    I want maximise and minimise button on the form , but the close button should
    be diabled.

    thanks in advance

    santosh


  2. #2
    Mark Alexander Bertenshaw Guest

    Re: How to disable the form Close button only on a VB form


    "santosh" <sant99@hotmail.com> wrote:
    >
    >hi !
    >
    >Can anybody tell me how to disable the Close button on a VB form . If I

    try
    >to disable the control box , then maximise and minimise button are also

    gone.
    >
    >I want maximise and minimise button on the form , but the close button should
    >be diabled.
    >
    >thanks in advance
    >
    >santosh
    >


    Santosh -

    This should do the trick:

    --------------------------------------------------------------------------

    Option Explicit

    Private Declare Function DeleteMenu Lib "user32.dll" ( _
    ByVal hMenu As Long, _
    ByVal lPosition As Long, _
    ByVal lFlags As Long _
    ) As Long

    Private Declare Function GetSystemMenu Lib "user32.dll" ( _
    ByVal hWnd As Long, _
    ByVal bRevert As Long _
    ) As Long

    Private Const SC_CLOSE = &HF060
    Private Const MF_BYCOMMAND = 0

    Private Sub Command1_Click()
    Unload Me
    End Sub

    Private Sub Form_Load()
    Dim hMenu As Long

    hMenu = GetSystemMenu(Me.hWnd, 0)
    DeleteMenu hMenu, SC_CLOSE, MF_BYCOMMAND

    End Sub

    --------------------------------------------------------------------------


    --
    Mark Alexander Bertenshaw
    Programmer/Analyst
    Chordiant Software, Inc.
    Brentford
    UK

  3. #3
    Mark Alexander Bertenshaw Guest

    Re: How to disable the form Close button only on a VB form


    "santosh" <sant99@hotmail.com> wrote:
    >
    >hi !
    >
    >Can anybody tell me how to disable the Close button on a VB form . If I

    try
    >to disable the control box , then maximise and minimise button are also

    gone.
    >
    >I want maximise and minimise button on the form , but the close button should
    >be diabled.
    >
    >thanks in advance
    >
    >santosh
    >


    Santosh -

    This should do the trick:

    --------------------------------------------------------------------------

    Option Explicit

    Private Declare Function DeleteMenu Lib "user32.dll" ( _
    ByVal hMenu As Long, _
    ByVal lPosition As Long, _
    ByVal lFlags As Long _
    ) As Long

    Private Declare Function GetSystemMenu Lib "user32.dll" ( _
    ByVal hWnd As Long, _
    ByVal bRevert As Long _
    ) As Long

    Private Const SC_CLOSE = &HF060
    Private Const MF_BYCOMMAND = 0

    Private Sub Command1_Click()
    Unload Me
    End Sub

    Private Sub Form_Load()
    Dim hMenu As Long

    hMenu = GetSystemMenu(Me.hWnd, 0)
    DeleteMenu hMenu, SC_CLOSE, MF_BYCOMMAND

    End Sub

    --------------------------------------------------------------------------


    --
    Mark Alexander Bertenshaw
    Programmer/Analyst
    Chordiant Software, Inc.
    Brentford
    UK

  4. #4
    Karl E. Peterson Guest

    Re: How to disable the form Close button only on a VB form

    Hi Santosh --

    The FormBdr.zip sample at http://www.mvps.org/vb is a dropin solution to this and a
    couple dozen other common form characteristics that aren't always easy to set at
    runtime.

    Later... Karl
    --
    [Microsoft Basic: 1976-2001, RIP]


    "santosh" <sant99@hotmail.com> wrote in message news:3be24596$1@147.208.176.211...
    >
    > hi !
    >
    > Can anybody tell me how to disable the Close button on a VB form . If I try
    > to disable the control box , then maximise and minimise button are also gone.
    >
    > I want maximise and minimise button on the form , but the close button should
    > be diabled.
    >
    > thanks in advance
    >
    > santosh
    >



  5. #5
    Karl E. Peterson Guest

    Re: How to disable the form Close button only on a VB form

    Hi Santosh --

    The FormBdr.zip sample at http://www.mvps.org/vb is a dropin solution to this and a
    couple dozen other common form characteristics that aren't always easy to set at
    runtime.

    Later... Karl
    --
    [Microsoft Basic: 1976-2001, RIP]


    "santosh" <sant99@hotmail.com> wrote in message news:3be24596$1@147.208.176.211...
    >
    > hi !
    >
    > Can anybody tell me how to disable the Close button on a VB form . If I try
    > to disable the control box , then maximise and minimise button are also gone.
    >
    > I want maximise and minimise button on the form , but the close button should
    > be diabled.
    >
    > thanks in advance
    >
    > santosh
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center