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

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

By , About.com Guide

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

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  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.