Is there any API that can hide the 3 max, min and close buttons on a form. I know they can be disabled - but I need them completely invisible so that my form's title bar is the only thing that can be seen.
If you set the forms controlbox property to false, there will be no Min,Max or Close button, or are you doing something else? If you choose to battle wits with the witless be prepared to lose.
I only know how to disable them by disabling or removing commands in the system menu.
You can set the ControlBox, MaxButton and MinButton properties at design time in the VB IDE. If you need to change them at run time, is it feasible to have two versions of the same form and toggle them as required?
You must not have a Caption for the form, if you still want the title bar visible, just place a single space for the caption property. Does that help? If you choose to battle wits with the witless be prepared to lose.
Foada, This works fine on normal forms, but not on MDI Parent forms (no ControlBox property). Any ideas??? Right now I am disabling them, but it can be confusing to users.
It's easy. Just change the window style through API.
[tt]
Option Explicit
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
dwStyle = GetWindowLong(Me.hWnd, GWL_STYLE)
dwStyle = dwStyle And Not WS_MINIMIZEBOX
dwStyle = dwStyle And Not WS_MAXIMIZEBOX
dwStyle = dwStyle And Not WS_SYSMENU
Call SetWindowLong(Me.hWnd, GWL_STYLE, dwStyle)
Oh you can just use dwStyle And Not WS_SYSMENU, since that will disable the minimizebox and maximizebox as well, but I though it could be usefull to add those as well, since perhaps you wish to disable only one button or perhaps two. I don't know however if it's possible to just hide the close button and keep the others visible. I don't know why you would want that though, but I was just wondering...
Private Declare Function GetSystemMenu Lib "user32.dll" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32.dll" (ByVal hMenu As Long) As Long
Private Declare Function InsertMenuItem Lib "user32.dll" Alias "InsertMenuItemA" (ByVal hMenu As Long, ByVal uItem As Long, ByVal fByPosition As Long, lpmii As MENUITEMINFO) As Long
Private Type MENUITEMINFO
cbSize As Long
fMask As Long
fType As Long
fState As Long
wID As Long
hSubMenu As Long
hbmpChecked As Long
hbmpUnchecked As Long
dwItemData As Long
dwTypeData As String
cch As Long
End Type
Private Sub Form_Load()
Dim hMenu As Long
Dim lpmii As MENUITEMINFO
hMenu = GetSystemMenu(hWnd, False)
With lpmii
.cbSize = Len(lpmii)
.fMask = MIIM_TYPE Or MIIM_ID
.fType = MFT_STRING
.wID = 100 'ID to check when subclassing
.dwTypeData = "&Howdy"
.cch = Len(.dwTypeData)
End With
Call InsertMenuItem(hMenu, GetMenuItemCount(hMenu), 1, lpmii)
End Sub
[/tt]
If you want to find out if the menuitem was pressed, subclass the WM_SYSCOMMAND message and if the wparam matches the .wID parameter of the MENUITEMINFO type, the menuitem was pressed.
This works in your own application, but using the Get and SetWindowLong API calls, can I re-enable a disabled Maximize box on another application? Hmm that seems almost confusing the way I worded it. Let me clarify: Let's say I'm playing a game. I want to maximize the game, but the maximize button is disabled. Is it possible to re-enable the button with VB6? I know it can be done, because Windows Sniper could do it and that program isn't even around anymore (I don't think). You don't need to write the code for me but I would very much appreciate a hint as to what API's to use
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.