Solved

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

Posted on 2004-08-12
7
750 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
Simple Delphi Question 9 104
Delphi IDE crash without error message ... 7 113
How to renew a Delphi rad-studio licence? 5 75
Press three keys together and trigger a function 3 67
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

713 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