Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove Min/max/close buttons

Status
Not open for further replies.

ashthud

Programmer
Oct 6, 2008
53
GB
1) What is the official name of the min/max/close button trio?

2) How can i remove the trio from a window that has already been created?

Ashthud
 
The best you can do is remove the maximize and minimize buttons and disable the close button.

See these for hints on how to do that.

thread102-1472745
thread209-1456767

----------
Measurement is not management.
 
I looked at the second thread closer and am reminded you can remove the entire menu. Look there for what you want.

----------
Measurement is not management.
 
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]
 
In the property window for the form, under Window Style you will see Control Box select it and change it to false.

This will get rid of the min/max/close btns, and if you get rid of the .text for the form the border will shrink and be uniform around the form.
 
>the property window for the form

Which unfortunately we won't have for a window that has already been created as per the original question. Hence Glenn9999's and Hypetia's solutions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top