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
Solved

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

Posted on 2004-08-12
7
737 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
  • 2
7 Comments
 
LVL 4

Accepted Solution

by:
LMuadDIb earned 40 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 40 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

839 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