Megatron helped with the min, max, x disabling. Thanks.
Is there a way to stop the user from resizing?
Printable View
Megatron helped with the min, max, x disabling. Thanks.
Is there a way to stop the user from resizing?
Remove the Size commmand like you did with the rest.
Code:Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Const MF_BYPOSITION = &H400&
Private Sub Form_Load()
RemoveMenu GetSystemMenu(hwnd, 0), 2, MF_BYPOSITION
End Sub
I tryed Megatron's code in Windows 2000 with VB6 sp4 and I could NOT stop the form to maximize if I dbl-click on the titlebar. sorry
Code:Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Const MF_BYPOSITION = &H400&
Private Sub Form_Load()
RemoveMenu GetSystemMenu(hwnd, 0), 2, MF_BYPOSITION
End Sub
That because the above example will stop the user from resizing the Form. If you want to prevent them from maximizing the Form, use the following code.
Code:Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Const MF_BYPOSITION = &H400&
Private Sub Form_Load()
RemoveMenu GetSystemMenu(hwnd, 0), 4, MF_BYPOSITION
End Sub
Gentlemen, first thanks for you responses.
I just wanted to explain things better. I have a MDIform that is maximized on startup. I have disabled the min,restore, and x button. Double clicking on titlebar resizes and that is the problem.
The code I gave above should fix the problem.
Megatron - Yeah.. Now I see.. and it works.. great!
Megatron, the maximize button will not function, true.
However, it is not grayed out. This looks better and is not confusing. Lets the user know it is disabled.
Here is how to keep a form/mdiform from being resized:
Code:'Author: Megatron
'Origin: http://forums.vb-world.net/showthread.php?postid=91647
'Purpose: Keep a form from being resized.
'Version: VB4+
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Dim LockWindow As Boolean
Dim iWidth As Integer
Dim iHeight As Integer
Private Sub MDIForm_Load()
'Save the initial dimensions
iWidth = Me.Width
iHeight = Me.Height
End Sub
Private Sub MDIForm_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
LockWindowUpdate 0&
End Sub
Private Sub MDIForm_Resize()
On Error Resume Next
Static FirstLoad
'If this is the First time the Window is loading then don't lock it
If FirstLoad = False Then
FirstLoad = True
LockWindow = True
Exit Sub
End If
'Lock the Window when the User tries to resize it
If LockWindow = True Then
'Restore the dimensions
Me.Width = iWidth
Me.Height = iHeight
LockWindowUpdate Me.hWnd
End If
End Sub
With simple API, using LockWindowUpdate is not necessary, however, that method is good if you don't want the menu completely reomved.