Search Tools Links Login

_Disable X button on form


_Disable X button on form

Original Author: Petko Petkov

Code

Private Declare Function GetSystemMenu
Lib
"user32" (ByVal hwnd As
Long
, ByVal bRevert
As Long
) As Long

Private Declare Function GetMenuItemCount
Lib
"user32" (ByVal hMenu 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 Declare Function DrawMenuBar Lib
"user32" (ByVal hwnd As
Long
) As Long

Private Const MF_BYPOSITION = &H400&

Private Const MF_DISABLED = &H2&

Public Sub DisableX(Frm As
Form)

Dim hMenu As Long

Dim nCount As Long

  hMenu = GetSystemMenu(Frm.hwnd, 0)

  nCount = GetMenuItemCount(hMenu)

  Call RemoveMenu(hMenu, nCount - 1,
MF_DISABLED Or MF_BYPOSITION)

  DrawMenuBar Frm.hwnd

End Sub


Private Sub Command1_Click()

  DisableX Me

End Sub

About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 86 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.