Solved

Status bar and Panel color.....

Posted on 2004-09-16
10
461 Views
Last Modified: 2006-11-17
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
Comment
Question by:imarshad
  • 4
  • 4
  • 2
10 Comments
 
LVL 5

Assisted Solution

by:KarcOrigin
KarcOrigin earned 50 total points
ID: 12081700
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
 
LVL 5

Expert Comment

by:KarcOrigin
ID: 12081703
Do not consider the comments!
:-)
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 12082339
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
 
LVL 8

Accepted Solution

by:
mladenovicz earned 100 total points
ID: 12082347
You can insert picture box in panel

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

0
 
LVL 13

Author Comment

by:imarshad
ID: 12082886
>>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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 13

Author Comment

by:imarshad
ID: 12082892
KarcOrigin,

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

Imran Arshad
0
 
LVL 8

Assisted Solution

by:mladenovicz
mladenovicz earned 100 total points
ID: 12082943
pic1.cls
pic1.print "Next Synchronization after " & CountDownTimer
0
 
LVL 13

Author Comment

by:imarshad
ID: 12083238
>>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
 
LVL 8

Assisted Solution

by:mladenovicz
mladenovicz earned 100 total points
ID: 12083280
you should use sthg like this

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

calculate CurrentX and CurrentY according to your needs
0
 
LVL 13

Author Comment

by:imarshad
ID: 12083366
OK thanks all is working fine now.......
also Thanks for your prompt responses

Imran Arshad
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Restricting text box entry from \/:?<>"| 9 76
vb6 connector to mongodb 2 45
Exit a vb6 apps when a calling it apps closes 15 41
fso.FolderExists("\\server\HiddenFolder$") 4 46
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now