• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 480
  • Last Modified:

Status bar and Panel color.....

Hi all,
         I need to change the color of a panel of Status bar according to some conditions......I couldnot find a Backcolor property for a Status Bar.......I tried to insert a label control on the Panel so that its backcolor can be changed.....But the Label is shown always behind the Status Bar which is undesirable for me........

Can someone suggest a free Status Bar that has this property of letting to change the color of individual Panel?
or some workaround this ? Using a picture box over the Control Panel is one option but I couldnot draw it on the Status bar perfectly so that text is aligned and the user doesnot know that a Picture Box is drawn on the Status bar.........

Imran Arshad

0
imarshad
Asked:
imarshad
  • 4
  • 4
  • 2
4 Solutions
 
KarcOriginCommented:
Try something like this since there is no property to change the back color of the Status Bar:

Public Sub DrawProgressBar(ObjTarget As Object, ByVal sngP As Single, ByVal lngColor As Long)
    Dim w As Long
    Dim h As Long
    Dim pic As PictureBox
    On Error GoTo ErrorProc
    Set pic = ObjTarget                                         'Picture Box以外はエラーとなる
    pic.Cls
    w = ObjTarget.Width                                         'PictureBox幅
    h = ObjTarget.Height                        '
    If sngP > 0 Then
        ObjTarget.Line (0, 0)-(w * (sngP / 100), h), lngColor, BF
        DoEvents
    End If
ErrorProc:
End Sub

And call it like this -

Private Sub Command6_Click()
    Dim i As Integer
    Dim LowerLimit As Integer
    Dim UpperLimit As Integer
    LowerLimit = 0
    UpperLimit = 100
    For i = LowerLimit To UpperLimit
        Call DrawProgressBar(Picture1, i, vbRed)
    Next
End Sub

I hope it will help you.
Thanks
0
 
KarcOriginCommented:
Do not consider the comments!
:-)
0
 
mladenoviczCommented:
This will set forecolor for the status bar

'to module
Option Explicit

Private Const WM_USER = &H400
Private Const CCM_FIRST       As Long = &H2000&
Private Const CCM_SETBKCOLOR  As Long = (CCM_FIRST + 1)

'set progressbar backcolor in IE3 or later
Private Const PBM_SETBKCOLOR  As Long = CCM_SETBKCOLOR

Private Declare Function SendMessage Lib "user32" _
   Alias "SendMessageA" _
  (ByVal hwnd As Long, _
   ByVal wMsg As Long, _
   ByVal wParam As Long, _
   lParam As Any) As Long


Public Sub SetPBackColor(ByVal hwnd As Long, Optional ByVal color As Long = vbWhite)
    Call SendMessage(hwnd, PBM_SETBKCOLOR, 0&, ByVal color)
End Sub


'form
Private Sub Command1_Click()
    SetPBackColor StatusBar1.hwnd, vbRed
End Sub
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
mladenoviczCommented:
You can insert picture box in panel

http://www.vbsight.com/Zips/PBinSB.zip

0
 
imarshadAuthor Commented:
>>This will set forecolor for the status bar

Yes it does but not for individual Panels? Lets say I want color of Panel1 to be green for some condition and Red for some other?

>>You can insert picture box in panel

Yes this is what I am doing.......But one problem that I am facing is that I am displaying a countdown timer on the StatusBar.........When I use a picture box and call the following code in  a loop of 1 sec.
pic1.print "Next Synchronization after " & CountDownTimer

the next messge is displayed in a new line on the picture box......While I need the next message to be exactly at the same place where the first is present..... i.e

on the Picture Box it is displaying

Next Synchronization after 00:00:10
Next Synchronization after 00:00:09
Next Synchronization after 00:00:08

while I need the next message to be displayed on the same line so that it overwrites the previous message

Imran Arshad

0
 
imarshadAuthor Commented:
KarcOrigin,

Same problem with your code...... i.e I cant write text properly......

Imran Arshad
0
 
mladenoviczCommented:
pic1.cls
pic1.print "Next Synchronization after " & CountDownTimer
0
 
imarshadAuthor Commented:
>>pic1.cls

Thanks....It is working now....Only one small point left......How to align the text of Picture Box to that of Status bar.... i.e I am using picture Box in only one panel and all the other panels are the default panels......But the text for both of them is not aligned ..... How to achieve this......?
0
 
mladenoviczCommented:
you should use sthg like this

Picture1.CurrentX = 100
Picture1.CurrentY = 100
Picture1.Print "aha"

calculate CurrentX and CurrentY according to your needs
0
 
imarshadAuthor Commented:
OK thanks all is working fine now.......
also Thanks for your prompt responses

Imran Arshad
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now