# include "fivewin.ch"
#define LVSIL_NORMAL 0
#define LVSIL_SMALL 1
#define LVSIL_STATE 2
#define LVS_ICON 0
#define LVS_SMALLICON 2
#define LVS_LIST 3
static oList
static oImageListBig
static oImageListSmall
Function test()
Local oDlg
local obtn[5]
Define Dialog oDlg size 400,400
@ 1,10 button obtn[1] prompt " delete item" action nil
@ 10,10 button obtn[2] prompt " rename item" action nil
@ 8,10 button obtn[3] prompt "Big" SIZE 35,10 action SetWindowLong( oList:hWnd, -16, nOR( WS_CHILD, WS_VISIBLE, WS_TABSTOP, LVS_ICON ) )
@ 8,18 button obtn[4] prompt "Small" SIZE 35,10 action SetWindowLong( oList:hWnd, -16, nOR( WS_CHILD, WS_VISIBLE, WS_TABSTOP, LVS_SMALLICON ) )
@ 8,25 button obtn[5] prompt "List" SIZE 25,10 action SetWindowLong( oList:hWnd, -16, nOR( WS_CHILD, WS_VISIBLE, WS_TABSTOP, LVS_LIST ) )
activate dialog oDlg;
ON INIT Crealistview(oDlg)
return nil
//----------------------------------------------------------------------//
Function give_type(n)
Do Case
case n=1
oList:SetImageList(oImageListBig ,1)
oList:SetImageList(oImageListSmall,0 )
case n=2
oList:SetImageList(oImageListBig ,0)
oList:SetImageList(oImageListSmall,1 )
endcase
return nil
Function Crealistview(oDlg)
Local nOption := 1
local bAction:= { | nOption | Optionfile( oList ) }
oImageListBig := TImageList():New(32,32)
oImageListBig:hImageList := Fix(32,32)
oImageListSmall := TImageList():New(16,16)
oImageListSmall:hImageList := Fix(16,16)
oList := TListView():New(oDlg:nHeight-300,2,{},bAction, oDlg, ,,.T., .F., oDlg:nwidth-25,150, )
oList:SetImageList(oImageListBig,LVSIL_NORMAL)
oList:SetImageList(oImageListSmall,LVSIL_SMALL)
// toglie il dotted
oList:WinStyle(/*LVS_SINGLESEL*/4,.T.)
//oList:lPopUp:= .f.
DragAcceptFiles( oList:hWnd, .T. )
oList:bDropFiles = {|nRow,nCol,aFiles| Drop(oList,nil,nRow,nCol,aFiles) }
return nil
Procedure Drop(oList,oImageList, nRow,nCol,aFiles)
local cFile, nImage, oItem, imgIdx
for each cFile in aFiles
nImage := Icon_Read(cFile)
//MSgInfo(cFile + STR(GetLastError()))
//Aggiungi_record(cFile)
ILADDICON( oImageListSmall:hImageList, nImage )
nImage := max(0,ILADDICON( oImageListBig:hImageList, nImage ) )
DestroyIcon(nImage)
// oList:InsertItem(nImage, cFile, 0)
oItem = TListViewItem():New( oList )
oItem:cText = cFile
oItem:nImage = nImage
oItem:Create()
next
return
function Optionfile(oList)
Local nfile:= oList:nOption
msginfo(str(oList:nOption))
msginfo( oList:aItems[nFile]:cText )
return nil
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
#include <CommCtrl.h>
HB_FUNC( FIX )
{
typedef HIMAGELIST ( __stdcall * PIMAGELIST_CREATE ) ( int cx, int cy,
UINT flags, int cInitial, int cGrow );
static PIMAGELIST_CREATE pImageList_Create = NULL;
if( pImageList_Create == NULL )
{
HMODULE hDLL = LoadLibrary( "comctl32.dll" );
if( hDLL )
pImageList_Create = ( PIMAGELIST_CREATE ) GetProcAddress( hDLL, "ImageList_Create" );
FreeLibrary(hDLL);
}
#ifndef _WIN64
hb_retnl( ( LONG ) pImageList_Create( hb_parnl( 1 ), hb_parnl( 2 ),
ILC_MASK | ILC_COLOR32, 0, 50 ) );
#else
hb_retnll( ( LONGLONG ) pImageList_Create( hb_parnl( 1 ), hb_parnl( 2 ),
ILC_MASK | ILC_COLOR32, 0, 50 ) );
#endif
}
HB_FUNC( LVDELETEITEM )
{
#ifndef _WIN64
HWND hWnd = ( HWND ) hb_parnl( 1 );
#else
HWND hWnd = ( HWND ) hb_parnll( 1 );
#endif
ListView_DeleteItem( hWnd, hb_parnl( 2 ) );
}
HB_FUNC( LVSETITEMTEXT )
{
LV_ITEM _ms_lvi;
#ifndef _WIN64
HWND hWnd = ( HWND ) hb_parnl( 1 );
#else
HWND hWnd = ( HWND ) hb_parnll( 1 );
#endif
_ms_lvi.iSubItem = hb_parnl( 3 );
_ms_lvi.pszText = ( char * ) hb_parc( 4 );
SendMessage( hWnd, LVM_SETITEMTEXT, hb_parnl( 2 ), ( LPARAM ) ( LV_ITEM * ) &_ms_lvi );
}
#pragma ENDDUMP