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

Setting minimum form width ?

Status
Not open for further replies.

maverick

MIS
Apr 21, 1999
193
0
0
US
Hi All !

how do I set the minimum width on a sizable form ?

so they can't make it too small

tia :)

--------------------------------------
"Hacker by Heart"
saenzcorp@hotpop.com
 
This is how I do it.

I don't know if it is the best option, but it works for me.

Code:
Private Sub Form_Resize()
  With <formName>
    .Width = IIf(.Width < <minWidth>, <minWidth>, .Width)
    .Height = IIf(.Height < <minHeight>, <minHeight>, .Height)
  end with
end Sub

Basically what you do is: check the height and width on resize and when one or both of those values become too small, you just replace them with the minimum values you defined.
 
Overdoos,

You seem to have forgotten to take the minimize and maximize states into account.

I would personaly take you code and change it to this:



Code:
Private Sub Form_Resize()
  With <formName>
    If .WindowState = vbNormal Then
      .Width = IIf(.Width < <minWidth>, <minWidth>, .Width)
      .Height = IIf(.Height < <minHeight>, <minHeight>, .Height)
    End If
  end with
end Sub

-Sean
 
Is that about the same as;

If Form1.Width < 9500 Then
Form1.Width = 10000
End If
If Form1.Height < 4500 Then
Form1.Height = 5000
End If


This is what I'm using now,
it seems to flicker too much...

Thanks though ! :)



--------------------------------------
"Hacker by Heart"
saenzcorp@hotpop.com
 
Here's my two cents worth -- Something extracted from one of my projects.
Code:
Private Sub Form_Resize()

    If Width < 8730 Then
        If Me.WindowState <> vbMinimized Then
            Width = 8730
            dgrExpenseRecord.Width = 8415
        End If

    ElseIf Width >= 8730 Then
        dgrExpenseRecord.Width = Width - 315
    End If


    If Height < 7065 Then
        If Me.WindowState <> vbMinimized Then
            Height = 7065
            dgrExpenseRecord.Height = 2835
        End If

    ElseIf Height > 7065 Then
        dgrExpenseRecord.Height = Height - 4230
    End If


End Sub

Cassandra
 
Sean,

You're right. It wasn't a perfect c/p because I ripped it from a function and threw it in the resise-event.

In my code the check happens in the resize event on basis of which a function is called.

--

Maverick,

yes, my solution flickers as well, but i don't mind too much. Since I stop the change of dimentions -on- the minimal values I defined I consider it an extra warning to the user that (s)he is doing something wrong :)
 
Flickering? see thread222-494440

&quot;Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top