첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

■ MDI에서 최소화, 최대화 없애기

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

Private Const GWL_STYLE     = (-16)

Private Const WS_MAXIMIZEBOX = &H10000

Private Const WS_MINIMIZEBOX = &H20000

Private Const WS_SYSMENU    = &H80000

 

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal pWindowHandle As Long, ByVal lIndex As Long) As Long

Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal pWindowHandle As Long, ByVal lIndex As Long, ByVal lNewValue As Long) As Long

Private Declare Function GetSystemMenu Lib "user32" (ByVal pWindowHandle As Long, ByVal lRevert As Long) As Long

 

Private Const SC_MAXIMIZE = &HF030&

Private Const SC_MINIMIZE = &HF020&

Private Const SC_SIZE     = &HF000&

Private Const MF_BYCOMMAND = &H0&

 

Private Declare Function DeleteMenu Lib "user32" (ByVal pMenuHandle As Long, ByVal lPosition As Long, ByVal lFlag As Long) As Long

Private Declare Function DrawMenuBar Lib "user32" (ByVal pWindowHandle As Long) As Long

 

Private Sub MDIForm_Load()

    Dim lNewValue As Long

    Dim pMenuHandle As Long

 

    lNewValue = GetWindowLong(Me.hwnd, GWL_STYLE)

    lNewValue = lNewValue And Not WS_MAXIMIZEBOX ' 최대 버튼 제거

    lNewValue = lNewValue And Not WS_MINIMIZEBOX ' 최소 버튼 제거

    lNewValue = lNewValue And Not WS_SYSMENU    ' 시스템 메뉴 제거

 

    SetWindowLong Me.hwnd, GWL_STYLE, lNewValue

 

   ' 시스템 메뉴에서 최소화, 최대화 메뉴 제거

   pMenuHandle = GetSystemMenu(Me.hwnd, 0)

 

   DeleteMenu pMenuHandle, SC_MAXIMIZE, MF_BYCOMMAND

   DeleteMenu pMenuHandle, SC_MINIMIZE, MF_BYCOMMAND

   DeleteMenu pMenuHandle, SC_SIZE, MF_BYCOMMAND

 

   DrawMenuBar Me.hwnd

End Sub

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

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요