Problem with Listview

Problem with Listview

Postby Silvio.Falconi » Fri Jun 05, 2015 11:11 am

I have a dbf with two record
Code: Select all  Expand view  RUN

    static function CreateTestDbf()

       local aCols := { { "PRCODE", 'C', 4, 0 }, { "PRDESC", 'C', 40, 0 }, ;
                        { "PRIMAGE", 'C', 60, 0 } }


      if .t. // ! File( "PROMO.DBF" )
          DBCREATE( "PROMO", aCols )
          USE PROMO EXCLUSIVE
          APPEND BLANK
          FIELD->PRCODE :="0001"
          FIELD->PRDESC :="PROMOZIONE  DI NATALE "
          FIELD->PRIMAGE:=".\bitmaps\files-exel.ico"
    APPEND BLANK
          FIELD->PRCODE :="0002"
          FIELD->PRDESC :="PROMOZIONE  DI PASQUA "
          FIELD->PRIMAGE:=".\bitmaps\files-word.ico"
         USE
       endif
    return nil
 



If I try to load this dbf into a listview control there is a strange error as you can see on this picture

Image

the listview load my record but add 3 object (&one,&two,&tree) WHY ?

this is the test

Code: Select all  Expand view  RUN


    #INCLUDE "Fivewin.ch"
    #INCLUDE "Ribbon.ch"
    #include "constant.ch"
    #INCLUDE "XBROWSE.ch"

    #define TRUE .t.
    #define FALSE .f.

    Function Promo_ListVw()
       Local oDlg,oBtn1,oBtn2
       Local bClrGrad := { | lPressed | If( ! lPressed,;
                               { { 1, nRGB( 253, 254, 255 ), nRGB( 179, 217, 255 ) } },;
                               { { 1, nRGB( 179, 217, 255 ), nRGB( 253, 254, 255 ) } } ) }

    Local  nBottom   := 23
    Local  nRight    := 99
    Local  nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
    Local  nHeight := nBottom * DLG_CHARPIX_H



    Local lGridAll := TRUE
    Local lGridRow := FALSE

    Local oBtnConferma,oBtnAnnulla


    Local oGridPromo,oBtnDown,oListView, oImageList

    Local aPromozioni := {}
    Local aPromoImages:= {}


    CreateTestDbf()





    DEFINE DIALOG oDlg  SIZE nWidth, nHeight;
                TITLE "Selezionare una promozione";
                STYLE nOr( DS_MODALFRAME, WS_POPUP, WS_CAPTION,  4 )



   USE PROMO  ALIAS PR
     DO WHILE ! PR->(EoF())
        AAdd( aPromozioni,( TRIM(PR->PRDESC)))
        AAdd( aPromoImages,( allTRIM(PR->PRIMAGE)))
         PR->(DbSkip())
      ENDDO
    CLOSE PR





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









       @ 150, 50  BTNBMP oBtnConferma PROMPT "&Conferma" OF oDlg FILENAME ".\bitmaps\DLG_OK.bmp" NOBORDER SIZE 50, 20 PIXEL  DEFAULT  ACTION   ( oDlg:end( IDOK ) )
       @ 150, 102 BTNBMP oBtnAnnulla PROMPT "&Annulla" OF oDlg FILENAME ".\bitmaps\DLG_NO.bmp" NOBORDER SIZE 50, 20 PIXEL  CANCEL ACTION  ( oDlg:end( IDCANCEL ) )
              oBtnConferma:bClrGrad = bClrGrad
              oBtnAnnulla:bClrGrad = bClrGrad
                         oBtnConferma:nLayout :=2
                         oBtnAnnulla:nLayout :=2


                        ACTIVATE DIALOG oDlg ;
                         ON INIT CreaListview(oImageList,aPromozioni,aPromoImages, oDlg)


     IF oDlg:nresult == IDOK



     ENDIF

     RETURN NIL

      FUNCTION CreaListview(oImageList,aPromozioni,aPromoImages, oDlg)
       Local oLvw,oBtnUp,oBtnDown


       @ 145, 10 LISTVIEW oLvw SIZE odlg:nwidth-30,130 PIXEL ;
          ACTION MsgInfo( nOption )




         for i=1 to len(aPromozioni)
            oLvw:InsertItem(i-1 , aPromozioni[i] )
           * oImageList:ReadBitmap( aPromoImages[i], 40,1)
                  oImageList:AddIcon(aPromoImages[i])
         Next i

       oLvw:SetImageList( oImageList )




    @  300,5 RBBTN oBtnUp    BITMAP ".\bitmaps\Up.BMP"  SIZE 40,40  OF  oDlg  PIXEL ;
            BORDER  CENTER ROUND ROUNDSIZE 2;
           ACTION  oLvw:KeyDown(VK_UP, 0)

    @  300,55 RBBTN oBtnDown  BITMAP ".\bitmaps\Down.BMP"  SIZE 40,40  OF  oDlg  PIXEL;
           BORDER  CENTER ROUND ROUNDSIZE 2;
           ACTION   oLvw:KeyDown(VK_DOWN, 0)






       RETU NIL



    static function CreateTestDbf()

       local aCols := { { "PRCODE", 'C', 4, 0 }, { "PRDESC", 'C', 40, 0 }, ;
                        { "PRIMAGE", 'C', 60, 0 } }


      if .t. // ! File( "PROMO.DBF" )
          DBCREATE( "PROMO", aCols )
          USE PROMO EXCLUSIVE
          APPEND BLANK
          FIELD->PRCODE :="0001"
          FIELD->PRDESC :="PROMOZIONE  DI NATALE "
          FIELD->PRIMAGE:=".\bitmaps\files-exel.ico"
    APPEND BLANK
          FIELD->PRCODE :="0002"
          FIELD->PRDESC :="PROMOZIONE  DI PASQUA "
          FIELD->PRIMAGE:=".\bitmaps\files-word.ico"

         USE
       endif

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

Re: Problem with Listview

Postby AntoninoP » Wed Jun 10, 2015 8:53 am

Hello,
I see this behavior too!
The problem is in tlistview.prg:
Code: Select all  Expand view  RUN
METHOD New( nTop, nLeft, aPrompts, bAction, oWnd, nClrFore,;
            nClrBack, lPixel, lDesign, nWidth, nHeight, cMsg ) CLASS TListView

   DEFAULT nTop     := 0, nLeft := 0,;
           aPrompts := { "&One", "&Two", "T&hree" },;
 

The only workaround I found is call New directly, in your case:
Code: Select all  Expand view  RUN
// @ 145, 10 LISTVIEW oLvw SIZE odlg:nwidth-30,130 PIXEL ACTION MsgInfo( nOption )
    oLvw := TListView():New( 145, 10,{}, { | nOption, Self | MsgInfo( nOption ) },,,, .T., .F., odlg:nwidth-30, 130, )
 

The easy way is to preprocess then add as 3rd parameter an empty array.
The listview implementation of fivewin looks only a sketch.

I see you have problem with the imageList too, I solved it in this way:
At imageList creation:
Code: Select all  Expand view  RUN
oImageList = TImageList():New( 48, 48 )
oImageList:hImageList := Fix(48,48)

plus this DUMP:
Code: Select all  Expand view  RUN
#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;
   HMODULE hDLL = NULL;
   if( pImageList_Create == NULL )
   {
      hDLL = LoadLibrary( "comctl32.dll" );
      if( hDLL )
         pImageList_Create = ( PIMAGELIST_CREATE ) GetProcAddress( hDLL, "ImageList_Create" );
   }
   
#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

Regards,
Antonino
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Problem with Listview

Postby Silvio.Falconi » Wed Jun 10, 2015 9:37 am

thanks
run all ok
only when i compile fix function if I use w2 /w1 or w
Warning W8004 test.prg 396: 'hDLL' is assigned a value that is never used in function HB_FUN_FIX
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: 7072
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with Listview

Postby cnavarro » Wed Jun 10, 2015 10:02 am

Try

Code: Select all  Expand view  RUN

HMODULE hDLL; // = NULL
 
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: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Problem with Listview

Postby Antonio Linares » Wed Jun 10, 2015 2:45 pm

The solution is to modify tlistvie.prg this way:

Code: Select all  Expand view  RUN

METHOD New( nTop, nLeft, aPrompts, bAction, oWnd, nClrFore,;
            nClrBack, lPixel, lDesign, nWidth, nHeight, cMsg ) CLASS TListView

   DEFAULT nTop     := 0, nLeft := 0,;
           aPrompts := {},;
 


We just include three TListView examples in FWH and never got any feedback about it up today. Thank you :-)

Included for the next FWH build.
regards, saludos

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

Re: Problem with Listview

Postby Antonio Linares » Wed Jun 10, 2015 3:06 pm

Antonino,

If we replace ILC_COLOR24 with ILC_COLOR32 then I guess FWH code should properly work

unless I am missing something else.

Included for next FWH build, thanks! :-)
regards, saludos

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

Re: Problem with Listview

Postby Antonio Linares » Wed Jun 10, 2015 3:08 pm

Silvio,

Silvio.Falconi wrote:thanks
run all ok
only when i compile fix function if I use w2 /w1 or w
Warning W8004 test.prg 396: 'hDLL' is assigned a value that is never used in function HB_FUN_FIX


Replace this code:
Code: Select all  Expand view  RUN
  HMODULE hDLL = NULL;
   if( pImageList_Create == NULL )
   {
      hDLL = LoadLibrary( "comctl32.dll" );
      if( hDLL )
         pImageList_Create = ( PIMAGELIST_CREATE ) GetProcAddress( hDLL, "ImageList_Create" );
   }


with this:
Code: Select all  Expand view  RUN
  if( pImageList_Create == NULL )
   {
      HMODULE hDLL = LoadLibrary( "comctl32.dll" );
      if( hDLL )
         pImageList_Create = ( PIMAGELIST_CREATE ) GetProcAddress( hDLL, "ImageList_Create" );
   }
regards, saludos

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

Re: Problem with Listview

Postby Antonio Linares » Wed Jun 10, 2015 3:10 pm

Also a FreeLibrary() call is missing in that fix.

Anyhow next FWH build will include these changes :-)
regards, saludos

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

Re: Problem with Listview

Postby AntoninoP » Wed Jun 10, 2015 3:32 pm

Antonio Linares wrote:Also a FreeLibrary() call is missing in that fix.

Anyhow next FWH build will include these changes :-)

ops :lol:
so the final version is:
Code: Select all  Expand view  RUN
if( pImageList_Create == NULL )
   {
      HMODULE hDLL = LoadLibrary( "comctl32.dll" );
      if( hDLL )
         pImageList_Create = ( PIMAGELIST_CREATE ) GetProcAddress( hDLL, "ImageList_Create" );
      FreeLibrary(hDLL);
   }

It is missing in FiveWin code, fwh\source\winapi\imagelis.c

You are correct, another solution is modify imagelis.c to create always 32bit imageList, but generally I prefer don't change fivewin code.
Regards,
Antonino
Last edited by AntoninoP on Wed Jun 10, 2015 4:18 pm, edited 1 time in total.
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Problem with Listview

Postby Antonio Linares » Wed Jun 10, 2015 4:15 pm

Antonino,

The problem that we have in imagelis.c is that we load the DLL to get all the pointers at once to speed up
the need for loading and freeing a DLL.

In fact we would need an exit procedure to free the DLL, but as we only load it once, the EXE will release
it on the application exit, so its not a problem.

The problem only comes from loading it more than one time, then the EXE when it finish will not release those
extra loads, it will just decrease a Windows internal counter in one.
regards, saludos

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

Re: Problem with Listview

Postby Silvio.Falconi » Thu Jun 11, 2015 11:11 am

Antonio,

is there a function to call the icon of file ?

I explain if I add a record sample

c:\work\testsample.doc

it must create a item on listview and show his icon on listview

is it possible ?
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: 7072
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with Listview

Postby AntoninoP » Thu Jun 11, 2015 1:33 pm

The FWH function Icon_Read returns the HICON of the file regardless its extension.
Here a snapshot of my code:

Code: Select all  Expand view  RUN
nImage := Icon_Read("c:\work\testsample.doc")
      nImage := max(0,ILADDICON( oImageList:hImageList, nImage ) )
      DestroyIcon(nImage)
      oList:InsertItem(nImage, cFile, 0)


Regards,
Antonino
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Problem with Listview

Postby Silvio.Falconi » Fri Jun 12, 2015 8:45 am

I saw good.. I not Known this function sorry
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: 7072
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with Listview

Postby Silvio.Falconi » Sat Jun 13, 2015 12:06 pm

to make a preview for each file I need IPreviewHandler https://msdn.microsoft.com/en-us/librar ... 15(v=vs.85).aspx
but I not Know how use it on TListview Item class
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: 7072
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 62 guests