Delphi Programming

  1. Home
  2. Computing & Technology
  3. Delphi Programming

Extract an icon from an Windows application and paint on a Form

By Zarko Gajic, About.com

This tip shows how to extract the associated icon and draw it into a small area of the form (e.g. Notepad icon)?

~~~~~~~~~~
procedure TForm1.Button1Click(Sender: TObject) ;
var
   IconIndex : word;
   h : hIcon;
begin
  IconIndex := 0;
  h:=ExtractAssociatedIcon
     (hInstance,'C:\WINDOWS\NOTEPAD.EXE', IconIndex) ;
  DrawIcon(Form1.Canvas.Handle, 10, 10, h) ;
end;
~~~~~~~~~~

Delphi tips navigator:
» Detecting Drive Types
« Prevent CTRL+DELETE in DBGrid

Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

Delphi Programming

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 1999 Delphi Tips
  7. Extract an icon from an Windows application and paint on a Form

©2009 About.com, a part of The New York Times Company.

All rights reserved.