Results 1 to 7 of 7

Thread: I can't figure it out..

  1. #1
    Guest

    Unhappy

    Hi!

    I have a progressbar IN a statusbar (by some api calls from another thread (tip by Matthew Gates))

    My problem is this: I'm using the Form_resize event to change the progressbar's position accordingly (because it won't do it by itself). Whenever I'm resizing everything is fine, but when Minimizing or Maximizing the StatusBar must be (I think) resizing later because the Progressbar doesn't size also.

    What should I do? Subclassing? Hooking? Swearing?

    Help, please!



  2. #2
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    Question redraw

    Is your forms autoredraw set to true?
    Matt

  3. #3
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Here's some code which uses swearing.
    Code:
    Option Explicit
    
    ' Declares and Consts and Subs from other thread go here
    
    Private Sub Form_Resize()
        Dim nPanel As Long
        Dim tRC As RECT
        
        nPanel = 5 ' 6th panel. (Set it to the panel number, minus one)
        
        Call SendMessageAny(MyStatusBar.hWnd, SB_GETRECT, nPanel, tRC)
        
        With tRC
            .Top = ScaleY(.Top, vbPixels, ScaleMode)
            .Left = ScaleX(.Left, vbPixels, ScaleMode)
            .Bottom = ScaleY(.Bottom, vbPixels, ScaleMode) - .Top
            .Right = ScaleX(.Right, vbPixels, ScaleMode) - .Left
            
            Call MyProgressBar.Move(.Left, .Top, .Right, .Bottom)
        End With
    End Sub

  4. #4
    Guest
    Sorry Yonatan. That doesn't work either....

    My forms autoredraw is TRUE.
    The problem DOESN'T occur if I use the "handle" of the statusbar to size my form, only whem Maximizing/Restoring. I think the StatusBar's resize event (and so the size changes) occur AFTER the form resize is done. So when I put the code in the resize event the Statusbar gets sized to the size of the statusbar before the maximizing is done...

    get it?

    please help...

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    The problem is because the Align property of the status bar is set to 2 - Align Bottom. I've noticed that when you have a control which aligns to one of the form sides the control haven't been resized when the Form_Resize event is raised.
    At least not when you maximize or minimize your form.

    I would suggest setting the align property to 0 - Align None and add code in the resize event to move and resize the Status bar manually.
    Code:
    Private Sub Form_Resize()
        On Error Resume Next
        With StatusBar1
            .Move 0, Me.ScaleHeight - .Height, Me.ScaleWidth
        End With
        'The code for moving the progress bar goes here
    End Sub
    Good luck!

  6. #6
    Guest
    RobIII,

    I've got the sme problem - the resize event fires BEFORE the form actual resizes, so resize code doesn't work when you maximise or minimise. I'm also looking for the answer, so I'll post it when I find it.

    - gaffa

  7. #7
    Guest
    Thanx Joacim !!!

    That worked great... I can't believe it was THAT simple...
    Oh, and I left the align at 2 - vbAlignBottom. That way I get a "handle" in the right-bottom corner. Else not...

    So thanx, VERY much...

    Rob.

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