Results 1 to 5 of 5

Thread: StatusBar & ProgressBar

  1. #1
    Guest

    Unhappy

    Hi!

    I have a progressbar on my form, and have put it in a statusbar's panel of my form with this code:

    Code:
        ShowProgressInStatusBar StatusBar, MainProgressBar, 2
    Wich in turn calls this sub:

    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 Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type
    
    Private Const WM_USER As Long = &H400
    Private Const SB_GETRECT As Long = (WM_USER + 10)
    
    Public Sub ShowProgressInStatusBar(StatBar As StatusBar, ProgrBar As ProgressBar, Panl As Integer)
    
        Dim tRC As RECT
    
        SendMessageAny StatBar.hwnd, SB_GETRECT, Panl - 1, tRC
        With tRC
            .Top = (.Top * Screen.TwipsPerPixelY)
            .Left = (.Left * Screen.TwipsPerPixelX)
            .Bottom = (.Bottom * Screen.TwipsPerPixelY) - .Top
            .Right = (.Right * Screen.TwipsPerPixelX) - .Left
        End With
        ' Re-parent the ProgressBar to the statusbar
        With ProgrBar
            SetParent .hwnd, StatBar.hwnd
            .Move tRC.Left, tRC.Top, tRC.Right, tRC.Bottom
            .Visible = True
            .Value = 0
        End With
    End Sub
    In my form_resize I use this code:

    Code:
    MainProgressBar.Left = StatusBar.Panels(2).Left
    Problem is when I maximize my form, the progressbar doesn't change it's position (size doesn't have to). I think it's because the Statusbar gets it's resize event AFTER the form_resize has finished.

    Anyone got any clue on how to solve it? I'd like not to have to use some timer or so... Maybe subclassing? Please help? How do I know when the Statusbar has finished sizing?

  2. #2
    Guest
    I was thinking: "Could I use something like WithEvents"???
    Please help...


    (I won't deny this msg is also for moving to the Top )

  3. #3
    Guest

    Angry

    Please help!

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Check out This Post which has an example of using this function.

  5. #5
    Guest
    Thanx Serge for the help, but that wasn't a solution. The problem is only occuring when I Maximize or Restore my window. Any more ideas?

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