Any solution ?
I trying with
Static Function InsertGroup()
oList:EnableGroupView()
oList:InsertGroup( "Items 1" )
oList:InsertItem( 0, "Console app", 1)
Return NIL
and it renamed the first as default and it create another group with name "Items 1"
on "Items 1" create the item "Console app"
then when I wish select this file make me error because on baction of Listview I insert
bAction:= { | nOption | Optionfile( oList ) }
function Optionfile(oList)
Local nfile:= 0
Local cFile:= ""
If len(oList:aItems)<>0
nfile:= oList:nOption
IF nFile >0
cFile:= oList:aItems[nFile]:cText
Setfile(cFile,.f.)
Endif
Endif
return nil
Setfile(cFile,.f.) is my function to show Preview Handler on Image control
but the problem is :
when I save the files I save all files on a folder
when I reopen I not found the two Group
how I can to save all groups created ?
a test to try ( but not run ok)
- Code: Select all Expand view
# 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,oImageList
Function test()
Local oDlg
local obtn[3]
Define Dialog oDlg title "test listview" size 400,400
@ 1,1 button obtn[1] prompt " delete item" size 40,10 action Cancella_Item_List(oList)
@ 1,10 button obtn[2] prompt " rename item" size 40,10 action Rinomina_Item_List(oList)
@ 1,20 button obtn[3] prompt "Insert a group" size 40,10 action InsertGroup()
activate dialog oDlg;
ON INIT Crealistview(oDlg)
return nil
Function InsertGroup()
oList:EnableGroupView()
oList:InsertGroup( "Items 1" )
oList:InsertItem( 0, "Console app", 1)
Return NIL
//----------------------------------------------------------------------//
Function Crealistview(oDlg)
Local nOption := 1
local bAction:= { | nOption | Optionfile( oList ) }
oImageList := TImageList():New(32,32)
oImageList:hImageList := Fix(32,32)
oList := TListView():New(oDlg:nHeight-300,2,{},bAction, oDlg, ,,.T., .F., oDlg:nwidth-25,150, )
oList:SetImageList(oImageList,LVSIL_NORMAL)
DragAcceptFiles( oList:hWnd, .T. )
oList:bDropFiles = {|nRow,nCol,aFiles| Drop(oList,oImageList,nRow,nCol,aFiles) }
return nil
//----------------------------------------------------------------------//
Procedure Drop(oList,oImageList, nRow,nCol,aFiles)
local cFile, nImage, oItem
for each cFile in aFiles
nImage := Icon_Read(cFile)
nImage := max(0,ILADDICON( oImageList:hImageList, nImage ) )
DestroyIcon(nImage)
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
function Cancella_Item_List(oList)
Local nItem
Local cFile
If len(oList:aItems)<>0
nItem:= olist:nOption
cFile:= oList:aItems[nitem]:cText
if msgYesNo( i18n("¿ E' sicuro di cancellare questo documento?") + CRLF + ;
cFile ,"Cancella record")
oList:DelItem( nItem )
oList:refresh()
* oImagePreview:Refresh( .t. )
endif
else
msginfo("Non c'è nessun elemento da cancellare")
endif
If len(oList:aItems)==0
cNameFile:=""
* Rinfresca_oDlgallegati()
else
oList:SetItemSelect( 1 )
Endif
return nil
//----------------------------------------------------------------------//
Function Rinomina_Item_List(oList)
Local nItem
Local cnewname:=space(60)
local oldname
local oDlgNewName
Local oBtnConferma, oBtnCancella
LOCAL oFont,oGrp
local aget[2]
If len(oList:aItems)<>0
nItem:=olist:nOption
oldname:= oList:aItems[nItem]:cText
DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0, 8
DEFINE DIALOG oDlgNewName FROM 100, 100 TO 260,376;
STYLE DS_MODALFRAME + WS_POPUPWINDOW + WS_VISIBLE + WS_DLGFRAME + 4;
TITLE i18n("Nuovo nome") PIXEL FONT oFont
* @ 0, 4 GROUP oGrp TO 42, 134 OF oDlgNewName PIXEL
@ 10, 10 say "Name prec :" of oDlgNewName SIZE 120,30 PIXEL FONT oFont
@ 20, 10 GET aGet[1] VAR oldname of oDlgNewName SIZE 120,10 PIXEL FONT oFont READONLY
@ 30, 10 say "Nnew name:" of oDlgNewName SIZE 120,30 PIXEL FONT oFont
@ 40, 10 GET aGet[2] VAR cnewname of oDlgNewName SIZE 120,10 PIXEL FONT oFont
@ 60, 48 BUTTON oBtnConferma PROMPT "&Confirm" of oDlgNewName ;
SIZE 42, 10 PIXEL FONT oFont DEFAULT ACTION ( oDlgNewName:end( IDOK ) )
@ 60, 92 BUTTON oBtnCancella PROMPT "&exit" of oDlgNewName;
SIZE 42, 10 PIXEL FONT oFont CANCEL ACTION ( oDlgNewName:end( IDCANCEL ) )
ACTIVATE DIALOG oDlgNewName center
if oDlgNewName:nresult == IDOK
oList:aItems[nItem]:SetText( cnewname )
else
MsgStop("Operazione annullata","Nuovo nome" )
endif
else
msginfo("Non c'è nessun elemento da rinominare")
endif
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
}
#pragma ENDDUMP
you can drop files into