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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide Max, Min and Close Buttons 3

Status
Not open for further replies.

Craftor

Programmer
Feb 1, 2001
420
NZ
Hi all

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.

Thanks as always

Craftor :cool:
 
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.
[machinegun][hammer]
 
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?

Paul Bent
Northwind IT Systems
 
Yup that hides the controls but is there any way to keep the form's title bar visible at the same time?
 
Craftor,

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.
[machinegun][hammer]
 
[cheers] If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
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.
 
Hi,

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

Private Const GWL_STYLE = (-16)

Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_SYSMENU = &H80000

Private Sub Form_Load()

Dim dwStyle 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)

End Sub
[/tt]

LuCkY
 
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... :)
 
LuckyLuke,
You get the supergenious of the day award. Thanks for the code, it worked great.
 
Does the supergenius also know how to add an extra command to the <ALT><SPACE> command box (like a dos box has edit commands)?
 
Yes, mister supergenious knows all:

[tt]
Option Explicit

Private Declare Function GetSystemMenu Lib &quot;user32.dll&quot; (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemCount Lib &quot;user32.dll&quot; (ByVal hMenu As Long) As Long
Private Declare Function InsertMenuItem Lib &quot;user32.dll&quot; Alias &quot;InsertMenuItemA&quot; (ByVal hMenu As Long, ByVal uItem As Long, ByVal fByPosition As Long, lpmii As MENUITEMINFO) As Long

Private Const MIIM_ID = &H2
Private Const MIIM_TYPE = &H10
Private Const MFT_STRING = &H0

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 = &quot;&Howdy&quot;
.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 :)
 
Hi,

is there a way to have the title bar visible
but not in the taskbar?

is there a way to have the form in the taskbar but its visible disabled?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top