Solved

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

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

15 Experts available now in Live!

Get 1:1 Help Now