Also for Listview

Re: Also for Listview

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

Antonio ,
I tried to delete an item

oList:aItems[nItem]:end()

run ok

but when I delete on item the procedure call the Optionfile(oList) function I not understood why ( perhaps I have an 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: 6871
Joined: Thu Oct 18, 2012 7:17 pm

Re: Also for Listview

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

Antonio,
fantastic

now run ok

Code: Select all  Expand view
function deleteitem(nItem)

     ?oList:aItems[nItem]:cText

   oList:aItems[nItem]:end()


   return nil


     Function  renameitem( nItem)
      Local newname:="Antonio"
             ?oList:aItems[nItem]:cText
           oList:aItems[nItem]:SetText( newname )
           return nil

 
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: 6871
Joined: Thu Oct 18, 2012 7:17 pm

Re: Also for Listview

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

Silvio,

I am using your example modified this way:

Code: Select all  Expand view
# include "fivewin.ch"

static oList, oImageList

Function test()

   Local oDlg

   DEFINE DIALOG oDlg SIZE 400, 400

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT Crealistview(oDlg) ;
      ON CLICK oList:aItems[ 1 ]:End()     
           
return nil

//----------------------------------------------------------------------//

Function Crealistview(oDlg)

   Local nOption     := 1
   local bAction:= { | nOption | Optionfile( oList ) }

   oImageList := TImageList():New(32,32)

   oList := TListView():New( oDlg:nHeight-300, 10, {}, 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
regards, saludos

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

Re: Also for Listview

Postby Silvio.Falconi » Thu Jun 18, 2015 6:01 pm

But thereis another error

then you erase all icons on listview and press the button to rename or delete

there is aldo the item on listview

it is not showed on list view but

if I use the command

?oList:aItems[nItem]:cText

it showed the last item text




please use this test code
Code: Select all  Expand view
# 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 deleteitem(olist:nOption)
@ 10,10 button obtn[2] prompt " rename item" action  renameitem( olist:nOption)

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 deleteitem(nItem)

     ?oList:aItems[nItem]:cText

   oList:aItems[nItem]:end()


   return nil


     Function  renameitem( nItem)
      Local newname:="Antonio"
             ?oList:aItems[nItem]:cText
           oList:aItems[nItem]:SetText( newname )
           return nil


function Optionfile(oList)

   Local nfile:= oList:nOption

   msginfo(str(oList:nOption))

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


 
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: 6871
Joined: Thu Oct 18, 2012 7:17 pm

Re: Also for Listview

Postby Antonio Linares » Thu Jun 18, 2015 6:46 pm

Silvio,

I finally have implemented it this way in Class TListView:

Code: Select all  Expand view
  METHOD DelItem( nItem ) INLINE If( nItem > 0 .and. nItem <= Len( ::aItems ),;
                                  ( LVDeleteItem( ::hWnd, nItem - 1 ), ADel( ::aItems, nItem ),;
                                    ::aItems := ASize( ::aItems, Len( ::aItems ) - 1 )  ),)
regards, saludos

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

Re: Also for Listview

Postby Otto » Fri Jun 19, 2015 9:36 am

Dear Antonio,

can you please post the whole sample.

Thanks in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6147
Joined: Fri Oct 07, 2005 7:07 pm

Re: Also for Listview

Postby cnavarro » Fri Jun 19, 2015 9:38 am

+++++1
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6515
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Also for Listview

Postby Silvio.Falconi » Fri Jun 19, 2015 9:49 am

Otto, see my sample and then add the new methods (of Antonio) into tilistview class
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: 6871
Joined: Thu Oct 18, 2012 7:17 pm

Re: Also for Listview

Postby AntoninoP » Fri Jun 19, 2015 10:19 am

Wow, there are lot of great enhancements in TListView!!

I done some experiment about class management in Harbour: It is possible define Class's method in C and Manipulate a Class and return it from C code.
Here an example to avoid save item data in another array.
Code: Select all  Expand view
#include <fivewin.ch>
#include <dialog.ch>

procedure Main()
   LOCAL oDlg
   TListViewItem() //without this does not found the class :(
   DEFINE DIALOG oDlg FROM  0,0 TO 220,200 PIXEL TITLE "Test"
   ACTIVATE DIALOG oDlg CENTER ON INIT InitDlg(Self)
return

PROCEDURE InitDlg(oDlg)
   LOCAL oList
   @ 1,1 LISTVIEW oList PROMPTS "FiveWin","Item2" OF oDlg SIZE 160,160
   @ 11,1 BUTTON "Test" ACTION CLICK(oList) SIZE 40,16
return

PROCEDURE CLICK(oList)
   //LOCAL pItem := oList:MyGetItem(1) //if you declare it in class
   LOCAL pItem := TLISTVIEW_MYGETITEM(oList,2)
   LOCAL cInfo := ""
   cInfo += "Item :" + pItem:cText
   cInfo += " Image :" + STR(pItem:nImage)
   MsgInfo(cInfo)
return

#pragma BEGINDUMP
#include <windows.h>
#include <CommCtrl.h>
#include <hbapi.h>
#include <hbapicls.h>
#include <hbapiitm.h>
#include <stdio.h>
#include <hbstack.h>

struct TLISTVIEWDATA
{
   HB_USHORT classId;
   
   HB_SIZE  hWnd;
} TListViewData = {0};

void InitListViewData()
{
   if(TListViewData.classId == 0)
   {
      TListViewData.classId   = hb_clsFindClass("TLISTVIEW", NULL);
      if(TListViewData.classId == 0) MessageBox(NULL,"TLISTVIEW not found","Error",MB_OK);
      TListViewData.hWnd  = hb_clsGetVarIndex(TListViewData.classId,hb_dynsymGet("hWnd"));
   }  
}

struct TLISTVIEWITEMDATA
{
   HB_USHORT classId;
   
   HB_SIZE  oParent  ;
   HB_SIZE  cText    ;
   HB_SIZE  cToolTip ;
   HB_SIZE  nImage   ;
   HB_SIZE  nGroup   ;
   HB_SIZE  nIndent  ;
   HB_SIZE  lChecked ;
   HB_SIZE  nItem    ;
   HB_SIZE  Cargo    ;
} TListViewItemData = {0};

void InitListViewItemData()
{
   InitListViewData();
   if(TListViewItemData.classId == 0)
   {
      TListViewItemData.classId   = hb_clsFindClass("TLISTVIEWITEM", NULL);
      if(TListViewItemData.classId == 0) MessageBox(NULL,"TLISTVIEWITEM not found","Error",MB_OK);
      TListViewItemData.oParent  = hb_clsGetVarIndex(TListViewItemData.classId,hb_dynsymGet("oParent"));
      TListViewItemData.cText    = hb_clsGetVarIndex(TListViewItemData.classId,hb_dynsymGet("cText"));
      TListViewItemData.cToolTip = hb_clsGetVarIndex(TListViewItemData.classId,hb_dynsymGet("cToolTip"));
      TListViewItemData.nImage   = hb_clsGetVarIndex(TListViewItemData.classId,hb_dynsymGet("nImage"));
      TListViewItemData.nGroup   = hb_clsGetVarIndex(TListViewItemData.classId,hb_dynsymGet("nGroup"));
      TListViewItemData.nIndent  = hb_clsGetVarIndex(TListViewItemData.classId,hb_dynsymGet("nIndent"));
      TListViewItemData.lChecked = hb_clsGetVarIndex(TListViewItemData.classId,hb_dynsymGet("lChecked"));
      TListViewItemData.nItem    = hb_clsGetVarIndex(TListViewItemData.classId,hb_dynsymGet("nItem"));
      TListViewItemData.Cargo    = hb_clsGetVarIndex(TListViewItemData.classId,hb_dynsymGet("Cargo"));
   }  
}
HB_FUNC( TLISTVIEW_MYGETITEM )
{
   //PHB_ITEM pListView = hb_stackSelfItem(); //in this case all parameter id is one less
   PHB_ITEM pListView = hb_param(1,HB_IT_OBJECT);
   PHB_ITEM pItem;
   HWND hWnd;
   LVITEM lvItem;
   char text[250];
   InitListViewItemData();
   if(pListView==0 || hb_objGetClass(pListView)!=TListViewData.classId)
   {
      /*
            if(pListView==0) MessageBox(NULL,"no parameter","Error",MB_OK);
      else  if(hb_objGetClass(pListView)!=TListViewData.classId)
      {
         sprintf_s(text,250,"parameter is not a TListView, it is a %i instead of %i",
               hb_objGetClass(pListView),TListViewData.classId);
         MessageBox(NULL,text,"Error",MB_OK);
      }*/

      hb_ret();
      return; //invalid input
   }
#ifndef _WIN64
   hWnd = ( HWND ) hb_itemGetNL( hb_itemArrayGet(pListView,TListViewData.hWnd) );
#else  
   hWnd = ( HWND ) hb_itemGetNLL( hb_itemArrayGet(pListView,TListViewData.hWnd) );
#endif
   lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_GROUPID | LVIF_INDENT | LVIF_STATE | LVIF_PARAM;
   lvItem.pszText = text; *text=0;
   lvItem.iItem = hb_parnl( 2 )-1;
   sprintf_s(text,250,"%i - %i - %i",lvItem.iItem, hWnd,TListViewItemData.classId );
   lvItem.iSubItem = HB_ISNUM(3) ? hb_parnl( 3 ) : 0;
   lvItem.cchTextMax = 250;
   lvItem.stateMask = (UINT)-1;
   ListView_GetItem(hWnd,&lvItem);
   hb_clsAssociate( TListViewItemData.classId );
   pItem = hb_stackReturnItem();
   //hb_itemArrayPut(pItem,TListViewItemData.oParent  ,
   hb_itemArrayPut(pItem,TListViewItemData.cText    , hb_itemPutC(NULL, text));
   //hb_itemArrayPut(pItem,TListViewItemData.cToolTip ,
   hb_itemArrayPut(pItem,TListViewItemData.nImage   , hb_itemPutNI(NULL, lvItem.iImage));
   hb_itemArrayPut(pItem,TListViewItemData.nGroup   , hb_itemPutNI(NULL, lvItem.iGroupId));
   hb_itemArrayPut(pItem,TListViewItemData.nIndent  , hb_itemPutNI(NULL, lvItem.iIndent));
   hb_itemArrayPut(pItem,TListViewItemData.lChecked , hb_itemPutL(NULL, (lvItem.state & LVIS_SELECTED)!=0));
   hb_itemArrayPut(pItem,TListViewItemData.nItem    , hb_itemPutNI(NULL, lvItem.iItem));
   if(lvItem.lParam != 0)
      hb_itemArrayPut(pItem,TListViewItemData.Cargo    , (PHB_ITEM)lvItem.lParam); // It is an item, change add.
}

#pragma ENDDUMP

What do you think about It?
Antonino
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Also for Listview

Postby Silvio.Falconi » Sat Jun 20, 2015 3:09 pm

Progetto: test, Ambiente: xFive_Pelles:
[1]:Harbour.Exe test.prg /m /n0 /gc1 /es2 /iC:\Work\fwh\include /ic:\work\xHarbour\Include /jC:\Work\Errori\ANTONI~2\I18n\Main.hil /iinclude;c:\work\fwh\include;c:\work\xHarbour\include /oObj\test.c
xHarbour 1.2.3 Intl. (SimpLex) (Build 20140725)
Copyright 1999-2014, http://www.xharbour.org http://www.harbour-project.org/
Compiling 'test.prg'...
Generating international list to 'C:\Work\Errori\ANTONI~2\I18n\Main.hil'...
Generating C source output to 'Obj\test.c'...
Done.
Lines 26, Functions/Procedures 3, pCodes 144
[1]:Bcc32.Exe -M -c -O2 -tW -v- -X -DHB_FM_STATISTICS_OFF -DHB_NO_DEFAULT_API_MACROS -DHB_NO_DEFAULT_STACK_MACROS -DHB_OS_WIN_32 -IC:\Work\fwh\include -IC:\Work\bcc582\Include;c:\work\xHarbour\Include -nC:\Work\Errori\ANTONI~2\Obj test.c
Borland C++ 5.82 for Win32 Copyright (c) 1993, 2005 Borland
test.c:
Error E2209 test.prg 30: Unable to open include file 'hbapicls.h'
Warning W8065 test.prg 46: Call to function 'hb_clsFindClass' with no prototype in function InitListViewData
Warning W8065 test.prg 48: Call to function 'hb_clsGetVarIndex' with no prototype in function InitListViewData
Warning W8065 test.prg 69: Call to function 'InitListViewData' with no prototype in function InitListViewItemData
Warning W8065 test.prg 72: Call to function 'hb_clsFindClass' with no prototype in function InitListViewItemData
Warning W8065 test.prg 74: Call to function 'hb_clsGetVarIndex' with no prototype in function InitListViewItemData
Warning W8065 test.prg 75: Call to function 'hb_clsGetVarIndex' with no prototype in function InitListViewItemData
Warning W8065 test.prg 76: Call to function 'hb_clsGetVarIndex' with no prototype in function InitListViewItemData
Warning W8065 test.prg 77: Call to function 'hb_clsGetVarIndex' with no prototype in function InitListViewItemData
Warning W8065 test.prg 78: Call to function 'hb_clsGetVarIndex' with no prototype in function InitListViewItemData
Warning W8065 test.prg 79: Call to function 'hb_clsGetVarIndex' with no prototype in function InitListViewItemData
Warning W8065 test.prg 80: Call to function 'hb_clsGetVarIndex' with no prototype in function InitListViewItemData
Warning W8065 test.prg 81: Call to function 'hb_clsGetVarIndex' with no prototype in function InitListViewItemData
Warning W8065 test.prg 82: Call to function 'hb_clsGetVarIndex' with no prototype in function InitListViewItemData
Warning W8065 test.prg 93: Call to function 'InitListViewItemData' with no prototype in function HB_FUN_TLISTVIEW_MYGETITEM
Warning W8065 test.prg 94: Call to function 'hb_objGetClass' with no prototype in function HB_FUN_TLISTVIEW_MYGETITEM
Error E2451 test.prg 112: Undefined symbol 'LVIF_GROUPID' in function HB_FUN_TLISTVIEW_MYGETITEM
Warning W8065 test.prg 115: Call to function 'sprintf_s' with no prototype in function HB_FUN_TLISTVIEW_MYGETITEM
Warning W8065 test.prg 120: Call to function 'hb_clsAssociate' with no prototype in function HB_FUN_TLISTVIEW_MYGETITEM
Error E2451 test.prg 126: Undefined symbol 'iGroupId' in function HB_FUN_TLISTVIEW_MYGETITEM
*** 3 errors in Compile ***
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: 6871
Joined: Thu Oct 18, 2012 7:17 pm

Re: Also for Listview

Postby AntoninoP » Mon Jun 22, 2015 7:11 am

This code is for Harbour, I don't know the xHarbour version of these functions.
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Also for Listview

Postby Silvio.Falconi » Mon Jun 22, 2015 8:17 am

I allready compiled with harbour
Progetto: test, Ambiente: Five_Pelles:
[1]:Harbour.Exe test.prg /m /n0 /gc1 /es2 /iC:\Work\fwh\include /ic:\work\Harbour\Include /jitaliano.HIT /iinclude;c:\work\fwh\include;c:\work\Harbour\include /oObj\test.c
Harbour 3.4.0dev () (2014-06-29 00:47)
Copyright (c) 1999-2014, https://harbour.github.io/
Compiling 'test.prg'...
Lines 4457, Functions/Procedures 3
Generating C source output to 'Obj\test.c'... Done.
[1]:Bcc32.Exe -M -c -O2 -tW -v- -X -DHB_FM_STATISTICS_OFF -DHB_NO_DEFAULT_API_MACROS -DHB_NO_DEFAULT_STACK_MACROS -DHB_OS_WIN_32 -IC:\Work\fwh\include -IC:\Work\bcc582\Include;c:\work\Harbour\Include -nC:\Work\Errori\LISTVI~1\Obj test.c
Borland C++ 5.82 for Win32 Copyright (c) 1993, 2005 Borland
test.c:
Warning W8065 test.prg 69: Call to function 'InitListViewData' with no prototype in function InitListViewItemData
Warning W8065 test.prg 93: Call to function 'InitListViewItemData' with no prototype in function HB_FUN_TLISTVIEW_MYGETITEM
Error E2451 test.prg 112: Undefined symbol 'LVIF_GROUPID' in function HB_FUN_TLISTVIEW_MYGETITEM
Warning W8065 test.prg 115: Call to function 'sprintf_s' with no prototype in function HB_FUN_TLISTVIEW_MYGETITEM
Error E2451 test.prg 126: Undefined symbol 'iGroupId' in function HB_FUN_TLISTVIEW_MYGETITEM
*** 2 errors in Compile ***
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: 6871
Joined: Thu Oct 18, 2012 7:17 pm

Re: Also for Listview

Postby AntoninoP » Mon Jun 22, 2015 9:06 am

Borland :cry:
please add:
Code: Select all  Expand view
void InitListViewData();
void InitListViewItemData()

just after the includes.

and remove the line
Code: Select all  Expand view
sprintf_s(text,250,"%i - %i - %i",lvItem.iItem, hWnd,TListViewItemData.classId );

it was debug text in messagebox

Thank you for testing :wink:
Antonino
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Also for Listview

Postby Antonio Linares » Mon Jun 22, 2015 2:27 pm

Antonino,

Many thanks for your great low level example :-)

Personally I prefer to manage PRG code from high level as it is faster to be modified
unless C code is required for other reasons as speed, low level API calls, etc.

You write a very good code ;-)
regards, saludos

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

Re: Also for Listview

Postby Silvio.Falconi » Tue Jun 23, 2015 3:20 pm

also error ( harbour)
Code: Select all  Expand view
Progetto: test, Ambiente: Five_Pelles:
[1]:Harbour.Exe test.prg  /m /n0 /gc1 /es2 /iC:\Work\fwh\include /ic:\work\Harbour\Include /jitaliano.HIT /iinclude;c:\work\fwh\include;c:\work\Harbour\include /oObj\test.c
Harbour 3.2.0dev (r1406271520)
Copyright (c) 1999-2014, http://harbour-project.org/
Compiling 'test.prg'...
Lines 4476, Functions/Procedures 3
Generating C source output to 'Obj\test.c'... Done.
[1]:Bcc32.Exe -M -c -O2  -tW -v- -X -DHB_FM_STATISTICS_OFF -DHB_NO_DEFAULT_API_MACROS -DHB_NO_DEFAULT_STACK_MACROS -DHB_OS_WIN_32 -IC:\Work\fwh\include -IC:\Work\bcc582\Include;c:\work\Harbour\Include  -nH:\SCUOLA~1\ANTONI~1\Obj test.c
Borland C++ 5.82 for Win32 Copyright (c) 1993, 2005 Borland
test.c:
Warning W8065 test.prg 74: Call to function 'InitListViewData' with no prototype in function InitListViewItemData
Warning W8065 test.prg 98: Call to function 'InitListViewItemData' with no prototype in function HB_FUN_TLISTVIEW_MYGETITEM
Error E2451 test.prg 117: Undefined symbol 'LVIF_GROUPID' in function HB_FUN_TLISTVIEW_MYGETITEM
Error E2451 test.prg 130: Undefined symbol 'iGroupId' in function HB_FUN_TLISTVIEW_MYGETITEM
*** 2 errors in Compile ***
 




the source

Code: Select all  Expand view
#include <fivewin.ch>
#include <dialog.ch>

procedure Main()
   LOCAL oDlg
   TListViewItem() //without this does not found the class :(
   DEFINE DIALOG oDlg FROM  0,0 TO 220,200 PIXEL TITLE "Test"
   ACTIVATE DIALOG oDlg CENTER ON INIT InitDlg(Self)
return

PROCEDURE InitDlg(oDlg)
   LOCAL oList
   @ 1,1 LISTVIEW oList PROMPTS "FiveWin","Item2" OF oDlg SIZE 160,160
   @ 11,1 BUTTON "Test" ACTION CLICK(oList) SIZE 40,16
return

PROCEDURE CLICK(oList)
   //LOCAL pItem := oList:MyGetItem(1) //if you declare it in class
   LOCAL pItem := TLISTVIEW_MYGETITEM(oList,2)
   LOCAL cInfo := ""
   cInfo += "Item :" + pItem:cText
   cInfo += " Image :" + STR(pItem:nImage)
   MsgInfo(cInfo)
return

#pragma BEGINDUMP
#include <windows.h>
#include <CommCtrl.h>
#include <hbapi.h>
#include <hbapicls.h>
#include <hbapiitm.h>
#include <stdio.h>
#include <hbstack.h>

void InitListViewData();
void InitListViewItemData();



struct TLISTVIEWDATA
{
   HB_USHORT classId;
   
   HB_SIZE  hWnd;
} TListViewData = {0};

void InitListViewData()
{
   if(TListViewData.classId == 0)
   {
      TListViewData.classId   = hb_clsFindClass("TLISTVIEW", NULL);
      if(TListViewData.classId == 0) MessageBox(NULL,"TLISTVIEW not found","Error",MB_OK);
      TListViewData.hWnd  = hb_clsGetVarIndex(TListViewData.classId,hb_dynsymGet("hWnd"));
   }  
}

struct TLISTVIEWITEMDATA
{
   HB_USHORT classId;
   
   HB_SIZE  oParent  ;
   HB_SIZE  cText    ;
   HB_SIZE  cToolTip ;
   HB_SIZE  nImage   ;
   HB_SIZE  nGroup   ;
   HB_SIZE  nIndent  ;
   HB_SIZE  lChecked ;
   HB_SIZE  nItem    ;
   HB_SIZE  Cargo    ;
} TListViewItemData = {0};

void InitListViewItemData()
{
   InitListViewData();
   if(TListViewItemData.classId == 0)
   {
      TListViewItemData.classId   = hb_clsFindClass("TLISTVIEWITEM", NULL);
      if(TListViewItemData.classId == 0) MessageBox(NULL,"TLISTVIEWITEM not found","Error",MB_OK);
      TListViewItemData.oParent  = hb_clsGetVarIndex(TListViewItemData.classId,hb_dynsymGet("oParent"));
      TListViewItemData.cText    = hb_clsGetVarIndex(TListViewItemData.classId,hb_dynsymGet("cText"));
      TListViewItemData.cToolTip = hb_clsGetVarIndex(TListViewItemData.classId,hb_dynsymGet("cToolTip"));
      TListViewItemData.nImage   = hb_clsGetVarIndex(TListViewItemData.classId,hb_dynsymGet("nImage"));
      TListViewItemData.nGroup   = hb_clsGetVarIndex(TListViewItemData.classId,hb_dynsymGet("nGroup"));
      TListViewItemData.nIndent  = hb_clsGetVarIndex(TListViewItemData.classId,hb_dynsymGet("nIndent"));
      TListViewItemData.lChecked = hb_clsGetVarIndex(TListViewItemData.classId,hb_dynsymGet("lChecked"));
      TListViewItemData.nItem    = hb_clsGetVarIndex(TListViewItemData.classId,hb_dynsymGet("nItem"));
      TListViewItemData.Cargo    = hb_clsGetVarIndex(TListViewItemData.classId,hb_dynsymGet("Cargo"));
   }  
}
HB_FUNC( TLISTVIEW_MYGETITEM )
{
   //PHB_ITEM pListView = hb_stackSelfItem(); //in this case all parameter id is one less
   PHB_ITEM pListView = hb_param(1,HB_IT_OBJECT);
   PHB_ITEM pItem;
   HWND hWnd;
   LVITEM lvItem;
   char text[250];
   InitListViewItemData();
   if(pListView==0 || hb_objGetClass(pListView)!=TListViewData.classId)
   {
      /*
            if(pListView==0) MessageBox(NULL,"no parameter","Error",MB_OK);
      else  if(hb_objGetClass(pListView)!=TListViewData.classId)
      {
         sprintf_s(text,250,"parameter is not a TListView, it is a %i instead of %i",
               hb_objGetClass(pListView),TListViewData.classId);
         MessageBox(NULL,text,"Error",MB_OK);
      }*/

      hb_ret();
      return; //invalid input
   }
#ifndef _WIN64
   hWnd = ( HWND ) hb_itemGetNL( hb_itemArrayGet(pListView,TListViewData.hWnd) );
#else
   hWnd = ( HWND ) hb_itemGetNLL( hb_itemArrayGet(pListView,TListViewData.hWnd) );
#endif
   lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_GROUPID | LVIF_INDENT | LVIF_STATE | LVIF_PARAM;
   lvItem.pszText = text; *text=0;
   lvItem.iItem = hb_parnl( 2 )-1;
   lvItem.iSubItem = HB_ISNUM(3) ? hb_parnl( 3 ) : 0;
   lvItem.cchTextMax = 250;
   lvItem.stateMask = (UINT)-1;
   ListView_GetItem(hWnd,&lvItem);
   hb_clsAssociate( TListViewItemData.classId );
   pItem = hb_stackReturnItem();
   //hb_itemArrayPut(pItem,TListViewItemData.oParent  ,
   hb_itemArrayPut(pItem,TListViewItemData.cText    , hb_itemPutC(NULL, text));
   //hb_itemArrayPut(pItem,TListViewItemData.cToolTip ,
   hb_itemArrayPut(pItem,TListViewItemData.nImage   , hb_itemPutNI(NULL, lvItem.iImage));
   hb_itemArrayPut(pItem,TListViewItemData.nGroup   , hb_itemPutNI(NULL, lvItem.iGroupId));
   hb_itemArrayPut(pItem,TListViewItemData.nIndent  , hb_itemPutNI(NULL, lvItem.iIndent));
   hb_itemArrayPut(pItem,TListViewItemData.lChecked , hb_itemPutL(NULL, (lvItem.state & LVIS_SELECTED)!=0));
   hb_itemArrayPut(pItem,TListViewItemData.nItem    , hb_itemPutNI(NULL, lvItem.iItem));
   if(lvItem.lParam != 0)
      hb_itemArrayPut(pItem,TListViewItemData.Cargo    , (PHB_ITEM)lvItem.lParam); // It is an item, change add.
}

#pragma ENDDUM
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: 6871
Joined: Thu Oct 18, 2012 7:17 pm

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: karinha and 21 guests