Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

Resize cancel

I have written some code that when a form gets resized by the user, the controls on it are reorganized.
If the form gets to small that I can't reorganize the controls anymore I want to cancel the resize operation.
Is there anyone who knows how to cancel this operation?
0
ndb
Asked:
ndb
  • 2
1 Solution
 
swiltCommented:
This is a bit flickery, but it works

Private Sub Form_Resize()
   Static nWidth As Long, nHeight As Long
   
    If Me.Width < 3000 Or Me.Height < 3000 Then
        Me.Width = nWidth
        Me.Height = nHeight
    Else
        nWidth = Me.Width
        nHeight = Me.Height
    End If
End Sub
0
 
ndbAuthor Commented:
This doen't work. If I resize the form and come under the size I've sayd then the form stays at that size. 'till here it works but if the user continues resizing the form then he/she gets an error.
0
 
swiltCommented:
I could not reproduce any errors, try the following code.
Which line of code causes the error and what is the error

Private Sub Form_Resize()
    On Error Resume Next
   
    Static nWidth As Long, nHeight As Long
     
    If Me.Width < 3000 Or Me.Height < 3000 Then
        Me.Width = nWidth
        Me.Height = nHeight
    Else
        nWidth = Me.Width
        nHeight = Me.Height
    End If
End Sub

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now