title: How to load a TImage using task dialog common icons?
body: <p>I'm trying to load icons used by Delphi's task dialogs into a <code>TImage</code> control.
  As I've learned <a href="https://stackoverflow.com/a/36764762/4528159">here</a>, I'm using <a href="https://docs.microsoft.com/it-it/windows/desktop/api/winuser/nf-winuser-loadimagea" rel="nofollow noreferrer"><code>LoadImage</code></a> function but icons appear lightly different from the ones which are used by the <a href="http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/Dialogs_MessageDlg@string@TMsgDlgType@TMsgDlgButtons@Longint.html" rel="nofollow noreferrer"><code>MessageDlg</code></a> function.</p>
  
  <p><a href="https://i.stack.imgur.com/3wpye.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3wpye.png" alt="example form"></a></p>
  
  <pre><code>unit Unit1;
  
  interface
  
  uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls, ExtCtrls;
  
  type
    TForm1 = class(TForm)
      Button1: TButton;
      Image1: TImage;
      procedure Button1Click(Sender: TObject);
    private
      { Private declarations }
    public
      { Public declarations }
    end;
  
  var
    Form1: TForm1;
  
  implementation
  
  {$R *.dfm}
  
  procedure TForm1.Button1Click(Sender: TObject);
  begin
    Image1.Picture.Icon.Handle := LoadImage( 0, IDI_WARNING, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE or LR_SHARED );
    MessageDlg('mtWarning', mtWarning, [mbOk], 0);
  
    Image1.Picture.Icon.Handle := LoadImage( 0, IDI_ERROR, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE or LR_SHARED );
    MessageDlg('mtError', mtError, [mbOk], 0);
  
    Image1.Picture.Icon.Handle := LoadImage( 0, IDI_INFORMATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE or LR_SHARED );
    MessageDlg('mtInformation', mtInformation, [mbOk], 0);
  
    Image1.Picture.Icon.Handle := LoadImage( 0, IDI_QUESTION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE or LR_SHARED );
    MessageDlg('mtConfirmation', mtConfirmation, [mbOk], 0);
  end;
  
  end.
  </code></pre>
  
  <p>As you can see, the icons in the <code>TImage</code> are different from the corresponding icon used by the <code>MessageDlg</code> function.</p>
  
  <p><a href="https://i.stack.imgur.com/o8wTo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o8wTo.png" alt="mtWarning dialog"></a>
  <a href="https://i.stack.imgur.com/nwcYN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nwcYN.png" alt="mtError dialog"></a>
  <a href="https://i.stack.imgur.com/Sa9mT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Sa9mT.png" alt="mtInformation dialog"></a>
  <a href="https://i.stack.imgur.com/Nt1iR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Nt1iR.png" alt="mtConfirmation dialog"></a></p>
  
  <p><strong>Further tests:</strong></p>
  
  <ol>
  <li><p>I found out that <code>MessageDlg</code> function uses the same icons obtained by <code>LoadImage</code> when the <em>Enable runtime themes</em> flag is deactivated (in the <em>Project Options</em>).</p></li>
  <li><p>The <code>MessageDlg</code> function seems to use some constants defined in <code>CommCtrl</code> unit:   </p></li>
  </ol>
  
  <blockquote>
    <p>{ Task Dialog Common Icons }</p>
    
    <p>{$EXTERNALSYM TD_WARNING_ICON}<br>
    TD_WARNING_ICON         = MAKEINTRESOURCEW(Word(-1));<br>
    {$EXTERNALSYM TD_ERROR_ICON}<br>
    TD_ERROR_ICON           = MAKEINTRESOURCEW(Word(-2));<br>
    {$EXTERNALSYM TD_INFORMATION_ICON}   TD_INFORMATION_ICON     = MAKEINTRESOURCEW(Word(-3));<br>
    {$EXTERNALSYM TD_SHIELD_ICON}<br>
    TD_SHIELD_ICON          = MAKEINTRESOURCEW(Word(-4));</p>
  </blockquote>
  
  <p>How can I get the same icons used by the task dialogs?</p>