Bonsoir à tous,
J'ai un problème depuis un moment :
Je voudrais qu'à l'execution d'un OpenDialog l'icone du fichier (.exe) récupéré soit mise dans le Form1.BitBtn1.Glyph, j'ai ce code et après moultes et moultes essais j'abandonne et je post
Uses et Variables :
Fonction :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 Uses [...], Unit1; var h : string;
Procédure :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 function TForm1.GetIconHandle(const P_FileName : string; const P_Modifier : integer): HIcon; var Sfi: TSHFileInfo; begin SHGetFileInfo(PChar(P_FileName), 0, Sfi, SizeOf(TSHFileInfo), SHGFI_SYSICONINDEX or SHGFI_ICON or P_Modifier); Result := Sfi.hIcon; end;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 procedure TForm2.Btn1Click(Sender: TObject); begin if OpenDialog1.execute then h:=(opendialog1.Filename); bitbtn1.glyph.handle := GetIconHandle(h, SHGFI_SHELLICONSIZE); end;
Partager