Results 1 to 12 of 12

Thread: Status Bar

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    11

    Red face

    Hi there

    Is it possible to have a progressbar on the status bar e.g Internet Explorer.

    Thanks in advance ;p

    Mark
    Could a single cell organism spell its name correctly!!

  2. #2
    Guest
    Try this:

    Code:
    'Author: Chris Eastwood
    'Author's email: [email protected]
    'Date Submitted: 2/22/1999
    'Compatibility: VB 5
    
    'Task: How to place a Progress Bar in A Status Bar Panel (VB5) - should
    work with VB4(32 bit) and VB6.
    
    
    'Declarations
    '
    ' Module Declares for the StatProgressBar example
    '
    ' Chris Eastwood Feb. 1999
    '
    ' http://www.codeguru.com/vb
    '
    
    '
    ' API Declarations
    '
    Public Declare Function SetParent Lib "user32" (ByVal hWndChild As Long,
    ByVal hWndNewParent As Long) As Long
    Public Declare Function SendMessageAny Lib "user32" Alias "SendMessageA"
    (ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, lParam As
    Any) As Long
    
    '
    ' API Types
    '
    ' RECT is used to get the size of the panel we're inserting into
    '
    Public Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type
    
    '
    ' API Messages
    '
    Public Const WM_USER As Long = &H400
    Public Const SB_GETRECT As Long = (WM_USER + 10)
    
    
    'Code:
    Private Sub ShowProgressInStatusBar(ByVal bShowProgressBar As Boolean)
    
        Dim tRC As RECT
    
        If bShowProgressBar Then
    '
    ' Get the size of the Panel (2) Rectangle from the status bar
    ' remember that Indexes in the API are always 0 based (well,
    ' nearly always) - therefore Panel(2) = Panel(1) to the api
    '
    '
            SendMessageAny StatusBar1.hwnd, SB_GETRECT, 1, tRC
    '
    ' and convert it to twips....
    '
            With tRC
                .Top = (.Top * Screen.TwipsPerPixelY)
                .Left = (.Left * Screen.TwipsPerPixelX)
                .Bottom = (.Bottom * Screen.TwipsPerPixelY) - .Top
                .Right = (.Right * Screen.TwipsPerPixelX) - .Left
            End With
    '
    ' Now 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
    
        Else
    '
    ' Reparent the progress bar back to the form and hide it
    '
            SetParent ProgressBar1.hwnd, Me.hwnd
            ProgressBar1.Visible = False
        End If
    
    End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    11

    Thumbs up Thanks

    I believe God just spoke to me!!

    Thanks
    Could a single cell organism spell its name correctly!!

  4. #4
    Hyperactive Member davem's Avatar
    Join Date
    Dec 2000
    Location
    Gainesville, FL
    Posts
    265
    I found an API that would "paint" the Menu bar... can I transform this to paint the entire stausbar also?

    Here's the menu color code:
    VB Code:
    1. '******************************************************************************
    2. 'Required API call declarations
    3. '******************************************************************************
    4.  
    5. 'CreateBrushIndirect is used to create the background brush for the menus
    6. Private Declare Function CreateBrushIndirect Lib "gdi32" (lpLogBrush As LOGBRUSH) As Long
    7. 'GetMenu is used to get the handle to the menus
    8. Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
    9. 'GetMenuInfo is used to get the current info for the menu (so we don't change anything we shouldn't by mistake)
    10. Private Declare Function GetMenuInfo Lib "user32" (ByVal hMenu As Long, lpcmi As tagMENUINFO) As Long
    11. 'SetMenuInfo is used to set the background brush back to the menu and all sub-menus
    12. Private Declare Function SetMenuInfo Lib "user32" (ByVal hMenu As Long, lpcmi As tagMENUINFO) As Long
    13.  
    14. '******************************************************************************
    15. 'Required API Type Definitions
    16. '******************************************************************************
    17.  
    18. 'Used in the Calls to CreateBrushIndirect
    19. Private Type LOGBRUSH
    20.     lbStyle As Long     'Style type (we only need to create a solid background for this example)
    21.     lbColor As Long     'Set the color of the brush
    22.     lbHatch As Long     'Hatch style (not used in this example because it's ignored for Solid style)
    23. End Type
    24.  
    25. 'Used in GetMenuInfo and SetMenuInfo calls
    26. Private Type tagMENUINFO
    27.     cbSize As Long              'The size of the type structure (use len to calculate)
    28.     fMask As Long               'Mask of information/Actions to process
    29.     dwStyle As Long             'Menu Style (not used in this example)
    30.     cyMax As Long               'Maximum height of menu in pixels (not used in this example)
    31.     hbrBack As Long             'Handle to background brush
    32.     dwContextHelpID As Long     'Help Context ID (not used in this example)
    33.     dwMenuData As Long          'Menu Data (again not used in this example)
    34. End Type
    35.  
    36. '******************************************************************************
    37. 'API Constant declarations
    38. '******************************************************************************
    39.  
    40. Private Const BS_SOLID = 0      'Solid style for brush
    41. Private Const MIM_APPLYTOSUBMENUS = &H80000000  'Apply to Sub-Menus Mask
    42. Private Const MIM_BACKGROUND = &H2              'Background Mask
    43.  
    44. Public Sub PaintTheMenu()
    45.     Dim ret As Long                 'Variable to hold return values from GetMenuInfo and SetMenuInfo
    46.     Dim hMenu As Long               'Variable to hold the handle to the menu
    47.     Dim hBrush As Long              'Variable to hold the handle to the background brush we are going to create
    48.     Dim lbBrushInfo As LOGBRUSH     'Variable to hold the information to pass to the CreateBrushIndirect API
    49.     Dim miMenuInfo As tagMENUINFO   'Variable to hold the menu info
    50.  
    51.     lbBrushInfo.lbStyle = BS_SOLID  'Set our brush type to solid
    52.     lbBrushInfo.lbColor = vbRed     'Here we set our brush color
    53.     lbBrushInfo.lbHatch = 0         'This value is ignored I set it to 0 to make sure nothing weird will happen
    54.     hBrush = CreateBrushIndirect(lbBrushInfo)   'We create our brush
    55.     hMenu = GetMenu(main.hwnd)                  'Get the handle to the menu that we are modifying (note we pass the form's hWnd because it is the owner of the menu)
    56.     miMenuInfo.cbSize = Len(miMenuInfo)         'Set the MenuInfo structure size so that we don't get errors
    57.     ret = GetMenuInfo(hMenu, miMenuInfo)        'Go and get the actual menu info should return non-zero if successful
    58.     miMenuInfo.fMask = MIM_APPLYTOSUBMENUS Or MIM_BACKGROUND    'Set the mask for the changes (changing the background for menu and all sub-menus)
    59.     miMenuInfo.hbrBack = hBrush                 'Assign our brush to the menu info
    60.     ret = SetMenuInfo(hMenu, miMenuInfo)        'Write our info back to the menu and we're done. (should return non-zero if successful)
    61. End Sub

  5. #5
    Hyperactive Member davem's Avatar
    Join Date
    Dec 2000
    Location
    Gainesville, FL
    Posts
    265
    Also... will this code work safely on Me, 2000 and XP?

  6. #6
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    davem -

    How would you use this code? Do you just call PaintTheMenu in the Form Load Event?

  7. #7
    Hyperactive Member davem's Avatar
    Join Date
    Dec 2000
    Location
    Gainesville, FL
    Posts
    265
    Yeah bloodeye.

    THere is a problem though... if you have hidden menu's (for popups) then those don't get painted... anyone, ideas?

  8. #8
    PowerPoster eiSecure's Avatar
    Join Date
    Jul 2000
    Location
    Texas
    Posts
    2,209
    Try setting the menus visible at startup, call the PaintMenu code, and then set their visible property to false again.

    Maybe that'll work.

  9. #9
    Hyperactive Member davem's Avatar
    Join Date
    Dec 2000
    Location
    Gainesville, FL
    Posts
    265
    Tried that... apparently when you set them back to visible = false they loose their color. I'm gonna see what I can come up with but I'm not strong in API.

    Any idea on the painting the statusbar ei?

  10. #10
    PowerPoster eiSecure's Avatar
    Join Date
    Jul 2000
    Location
    Texas
    Posts
    2,209
    Well, there's lots of 3rd party controls that can do that.

    Or, you can just have 1 picture box, and another picturebox inside the first one that acts like a progress bar.

  11. #11
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    I remember seeing some code at PSC for changing the backcolor and forecolor of a statusbar....

  12. #12
    Hyperactive Member davem's Avatar
    Join Date
    Dec 2000
    Location
    Gainesville, FL
    Posts
    265
    No... I don't need the progress bar... my question is even simpler. I just need to make the statusbar (the entire thing - not just specific panels) another color.

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