Click to See Complete Forum and Search --> : Lock form resizing


udipr
March 15th, 2001, 02:55 AM
Hi

I wan't to make form Maximize and without option to resize it.

I set that form properties:
BorderStyle = 1 - FixedSingle
WindowState = Maximized

I run the program and the form is Maximizes without option to resize...
But if i DblClicked on the form Caption the form resize to normal size.

How can I prevent that action ???
(without set the size to Maximize in the Resize event!)

Thank you for help.

Clearcode
March 15th, 2001, 03:09 AM
There is a solution that involves subclassing and is a bit involved if you actually are a beginner - it's posted at http://www.merrioncomputing.com in the advanced section of the Visual Basic index.



-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com

shree
March 15th, 2001, 06:01 AM
Make

Me.Height = Screen.Height
Me.Width = Screen.Width

Now, with the BorderStyle set to fixed single, you get a maximized form that will not resize. But it will move still.
If you remove the Move item from a form's control menu, the user will not be able to move it in any way.
Here is a code sample that will prevent the user from both moving and resizing a form by modifying the system menu.



private Declare Function GetSystemMenu Lib "User" (byval hWnd%, byval bRevert%) as Integer
private Declare Function DeleteMenu Lib "user" (byval hMenu%, byval iditem%, byval wflags%) as Integer

private Const SC_SIZE = &HF000
private Const SC_MOVE = &HF010
private Const MF_BYCOMMAND = &H0

Sub Form_Load()
Dim hWnd%, hMenu%, Success%
hWnd% = me.hWnd
hMenu% = GetSystemMenu(hWnd%, 0)
Success% = deletemenu(hMenu%, SC_SIZE, MF_BYCOMMAND)
Success% = deletemenu(hMenu%, SC_MOVE, MF_BYCOMMAND)
End Sub