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

Setting a form so it can't be resized

Status
Not open for further replies.

Streetdaddy

Programmer
Jun 10, 1999
161
AU
Im trying to work out how to prevent a form, with BorderStyle property of Sizeable, from being resized in certain situations. My first idea was to save the current size in variables and make the resize event just keep the form the same size if triggered. It works okay, but the form doesn't repaint properly. The scroll bar doesnt go to the edge of the form.<br>
<br>
Any ideas? API calls etc...<br>
<br>
P.S. The form is using the Protoview Interact control.
 
You can tell the program the max and min of the size you want it to be... so that when some one tries to resize it well it looks like it will work but snaps back to the size you want it.... I don't remember the code for it... but it is not too much work... sort of a cheap fix but it works... also Depending on why you would not want to be resized you can do like i do alot. and just disable the max button and set the code to not resize it... just so you can still use the minimize button... <br>
<br>
Tinman<br>
<br>
Welcome to OZ <br>

 
I use the following code in a bas file I call CancelX.bas<br>
<br>
Private Declare Function GetSystemMenu Lib "USER32" _<br>
(ByVal hWnd As Long, ByVal bRevert As Long) As Long<br>
Private Declare Function RemoveMenu Lib "USER32" _<br>
(ByVal hMenu As Long, ByVal nPosition As Long, _<br>
ByVal wFlags As Long) As Long<br>
<br>
Private Const MF_BYPOSITION = &H400&<br>
<br>
Public Sub RemoveCancelMenuItem(frm As Form)<br>
Dim hSysMenu As Long<br>
<br>
' get the system menu for this form<br>
hSysMenu = GetSystemMenu(frm.hWnd, 0)<br>
' remove the close item<br>
Call RemoveMenu(hSysMenu, 6, MF_BYPOSITION)<br>
' remove the separator that was over the close item<br>
Call RemoveMenu(hSysMenu, 5, MF_BYPOSITION)<br>
End Sub<br>
<br>
Then I put the following line in the form load event.<br>
<br>
RemoveCancelMenuItem me<br>
<br>
This will remove the X from the upper right and the close option from the forms menu.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top