Solved

adding icon on a statusbar

Posted on 1998-11-16
2
290 Views
Last Modified: 2010-04-04
How can I add  an icon on statusbar like in netscape ?

thanks in advance...
0
Comment
Question by:guvencum
2 Comments
 
LVL 4

Accepted Solution

by:
BoRiS earned 100 total points
ID: 1347093
guvencum

here is code that addes the system icons to a status bar like explorer calc etc just modify as needed...

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ComCtrls, ExtCtrls, StdCtrls, Buttons;

type
  TForm1 = class(TForm)
    StatusBar1: TStatusBar;
    procedure FormCreate(Sender: TObject);
  private
    procedure StatusIconClick(Sender: TObject);
    procedure DisplayIconImages(ImageList: TImageList; ExeNameList: TStringList;
      WinControl: TWinControl);
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses ShellAPI, CommCtrl;

procedure TForm1.StatusIconClick(Sender: TObject);
begin
  WinExec(PChar((Sender as TImage).Hint), SW_ShowNormal);
end;

procedure TForm1.DisplayIconImages(ImageList: TImageList; ExeNameList: TStringList;
  WinControl: TWinControl);
var
  IconLeft: integer;
  i: integer;
begin
  IconLeft := ImageList.Width div 2;
  for i := 0 to ImageList.Count - 1 do
    with TImage.Create(Self) do
    begin
      Parent := WinControl;
      Hint := ExeNameList.Strings[i];
      ShowHint := True;
      OnClick := StatusIconClick;
      Top := (WinControl.Height - ImageList.Height) div 2;
      Left := IconLeft;
      Width := ImageList.Width;
      Height := ImageList.Height;
      IconLeft := IconLeft + Width + 5;
      Canvas.Brush.color := StatusBar1.Brush.Color;
      Canvas.FillRect(Canvas.ClipRect);
      ImageList.Draw(Canvas, 0, 0, i);
    end;
end;

procedure TForm1.FormCreate(Sender: TObject);
const
  ExeList: array[0..9] of String = (
    'CALC.EXE',
    'CLIPBRD.EXE',
    'NOTEPAD.EXE',
    'REGEDIT.EXE',
    'PBRUSH.EXE',
    'SYSMON.EXE',
    'DEFRAG.EXE',
    'EXPLORER.EXE',
    'TELNET.EXE',
    'TERMINAL.EXE'
  );
var
  StringList: TStringList;
  ImageList: TImageList;
  i: integer;
begin
  StringList := TStringList.Create;
  ImageList := TImageList.Create(Self);
  try
    for i := 0 to 9 do
    begin
      Imagelist_AddIcon(ImageList.Handle, ExtractIcon(Handle, PChar(ExeList[i]), 0));
      StringList.Add(ExeList[i]);
    end;
    DisplayIconImages(ImageList, StringList, StatusBar1);
  finally
    StringList.Free;
    ImageList.Free;
  end;
end;

Later
BoRiS
0
 

Author Comment

by:guvencum
ID: 1347094
Adjusted points to 100
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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…

813 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

11 Experts available now in Live!

Get 1:1 Help Now