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

Can i make it so a form can never be resized smaller than a min value? 1

Status
Not open for further replies.

adi316

Programmer
Sep 10, 2002
35
CA
But it can be resized larger? TIA!
 

Yes, try this code

[tt]Option Explicit

Private Sub Form_Resize()
If Me.WindowState <> vbMinimized Then
If Me.Width < 2000 Then Me.Width = 2000
If Me.Height < 2000 Then Me.Height = 2000
End If
End Sub
[/tt]
 
On a child form You should change what vb5prgrmr said from
If Me.WindowState <> vbMinimized Then

to
If (Me.WindowState <> vbMinimized)or (Me.WindowState <> vbMaximized)Then


to avoid side affects, it can happen that a MIDI form has a size smaller than what you wish, the child form can react with an error. Its also good practice because you never know what a user is doing, perhaps a user changed the width or height of the task bar to 90% of the screen, for what ever strange reason...

One of my best teachers always said :
There is nothing that doesn't exist.
 

merlinx,

Unfortunatly you are using an or in your statement. Add your code to mine, then minimize the form and see what happens.

I'll give you a hint.

Run Time Error '384'

A form can't be moved or sized while minimized or maximized.


That should be an And in your code that should be added to mine.

Thanks
 
Correct...

I was thinking = and not <>, Thanks for the correction.

;-)
 
Of course, this solution does have the (minor) drawback that the rubberbanding isn't limited by the extents that you choose - and is particulalry noticeable if you have full window dragging enabled which results in some additional visual artifacts.

It does have the advantage of being slightly simpler than the API variant.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top