Solved

adding icon on a statusbar

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

18 Experts available now in Live!

Get 1:1 Help Now