You can do this by toggling the WS_SYSMENU bit in window styles. See the following VB code. This is like setting the ControlBox property in design time in VB.
___
[tt]
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const GWL_STYLE = -16
Const WS_SYSMENU = &H80000
Const WM_NCPAINT = &H85
Private Sub Command1_Click()
SetWindowLong hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) Xor WS_SYSMENU
SendMessage hwnd, WM_NCPAINT, 0, ByVal 0& 'repaint the title bar
End Sub[/tt]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.