VB :: Code & APIs

[VB.NET] 닫기 (X) 버튼 비활성화 하기

Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Integer, ByVal bRevert As Integer) As Integer
Public Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Integer, ByVal nPosition As Integer, ByVal wFlags As Integer) As Integer
Public Const SC_CLOSE = &HF060&
Public Const MF_BYCOMMAND = &H0&

Function RemoveCloseButton(ByVal iHWND As Integer) As Integer
Dim iSysMenu As Integer
iSysMenu = GetSystemMenu(iHWND, False)
Return RemoveMenu(iSysMenu, SC_CLOSE, MF_BYCOMMAND)
End Function

 

상단의 코드를 Form1 클래스 내에 삽입하시고 사용하실 때
RemoveCloseButton(Me.Handle) 해 주시면 아래와 같이 닫기 버튼이 비활성화 됩니다. ^^

 

Close-Button-Disabled

 

고맙습니다.

Leave a Reply

Discover more from Dream big, Achieve more.

Subscribe now to keep reading and get access to the full archive.

Continue reading