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

adding icon on a statusbar

Posted on 1998-11-16
2
292 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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
How to fill array with TArray.Create? 14 93
Controlled Assessment GCSE - desperate help needed 4 98
Delphi problems to abort a printjob 9 24
MS Access from Delphi 31 59
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

789 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