Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Status bar and Panel color.....

Posted on 2004-09-16
10
Medium Priority
?
474 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 200 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Accepted Solution

by:
mladenovicz earned 400 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
 
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 400 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 400 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

927 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