victoryhighway2
Programmer
Hello Group,
I found this code on another board to disable the "X" close button on a form in VB6. What I would like to know is, once the Close buttons is disabled in this manner, how can I re-enable it? The reason why I am asking is because I am working on a download window where I don't want the user to use the close button while downloading, but I want to re-enable it when the download is finished. Any suggestions?
Regards,
Geoffrey
I found this code on another board to disable the "X" close button on a form in VB6. What I would like to know is, once the Close buttons is disabled in this manner, how can I re-enable it? The reason why I am asking is because I am working on a download window where I don't want the user to use the close button while downloading, but I want to re-enable it when the download is finished. Any suggestions?
Regards,
Geoffrey
Code:
Module:
Option Explicit
Public Const SC_CLOSE = &HF060
Public Const MF_BYCOMMAND = &H0
Public Declare Function GetSystemMenu Lib "user32" _
(ByVal hwnd As Long, ByVal bRevert As Long) As Long
Public Declare Function DeleteMenu Lib "user32" _
(ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Code:
Form:
Public Sub DisableXbutton(ByVal frmHwnd As Long)
Dim hMenu As Long
hMenu = GetSystemMenu(frmHwnd, 0&)
If hMenu Then
Call DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND)
DrawMenuBar (frmHwnd)
End If
End Sub