-
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!
-
redraw
Is your forms autoredraw set to true?
-
Here's some code which uses swearing. :rolleyes:
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
-
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...
-
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!
-
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
-
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.