Results 1 to 5 of 5

Thread: Serge, or anyone else that knows

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    http://www.vb-world.net/ubb/Forum1/HTML/011402.html

    I don't get the sngBorderWidth part....


    [This message has been edited by Inhumanoid (edited 12-06-1999).]

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    This variable is calculating the thinkness of the border. So when you place the Progress bar on the Status bar it will actually will be inside of the Status bar and not just on it. If you remove that variable, you will see what I mean. This VB way is short but not actually the right way, because it makes you think that Progress bar is a child for a Status bar, where actually it is NOT. If you want to use the right way, use API:

    Code:
    Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    Private Declare Function SendMessage 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 ShowProgressInStatus(pProgress As ProgressBar, pStatus As StatusBar, pPanelIndex As Integer)
        Dim tRC As RECT
        
        'Get the size of the given panel
        SendMessage StatusBar1.hwnd, SB_GETRECT, pPanelIndex - 1, tRC
        'Convert to Twips
        With tRC
            .Top = (.Top * Screen.TwipsPerPixelY)
            .Left = (.Left * Screen.TwipsPerPixelX)
            .Bottom = (.Bottom * Screen.TwipsPerPixelY) - .Top
            .Right = (.Right * Screen.TwipsPerPixelX) - .Left
        End With
        'Reparent the ProgressBar to the statusbar
        With ProgressBar1
            SetParent .hwnd, StatusBar1.hwnd
            .Move tRC.Left, tRC.Top, tRC.Right, tRC.Bottom
            .Visible = True
            .Value = 0
        End With
    End Sub
    Usage: ShowProgressInStatus ProgressBar, StatusBar, PanelIndex
    Example: ShowProgressInStatus Progress1, Status1, 1

    This will pu the Progress bar in the first panel (Panel index is 1 based)

    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819



    [This message has been edited by Serge (edited 12-06-1999).]

  3. #3
    New Member
    Join Date
    Nov 1999
    Posts
    13

    Post

    I put a progress bar into the second panel of my statusbar the way Serge described it. I set the bevel of the panel to sbrInset but when the progress bar is displayed, the inset-frame just disappears. How can I prevent it from doing this?

    Thanx in advance, Marc D. Migge

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Thats ok, we can tweak it a little.
    Code:
    Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    Private Declare Function SendMessage 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 ShowProgressInStatus(pProgress As ProgressBar, pStatus As StatusBar, pPanelIndex As Integer)
        Dim tRC As RECT
        
        pProgress.Appearance = ccFlat
        'Get the size of the given panel
        SendMessage StatusBar1.hwnd, SB_GETRECT, pPanelIndex - 1, tRC
        'Convert to Twips
        With tRC
            .Top = (.Top * Screen.TwipsPerPixelY) + 20
            .Left = (.Left * Screen.TwipsPerPixelX) + 20
            .Bottom = (.Bottom * Screen.TwipsPerPixelY) - .Top
            .Right = (.Right * Screen.TwipsPerPixelX) - .Left - 20
        End With
        'Reparent the ProgressBar to the statusbar
        With ProgressBar1
            SetParent .hwnd, StatusBar1.hwnd
            .Move tRC.Left, tRC.Top, tRC.Right, tRC.Bottom
            .Visible = True
            .Value = 0
        End With
    End Sub
    ShowProgressInStatus Progress1, Status1, 1

    Now you it will look like its actually inside of the status bar.

    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


  5. #5
    New Member
    Join Date
    Nov 1999
    Posts
    13

    Post

    Thanx, Serge. I tried:

    .Top = (.Top+1 * Screen.TwipsPerPixelY)
    .Left = (.Left+1 * Screen.TwipsPerPixelX)
    .Bottom = (.Bottom-1 * Screen.TwipsPerPixelY)
    .Right = (.Right-1 * Screen.TwipsPerPixelX)

    before and I got an error. But now I realize my mistake:

    .Top = ((.Top+1) * Screen.TwipsPerPixelY)
    .Left = (.Left+1) * Screen.TwipsPerPixelX)
    .Bottom = ((.Bottom-1)*Screen.TwipsPerPixelY)
    .Right = ((.Right-1) * Screen.TwipsPerPixelX)

    should work as well...

    Thanx again, Marc D. Migge

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