Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Status bar and Panel color.....

Posted on 2004-09-16
10
Medium Priority
?
471 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

715 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