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

x
?
Solved

Icon, Image from Image List into Status bar..how..?

Posted on 2004-08-12
7
Medium Priority
?
837 Views
Last Modified: 2010-04-04
how can i insert image into statusbar...is to check if i have connection to lan then show sepecific image or when is offline another image into status bar...(or i can use another component?)

thanks.
0
Comment
Question by:ThoseBug
[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
  • 2
7 Comments
 
LVL 4

Accepted Solution

by:
LMuadDIb earned 160 total points
ID: 11786327
here you go:

Add a statusbar and an imagelist to a form. Add an image to the imagelist (16X16)
Create an event for the statusbar "OnPanelDraw" and add the following code to it:

procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;  Panel: TStatusPanel; const Rect: TRect);
var
 imgIndex, imgWidth, offset : integer;
begin
 imgIndex := 0;    {Imagelist Item}
 imgWidth := 36;   {used to space the image and any text}
 offset   := 3;    {how close to the panel edge}

 with StatusBar1.Canvas do
 begin
   {Display Image in statusbar}
   FillRect(Rect);
   ImageList1.Draw(StatusBar1.Canvas, Rect.Left + offset, Rect.Top, imgIndex);

   {If you want to display some text use the following code}
   Font.Color := clRed;
   TextOut(Rect.Left + imgwidth + offset, Rect.Top, 'Some Text Here');
 end;
end;

-----------------------

most 3rd party statusbars allow images and other objects to be displayed.
I would check out http://www.torry.net/pages.php?id=17 for some free and some not so free :)
0
 
LVL 3

Author Comment

by:ThoseBug
ID: 11786983
may be i miss something but my status bar is not doing the event draw panel..why...?
0
 
LVL 4

Expert Comment

by:LMuadDIb
ID: 11789411
Sorry I forgot to mention this, you must change the statusbar panel property "Stlye" from "psText" to "psOwnerDraw".
Change that only in the panel you want the image to be in.
0
 

Assisted Solution

by:krypto2000
krypto2000 earned 160 total points
ID: 11819114
ok... i think there is a better way...

Add an imageList, a statuBar, a panel to the statusBar and set the property "style" to "psOwnerDraw"

here is the code for the onDrawPanel event :
===================================================
procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
  Panel: TStatusPanel; const Rect: TRect);
var tmpBmp: TBitmap; myRect: TRect;
begin
   tmpBmp := TBitmap.Create;

// specifiy the index of the picture you need in the imageList
   imageList1.GetBitmap(0,tmpBmp);    

// Create destination rect
   myRect := classes.Rect(Rect.Left+2,Rect.Top+2,Rect.Right+2,Rect.Bottom+2);

// Paint the icon to the panel
   StatusBar1.canvas.BrushCopy(myRect,tmpBmp,Rect,clWhite);

   tmpBmp.Destroy;
end;
===================================================
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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
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