Results 1 to 7 of 7

Thread: Restrict Form Resizing

  1. #1

    Thread Starter
    PowerPoster eiSecure's Avatar
    Join Date
    Jul 2000
    Location
    Texas
    Posts
    2,209

    Restrict Form Resizing

    Does anyone know how to not let the user make the form smaller than a certain size?

    I don't really want to use:
    VB Code:
    1. If Me.Width <= 5115 Then
    2.         Me.Width = 5115
    3.     End If
    since it flickers when the size is smaller than the one specified.

    Any solutions and/or other ways of doing this?

  2. #2
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    Try using the API

    if u use ShowWindow then you can holt the resize in much the same effect.

    I'm not to sure of the code now, but I'll post it later, but I know it uses this function.
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  3. #3
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530

  4. #4
    Lively Member
    Join Date
    Apr 2001
    Posts
    66
    I am trying to do the same thing also but I subclassed my form and looked for the WM_SIZING msg

    Dim r As RECT
    Select Case msg
    Case WM_SIZING
    CopyMemory r, lParam, Len(r)
    If (r.Bottom - r.Top) > 441 Or (r.Right - r.Left) > 672 Then
    WndProc = CallWindowProc(MainSubclassRet, hwnd, msg, wParam, lParam)
    Else
    WndProc = 0
    End If
    Case Else
    WndProc = CallWindowProc(MainSubclassRet, hwnd, msg, wParam, lParam)
    End Select

    The only problem w/ this is that it doesn't stop it once the dimensions are what it is supposed to be at. if you could figure this one out and reply that'd be great

  5. #5

    Thread Starter
    PowerPoster eiSecure's Avatar
    Join Date
    Jul 2000
    Location
    Texas
    Posts
    2,209
    Nucleus, that works okay, but the subclassing crashes very often.

  6. #6
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    Don't press the stop button while subclassing else it will crash, unload the form instead.

  7. #7
    Matthew Gates
    Guest
    Try this:


    VB Code:
    1. Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
    2.  
    3. Dim LockWindow As Boolean
    4. Dim iWidth As Integer
    5.  
    6.  
    7. Private Sub Form_Load()
    8.     iWidth = Me.Width '5115
    9. End Sub
    10.  
    11. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    12.     LockWindowUpdate 0&
    13. End Sub
    14.  
    15. Private Sub Form_Resize()
    16.     On Error Resume Next
    17.     Static FirstLoad
    18.  
    19.     If FirstLoad = False Then
    20.         FirstLoad = True
    21.         LockWindow = True
    22.         Exit Sub
    23.     End If
    24.    
    25.     If Me.Width <= iWidth Then
    26.         If LockWindow = True Then
    27.             Me.Width = iWidth
    28.             LockWindowUpdate Me.hWnd
    29.         End If
    30.     End If
    31.    
    32. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width