Also for Listview

Also for Listview

Postby Silvio.Falconi » Tue Jun 16, 2015 7:55 am

local bAction:= {|| OptionFile(oAllegati,oList:nOption) }
oList := TListView():New(oAllegati:nHeight-300,2,{},bAction, oAllegati, ,,.T., .F., oAllegati:nwidth-25,150, )

function Optionfile(oAllegati,oList)
msginfo(oList:nOption)
return nil


I need a baction to show the caption of item
But the baction not run ok

I tried also with

Local nOption:= oList:nOption
oList:GetItem(nOption)
? oList:aPrompt[nOption]

and

msginfo(str(oList:nOption))

give me this error

Code: Select all  Expand view  RUN
Application
===========
   Path and name: E:\Allegati\Allegati.Exe (32 bits)
   Size: 2,789,376 bytes
   Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20140725)
   FiveWin  Version: FWHX 15.01
   Windows version: 5.1, Build 2600 Service Pack 3

   Time from start: 0 hours 0 mins 12 secs
   Error occurred at: 06/16/15, 09:57:56
   Error description: Error BASE/1004  Class: 'NUMERIC' has no exported method: NOPTION
   Args:
     [   1] = N   2

Stack Calls
===========
   Called from:  => NOPTION( 0 )
   Called from: Source\test.prg => OPTIONFILE( 165 )
   Called from: Source\test.prg => (b)CREALISTVIEW( 206 )
   Called from: Source\tlistvie.prg => TLISTVIEW:NOTIFY( 222 )
   Called from: .\source\classes\WINDOW.PRG => TDIALOG:NOTIFY( 1670 )
   Called from:  => TWINDOW:HANDLEEVENT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT( 906 )
   Called from:  => DIALOGBOXINDIRECT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 286 )
   Called from: Source\test.prg => TEST( 156 )
   Called from: Source\test.prg => MAIN( 45 )
 



Local nfile:=oList:nOption

msginfo(str(oList:nOption)) give me the number

? oList:aItems[nFile]:cText //make error
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7068
Joined: Thu Oct 18, 2012 7:17 pm

Re: Also for Listview

Postby Antonio Linares » Wed Jun 17, 2015 5:58 pm

Please provide a self contained example to reproduce the error, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Also for Listview

Postby Silvio.Falconi » Wed Jun 17, 2015 7:19 pm

on line 54 error


I need the name , the size, and the last date of the file dropped

to try it you must drop two file into
when you click on a file (icon listview) you can see a msginfo the second make error

test.prg
Code: Select all  Expand view  RUN


# include "fivewin.ch"

static oList,oImageList

Function test()
Local oDlg

Define Dialog oDlg  size 400,400

activate dialog oDlg;
ON INIT Crealistview(oDlg)
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)


 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
   for each cFile in aFiles
      nImage := Icon_Read(cFile)
      //MSgInfo(cFile + STR(GetLastError()))
      //Aggiungi_record(cFile)
      nImage := max(0,ILADDICON( oImageList:hImageList, nImage ) )
      DestroyIcon(nImage)
      oList:InsertItem(nImage, cFile, 0)
   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
    }
    #pragma ENDDUMP

 
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7068
Joined: Thu Oct 18, 2012 7:17 pm

Re: Also for Listview

Postby Silvio.Falconi » Thu Jun 18, 2015 4:04 pm

Any solution please
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7068
Joined: Thu Oct 18, 2012 7:17 pm

Re: Also for Listview

Postby Antonio Linares » Thu Jun 18, 2015 4:21 pm

Silvio,

I get this when I run your example:

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Also for Listview

Postby Silvio.Falconi » Thu Jun 18, 2015 4:24 pm

yes of course

I explain you :
you compile it

now you can drop into one file sample a jpg

and then many others


Image


Image


then with the mouse you can select an item ....

I can Know with oList:nOption the number of item

how I can to Knwow the caption of the item ? ( the name of the file dropped ? )

how I can to delete an item ?

how I can change the caption of a item ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7068
Joined: Thu Oct 18, 2012 7:17 pm

Re: Also for Listview

Postby Antonio Linares » Thu Jun 18, 2015 5:08 pm

Silvio,

Please change this code in your example:

Code: Select all  Expand view  RUN
Procedure Drop(oList,oImageList, nRow,nCol,aFiles)
   local cFile, nImage, oItem
   for each cFile in aFiles
      nImage := Icon_Read(cFile)
      //MSgInfo(cFile + STR(GetLastError()))
      //Aggiungi_record(cFile)
      nImage := max(0,ILADDICON( oImageList:hImageList, nImage ) )
      DestroyIcon(nImage)
      // oList:InsertItem(nImage, cFile, 0)
      oItem = TListViewItem():New( oList )
      oItem:cText = cFile
      oItem:nImage = nImage    
      oItem:Create()       
   next
return
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Also for Listview

Postby Antonio Linares » Thu Jun 18, 2015 5:10 pm

You are properly retrieving the filename here:

Code: Select all  Expand view  RUN

function Optionfile(oList)
   
   Local nfile:= oList:nOption
   
   msginfo(str(oList:nOption))

   msginfo( oList:aItems[nFile]:cText )
return nil
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Also for Listview

Postby Antonio Linares » Thu Jun 18, 2015 5:14 pm

To delete an item we can use:

#define LVM_DELETEITEM (LVM_FIRST + 8)
#define ListView_DeleteItem(hwnd, i) \
(BOOL)SNDMSG((hwnd), LVM_DELETEITEM, (WPARAM)(int)(i), 0L)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Also for Listview

Postby Antonio Linares » Thu Jun 18, 2015 5:17 pm

And this to set the text:

#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_) \
{ LV_ITEM _ms_lvi;\
_ms_lvi.iSubItem = iSubItem_;\
_ms_lvi.pszText = pszText_;\
SNDMSG((hwndLV), LVM_SETITEMTEXT, (WPARAM)(i), (LPARAM)(LV_ITEM *)&_ms_lvi);\
}

Also there is a function to allow inline editing:

#define ListView_EditLabel(hwndLV, i) \
(HWND)SNDMSG((hwndLV), LVM_EDITLABEL, (WPARAM)(int)(i), 0L)

We have not evolved this control more as we did not have feedback about it until now :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Also for Listview

Postby Antonio Linares » Thu Jun 18, 2015 5:20 pm

Code: Select all  Expand view  RUN
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 ) );
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Also for Listview

Postby Antonio Linares » Thu Jun 18, 2015 5:24 pm

Code: Select all  Expand view  RUN
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 );
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Also for Listview

Postby Antonio Linares » Thu Jun 18, 2015 5:31 pm

The add these methods to Class TListViewItem:

METHOD SetText( cText ) INLINE ;
LVSetItemText( ::oParent:hWnd, ::nItem, ::nGroup, cText )

METHOD End() INLINE LVDeleteItem( ::oParent:hWnd, ::nItem )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Also for Listview

Postby Silvio.Falconi » Thu Jun 18, 2015 5:32 pm

thanks Antonio,

can you rewrite all into a new file because I not understood where insert the defines

this the file new ( I add two buttons)
Code: Select all  Expand view  RUN
# include "fivewin.ch"

static oList,oImageList

Function test()
Local oDlg
local obtn[2]
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

activate dialog oDlg;
ON INIT Crealistview(oDlg)
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)


 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)
      //MSgInfo(cFile + STR(GetLastError()))
      //Aggiungi_record(cFile)
      nImage := max(0,ILADDICON( oImageList: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

 
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7068
Joined: Thu Oct 18, 2012 7:17 pm

Re: Also for Listview

Postby Antonio Linares » Thu Jun 18, 2015 5:44 pm

You don't need to include the defines that I copied here

I just did it to know where those functionalities come from
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 62 guests