-
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
-
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
-
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
-
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
>
-
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
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|