Solved

adding icon on a statusbar

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

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

Title # Comments Views Activity
how do i create updater to My Activex application? 3 79
Convert Jpg /PNG To GIF 5 120
Print Graphic and Text to Epson TM-T88v 12 185
how can i search if string exist in array ? 3 50
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
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…

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

19 Experts available now in Live!

Get 1:1 Help Now