#define PICTYPE_ICON 3 #define IID_IDispatch Chr(0x00)+Chr(0x04)+Chr(0x02)+Chr(0x00)+ ; Replicate(Chr(0x00), 4)+Chr(0xC0)+Replicate(Chr(0x00), 6)+Chr(0x46) * Large icons Declare long ExtractIconEx in shell32 String @ File, long iconIndex, ; long @ iconLarge, long iconSmall, long nIcons * Small icons *Declare long ExtractIconEx in shell32 String @ File, long iconIndex, ; * long iconLarge, long @ iconSmall, long nIcons Declare Long OleCreatePictureIndirect In oleaut32 ; String @ PicDesc, String @ RefIID, Long fPictureOwnsHandle, Object @ IPic *IconFile = "D:\Program Files\Microsoft Visual Studio\VFP98\VFP6.exe" iconFile = GetFile("EXE") IconIndex = 6 hIcon = 0 * Large icon ExtractIconEx(@IconFile, IconIndex, @hIcon, 0, 1) * SmallIcon *ExtractIconEx(@IconFile, IconIndex, 0, @hIcon, 1) * Create Picture object according to PICTDESC structure PictDesc = Thisform.DWord(16) ; && Size of PICTDESC structure + Thisform.DWord(PICTYPE_ICON) ; && Type of picture + Thisform.DWord(hIcon) ; && HICON + Thisform.DWord(0) && HPALETTE IPic = 0 iid = IID_IDispatch OleCreatePictureIndirect(@PictDesc, @iid, 1, @IPic) Thisform.ImageList.ListImages.ADD(,"SomePict",IPic)and in the DWORD-Method
*PROCEDURE LongToStr * This function converts a long to a string PARAMETERS nLongVal LOCAL nLoopVar, strReturn strReturn = "" FOR nLoopVar = 24 TO 0 STEP -8 && Long ist vier bytes lang strReturn = CHR(INT(nLongVal/(2^nLoopVar))) + strReturn nLongVal = MOD(nLongVal, (2^nLoopVar)) NEXT RETURN strReturnSave and run the form. Click on the button and select EXCEL.EXE for excample.
? m.MyForm.imageList.listImages.count
should now return 1.