Results 1 to 10 of 10

Thread: Am I just stupid or what....resize doesn't work.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Posts
    25

    Angry

    As far as I can tell, the resize event does NOT fire when you resize a form SMALLER. This is really screwing with the look of my form, because my resizing of some controls is dependant on the firing of the resize event.

    Any ideas?

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    easy enough to test.
    Code:
    Private Sub Form_Resize()
     MsgBox "X"
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Posts
    25

    Angry That's just it....

    I DID test it. Resize only fires when either X or Y INCREASE in value. If X and Y both DECREASE, the resize event does NOT fire.

    What's up with that?

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    test it by grabbing the handle and resizing it to a smaller size. If it fires then it's your code that is faulty.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    I also tested it, and when I make the form smaller, the Resize event still fires.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Posts
    25

    Question It does fire...but my controls still don't resize.....

    I have the following code in my form's resize.....Private


    On Error GoTo FormResizeError

    With Form1.SSSplitter1
    .Top = 1
    .Left = 1
    .Width = Form1.Width - 2
    .Height = Form1.StatusBar1.Top - 2
    End With

    Exit Sub

    FormResizeError:
    MsgBox Err.Description

    ....and the Sheridan Active Splitter will NOT resize when both X and Y decrease in a resizeevent. Why?


  7. #7
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Do you get an error?

  8. #8
    Guest
    dilama,

    1st of all, why don't you use the built in AutoSize-property? should work fine and you don't need to code anything.

    this should work, but you need to set your form's ScaleMode-property to Pixel:

    '**********************************************************

    Private Sub Form_Resize()
    On Error GoTo Err_Form_Resize

    With SSSplitter1
    .Top = 1
    .Left = 1
    .Width = Form1.ScaleWidth - 1
    .Height = Form1.ScaleHeight - (StatusBar1.Height + 1)
    End With

    Exit Sub

    Err_Form_Resize:
    MsgBox Err.Description

    End Sub

    '**********************************************************

    good luck

    Sascha

  9. #9
    Hyperactive Member PJB's Avatar
    Join Date
    Aug 2000
    Location
    dunno at the moment
    Posts
    302
    I got lazy and bought Larkum & Youngs Resize.OCX and put that on all my forms, saves me from having to think about one more thing
    VB6.0 SP4
    Windows 2000
    I'm thinking of a number between

  10. #10
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'this is the ultimate form resizer:
    '
    'this goes in a class module  NOT bas ( A CLASS MODULE)
    '
    Option Explicit
    
    ' Title:    Elastic Forms
    ' Author:   Leigh Bowers
    ' Email:    [email protected]
    ' WWW:      http://www.esheep.freeserve.co.uk/compulsion
    ' Version:  1.01
    ' Date:     19th June 1999
    ' Requires: N/A
    ' License:  Freely Distributable (non-commercial use)
    
    Private fForm As Form
    
    Private lOriginalWidth As Long
    Private lOriginalHeight As Long
    
    Private lMinWidth As Long
    Private lMinHeight As Long
    
    Private Type udtControl
        lLeft As Long
        lTop As Long
        lWidth As Long
        lHeight As Long
    End Type
    Private aControls() As udtControl
    
    Public Property Let Form(ByVal fPassForm As Form)
        
    Dim iCount As Integer
    Dim cControl As Control
    
        Set fForm = fPassForm
        
        ' Store form's original Width & Height
        
        lOriginalWidth = fForm.Width
        lOriginalHeight = fForm.Height
    
        ' Use error trapping to ignore components that don't
        ' support certain properties being read at run-time
    
        On Error Resume Next
    
        ' Store the form's component's properties
    
        iCount = 0
        ReDim aControls(fForm.Controls.Count)
    
        For Each cControl In fForm.Controls
            iCount = iCount + 1
            With aControls(iCount)
                If TypeOf cControl Is Line Then
                    .lLeft = cControl.X1
                    .lTop = cControl.Y1
                    .lWidth = cControl.X2
                    .lHeight = cControl.Y2
                Else
                    .lLeft = cControl.Left
                    .lTop = cControl.Top
                    .lWidth = cControl.Width
                    .lHeight = cControl.Height
                End If
            End With
        Next ' Each
    
    End Property
    
    Public Sub FormResize()
    
        ' v1.01 (19/06/1999)
        '
        ' bDisableResize:
        ' Used to avoid unnecessary *recursive* resizing
        '
        ' lPreviousWidth/Height:
        ' Used to avoid unnecessary resizing
    
        ' Resize the form's controls
    
    Dim iCount As Integer
    Dim cControl As Control
    Dim iTaskBarHeight As Integer
    Dim sOriginalWidthUnit As Single
    Dim sOriginalHeightUnit As Single
    Static bDisableResize As Boolean
    Static lPreviousWidth As Long
    Static lPreviousHeight As Long
    
        If fForm Is Nothing Or bDisableResize Then Exit Sub
    
        ' Don't process minimized forms
        
        If fForm.WindowState = vbMinimized Then Exit Sub
    
        ' Check form size against minimums
        
        bDisableResize = True
        If fForm.Width < lMinWidth Then fForm.Width = lMinWidth
        If fForm.Height < lMinHeight Then fForm.Height = lMinHeight
        bDisableResize = False
        
        ' Ensure form size has changed
        
        If lPreviousWidth = fForm.Width And lPreviousHeight = fForm.Height Then Exit Sub
        lPreviousWidth = fForm.Width
        lPreviousHeight = fForm.Height
    
        ' Perform calculations in advance (speed increase)
    
        iTaskBarHeight = 28 * Screen.TwipsPerPixelY ' Standard height
        sOriginalWidthUnit = lOriginalWidth / fForm.Width
        sOriginalHeightUnit = (lOriginalHeight - iTaskBarHeight) / (fForm.Height - iTaskBarHeight)
    
        ' Use error trapping to ignore components that don't
        ' support certain properties being set at run-time
    
        On Error Resume Next
    
        ' Do the resize...
        
        iCount = 0
    
        For Each cControl In fForm.Controls
            iCount = iCount + 1
            With cControl
                If TypeOf cControl Is Line Then
                    .X1 = Int(aControls(iCount).lLeft / sOriginalWidthUnit)
                    .Y1 = Int(aControls(iCount).lTop / sOriginalHeightUnit)
                    .X2 = Int(aControls(iCount).lWidth / sOriginalWidthUnit)
                    .Y2 = Int(aControls(iCount).lHeight / sOriginalHeightUnit)
                Else
                    .Left = Int(aControls(iCount).lLeft / sOriginalWidthUnit)
                    .Top = Int(aControls(iCount).lTop / sOriginalHeightUnit)
                    .Width = Int(aControls(iCount).lWidth / sOriginalWidthUnit)
                    .Height = Int(aControls(iCount).lHeight / sOriginalHeightUnit)
                End If
            End With
        Next ' Each
    
    End Sub
    
    
    Private Sub Class_Terminate()
    
        Set fForm = Nothing
    
    End Sub
    
    
    
    
    Public Property Let MinWidth(ByVal lPassMinWidth As Long)
    
        lMinWidth = lPassMinWidth
    
    End Property
    Public Property Let MinHeight(ByVal lPassMinHeight As Long)
    
        lMinHeight = lPassMinHeight
    
    End Property
    
    '<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
    'this if your form code for every form in project
    
    Option Explicit
    
    Private clsElastic As clsElasticForms
    
    Private Sub Form_Load()
    
        Set clsElastic = New clsElasticForms
        clsElastic.Form = Me
        clsElastic.MinHeight = 4000
        clsElastic.MinWidth = 4000
    
    End Sub
    
    
    Private Sub Form_Resize()
    
        clsElastic.FormResize
    
    End Sub
    
    
    Private Sub Form_Unload(Cancel As Integer)
    
        Set clsElastic = Nothing
    
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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