Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

adding icon on a statusbar

Posted on 1998-11-16
2
Medium Priority
?
299 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 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
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…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

886 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