I. Appel de la boîte de dialogue de changement d'icônes▲
Dans cet exemple nous allons appeler la boîte de dialogue de changement d'icônes. (Celle qui sert à changer les icônes des raccourcis.)
Puis nous afficherons l'icône sélectionnée sur la fiche.
Sur une Form (Form1) poser un bouton (Button1) et 2 Labels (Label1 et Label2).
Sur Unit.h déclaration du Handle d'icône :
Sélectionnez
private: // Déclarations de l'utilisateur
HICON MonIcone;Sur Unit.cpp événement OnClick de Button1 et OnPaint de Form1 :
Sélectionnez
#include <shellapi.h>
//................
void __fastcall TForm1::Button1Click(TObject *Sender)
{
typedef LONG (CALLBACK *SHCHANGEICONDIALOG)(HWND hWnd, LPCSTR szFilename,
LONG Size, int *IconIndex);
SHCHANGEICONDIALOG SHChangeIconDialog = NULL;
char szFilename[MAX_PATH];
int IconIndex;
HANDLE hInst;
hInst=LoadLibrary("SHELL32.DLL");
if(hInst)
{
SHChangeIconDialog=(SHCHANGEICONDIALOG)GetProcAddress(hInst,(LPCSTR)62);
szFilename[0]='\0';
SHChangeIconDialog(Handle,szFilename,sizeof(szFilename),&IconIndex);
Label1->Caption = IconIndex;
Label2->Caption = szFilename;
MonIcone = ExtractIcon(HInstance, szFilename, IconIndex);
Refresh();
}
if(hInst) FreeLibrary(hInst);
}
void __fastcall TForm1::FormPaint(TObject *Sender)
{
DrawIcon(Canvas->Handle, 200, 10, MonIcone);
}

