Solved

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

Posted on 2004-08-12
7
708 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

867 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

22 Experts available now in Live!

Get 1:1 Help Now