Solved

Status bar and Panel color.....

Posted on 2004-09-16
10
460 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
Comment Utility
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
Comment Utility
Do not consider the comments!
:-)
0
 
LVL 8

Expert Comment

by:mladenovicz
Comment Utility
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
Comment Utility
You can insert picture box in panel

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

0
 
LVL 13

Author Comment

by:imarshad
Comment Utility
>>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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 13

Author Comment

by:imarshad
Comment Utility
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
Comment Utility
pic1.cls
pic1.print "Next Synchronization after " & CountDownTimer
0
 
LVL 13

Author Comment

by:imarshad
Comment Utility
>>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
Comment Utility
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
Comment Utility
OK thanks all is working fine now.......
also Thanks for your prompt responses

Imran Arshad
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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 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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

772 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

12 Experts available now in Live!

Get 1:1 Help Now