ich möchte das "richtige" File Icon-Handle für eine ImageList (comctl32.DLL) haben.
da ich hier ot4xb einsetzte ergibt sich ein Unterschied bei der Syntax
Code: Alles auswählen
@comctl32:ImageList_Create(a,b,c,d,e)
->
DLLFUNCTION ImageList_Create(a,b,c,d,e) USING STDCALL FROM comctl32.DLL
hier nun die "o:Create()" Methode
Code: Alles auswählen
::nRowMax := LEN(::aData) // ::aData -> Directory() Array Struktur
nhImgList := @comctl32:ImageList_Create( ;
::nIcoSmallWidth ,; // The width, in pixels, of each image
::nIcoSmallHeight ,; // The height, in pixels, of each image
ILC_MASK ,; // A set of bit flags that specify the type of image list to create
0 ,; // The number of images that the image list initially contains.
::nRowMax ) // This parameter represents the number of new images that the resized image list can contain
zum "auffüllen" habe ich eine modifizierte XbpIcon() Class benutzt
original siehe C:\ALASKA\XPPW32\Source\SYS\xbparts.prg
Code: Alles auswählen
CLASS MYICON FROM XBPICON
EXPORTED:
VAR Handle
INLINE METHOD MyLoad( cDLL, nId, nWidth, nHeight )
LOCAL hModule
IF ::Status() != XBP_STAT_CREATE
Exception():RaiseObjectState()
ENDIF
IF ::Handle != 0
@user32:DestroyIcon( ::Handle )
ENDIF
IF ValType(cDLL) == "C"
hModule := @KERNEL32:GetModuleHandleA( cDLL )
ELSE
hModule := @KERNEL32:GetModuleHandleA( 0 )
ENDIF
IF ValType(nWidth) != "N"
nWidth := 32
ENDIF
IF ValType(nHeight) != "N"
nHeight := 32
ENDIF
::Handle := @user32:LoadImageA( hModule,;
nId ,;
IMAGE_ICON ,;
nWidth,nHeight ,;
LR_DEFAULTCOLOR )
* ::GetIconInfo() // ich brauche nur das ::Handle
RETURN (::Handle)
Code: Alles auswählen
@comctl32:ImageList_ReplaceIcon(;
nhImgList ,; // A handle to the image list.
-1 ,; // The index of the image to replace. If i is -1, the function appends the image to the end of the list
nIcoHandle ) // The handle to the icon or cursor that contains the bitmap and mask for the new image.
Code: Alles auswählen
FOR nRow = 1 TO ::nRowMax
nIcoHandle := 0
oPicture := NIL
cFile := ::cStartDir + ::aData[nRow][F_NAME]
oIcon := MYICON():new():create()
#IFDEF WARUM
// nIcoHandle ist > 0 ... aber keine Icon anzeige ...
nIcoHandle := oIcon:LoadFileIcon(cFile)
#ELSE
// so läuft es
nIcoHandle := oIcon:Myload(,nIcon)
nIcon++
IF nIcon > 19
nIcon := 11
ENDIF
#ENDIF
hier die Methode LoadFileIcon
Code: Alles auswählen
INLINE METHOD LoadFileIcon( cFile, lBigIcon ,cFileAttributes)
**************************************************************************
*
* SHFILEINFO psfi;
*
* hImageList = (HIMAGELIST)SHGetFileInfo(szFileName, 0, &psfi,
* sizeof(SHFILEINFO), SHGFI_ICON | SHGFI_SYSICONINDEX | HGFI_SMALLICON );
*
* ListView_SetImageList(hList, hImageList, LVSIL_SMALL);
*
**************************************************************************
LOCAL pBuf
LOCAL nFlags
LOCAL nFileAttributes := 0
DEFAULT lBigIcon TO .T.
IF ::Status() != XBP_STAT_CREATE
Exception():RaiseObjectState()
ENDIF
IF ::Handle != 0
@user32:DestroyIcon( ::Handle )
ENDIF
IF lBigIcon == .T.
nFlags := SHGFI_ICON
ELSE
/* nFlags := SHGFI_SMALLICON */ // SHGFI_SMALLICON allein geht nicht
nFlags := nOr(SHGFI_ICON,SHGFI_SMALLICON)
* nFlags := SHGFI_ICON+SHGFI_SMALLICON
ENDIF
IF cFileAttributes != NIL /* .AND. ! ".exe" $ lower( cFile ) */ // Will man das individuelle
// Exe-Icon oder nicht ?
nFlags += SHGFI_USEFILEATTRIBUTES // 0x10
IF "D" $ cFileAttributes
nFileAttributes := FILE_ATTRIBUTE_DIRECTORY // 0x10
ELSE
nFileAttributes := FILE_ATTRIBUTE_NORMAL // 0x80
ENDIF
ENDIF
* pBuf := Replicate( Chr(0), 348 ) // lt. MSDN braucht man 352 Bytes
* IF @SHELL32:SHGetFileInfoA(cFile, 0, @pBuf, 348, nFlags) == 0
pBuf := Replicate( Chr(0), 352 )
IF @SHELL32:SHGetFileInfoA(cFile, nFileAttributes, @pBuf, 352, nFlags) == 0
RETURN 0
ENDIF
//
// was ist das nun für ein Handle ?
//
::Handle := Bin2L( Left(pBuf,4) )
::GetIconInfo() //
RETURN (::Handle)
nun habe aber ich genau die selbe Routine zusammen mit Alaska´s ImageList am laufen ...
Code: Alles auswählen
oIcon := MYICON():new():create()
nFileHandle := oIcon:LoadFileIcon(cFile)
oPicture := oIcon:getIPicture()
an der Routine selbst liegt es also IMHO nicht ... aber irgendwas "fehlt" mir noch ...
wer hat eine Idee ?