Resize problems with Progressbar in Statusbar.

  • 18 years ago

    Hello,


    I'm trying to display a progressbar inside a statusbar.


    The problem I have is that when the form is resized the position of the progressbar is not always OK. The prolem is that when one of the panels in front of the statusbar is set to autosize that this happens after the MDIForm_Resize event.  Because of this the progressbar is positioned where it should have been one Resize event before.


    I do not want to use a timer to keep on repositioning the progressbar. I want it event driven.


    Here is the Code that I used to reposition the progressbar:

    Code:

    Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    Private Declare Function SendMessageAny Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, lParam As Any) As Long



    Private Sub MDIFormResize()
    Dim rc As RECT
     StatusBar1.Refresh  ' This does not help
     DoEvents
     SendMessageAny StatusBar1.hwnd, SB
    GETRECT, 2, rc
     With rc
         .Top = .Top * Screen.TwipsPerPixelY
         .Left = .Left * Screen.TwipsPerPixelX
         .Bottom = .Bottom * Screen.TwipsPerPixelY - .Top
         .Right = .Right * Screen.TwipsPerPixelX - .Left
     End With
     With PBar
         SetParent .hwnd, StatusBar1.hwnd
         .Move rc.Left, rc.Top, rc.Right, rc.Bottom
         .Value = 0.0001
     End With
    End Sub



    Any help is whelcome

  • 18 years ago

    Hey,


    I've never used Status Bar... I tried mucking around with it but I don't have time to read up on it.


    Anyways, to bind the progress bar to a location, couldn't you set the anchoring to "Left, Bottom, Right"?  I tried this out, and the pgb stuck to the bottom, and grew/shrunk according to me resizing the window.


    this is for .NET, which I've kinda assumed you were using.


    Happy Panda

  • 18 years ago

    Sorry, I use VB6 and not .net. There are no anchors available in VB6.
    Normaly in VB6 you do it yourselves in the form resize event.
    But in this case it does not work.

  • 18 years ago

    coult the pgb be resized according to the params of the status bar?


    ie withing MDIForm_Resize:
    pgb.left = statusbar.left + X
    pgb.width = statusbar.width - Y


    So rather then relying on the size of the panel, you could rely on the size of the status bar.


    Also, if one panel is set to autosize does this mean all the others are fixed?  I don't have experience with sb, but if this is the case, then you can get all the information by just using the values from all the other panels.


    Hopefully some of this rambling will inspire you...


    Happy

  • 18 years ago

    Thanks HappyPanda, that was a good tip.


    It did not solve my problem but I could found out what the problem was.
    It is the ActiveBar control from datadynamics that is causing this behavior.
    Because of ActiveBar the form resize event was called before it was actually resized.
    So all the size parameters returned the values of the previous resize event


  • 18 years ago

    hey edwin,


    if your using Activebar you can insert the progress bar as a ActiveX Control and let the control(AB) handle the resizeing for you if your using their own Statusbar contorl....

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Every language has an optimization operator. In C++ that operator is ‘//’”