how to use Member pszText, cx & Co from LVCOLUMN Structure

how to use Member pszText, cx & Co from LVCOLUMN Structure

Postby Jimmy » Mon Oct 17, 2022 10:38 am

hi,

i use LVCOLUMN from this Thread
https://forums.fivetechsupport.com/viewtopic.php?f=3&t=42301

LVCOLUMN Structure at Microsoft
https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvcolumna
https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvcolumnw
Code: Select all  Expand view
HB_FUNC( LVCOLUMNNEW )
{
   LVCOLUMN * lvcol = ( LVCOLUMN * ) hb_xgrab( sizeof( LVCOLUMN ) );

   memset( lvcol, 0, sizeof( LVCOLUMN ) );
   hb_retptr( ( void * ) lvcol );
}


but it fail here
Code: Select all  Expand view
METHOD InitTheListView()
   ::oLVCol := LVCOLUMN():New()

   // LVCF_FMT     = col:fmt   -> LVCFMT_LEFT / LVCFMT_RIGHT / LVCFMT_CENTER
   // LVCF_WIDTH   = col:cx    -> Pixel wide
   // LVCF_TEXT    = col:pszText -> Data
   // LVCF_SUBITEM = use Sub-Items
   ::oLVCol:Mask := hb_bitOr(LVCF_FMT, LVCF_WIDTH, LVCF_TEXT, LVCF_SUBITEM )

   for nCol := 1 to LEN(::aHeader)
      ::oLVCol:pszText  := ::aHeader[nCol][ID_HEADER]

Error description: Error BASE/1005 Message not found: LVCOLUMN:_PSZTEXT
Args:
[ 1] = O LVCOLUMN


Question : do i have to define a Method and HB_FUNC() for every Structure Member :?:

Code: Select all  Expand view
METHOD pszText( cValue ) CLASS LVColumn
...
HB_FUNC( LV_COLUMNPSZTEXT )
{
   int pszText = ( ( LVCOLUMN * ) hb_parptr( 1 ) )->pszText;

   if( ! hb_pcount() )
      hb_retnl( ( HB_LONG ) pszText );
   else
      ( ( LVCOLUMN * ) hb_parptr( 1 ) )->pszText = ( char * ) hb_parnl( 2 );

   hb_retnl( pszText );
}
 


under Xbase++ i have access to all Member of Structure
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1587
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: how to use Member pszText, cx & Co from LVCOLUMN Structure

Postby Antonio Linares » Mon Oct 17, 2022 3:56 pm

Dear Jimmy,

> Question : do i have to define a Method and HB_FUNC() for every Structure Member ?

Yes
regards, saludos

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

Re: how to use Member pszText, cx & Co from LVCOLUMN Structure

Postby Jimmy » Mon Oct 17, 2022 11:08 pm

hi,

i got Warning
Warning W8069 LVREPORT.prg 435: Nonportable pointer conversion in function HB_FUN_LV_COLUMNPSZTEXT

Code: Select all  Expand view
HB_FUNC( LV_COLUMNPSZTEXT )
{
   int pszText = ( ( LVCOLUMN * ) hb_parptr( 1 ) )->pszText;

who can help me please with "C" Code of HB_FUNC( LV_COLUMNPSZTEXT )
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1587
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: how to use Member pszText, cx & Co from LVCOLUMN Structure

Postby Jimmy » Tue Oct 18, 2022 1:17 am

next Problem

Error E2096 LVREPORT.prg 636: Illegal structure operation in function HB_FUN_LV_DISPINFO
Error E2096 LVREPORT.prg 641: Illegal structure operation in function HB_FUN_LV_DISPINFO


Code: Select all  Expand view
634HB_FUNC( LV_DISPINFO )
635{
636│   UINT item = ( ( NMLVDISPINFOA * ) hb_parptr( 1 ) )->item;
637
638│   if( ! hb_pcount() )
639│      hb_retnl( ( HB_LONG ) item );
640│   else
641│      ( ( NMLVDISPINFOA * ) hb_parptr( 1 ) )->item = ( UINT ) hb_parnl( 2 );
642
643│   hb_retnl( item );
644}
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1587
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: how to use Member pszText, cx & Co from LVCOLUMN Structure

Postby Jimmy » Tue Oct 18, 2022 5:40 am

hi,

have found out that i have to use Member of Structure in HB_FUNC() as "C" Code like for LVITEMx

Code: Select all  Expand view
HB_FUNC ( LISTVIEW_INSERTITEM )
{
   LV_ITEM LVI;
   HWND hWnd = (HWND) HMG_parnl (1);
   INT nRow  = (INT)  hb_parni (2);
   INT nColumnCount = (INT)  hb_parni (4);
   INT nCol;
   
   LVI.mask      = LVIF_TEXT;
   LVI.iItem     = nRow;
   LVI.iSubItem  = 0;
   LVI.state     = 0;
   LVI.stateMask = 0;
   LVI.pszText   = (TCHAR*) HMG_parvc (3, 1);
   LVI.iImage    = 0;

   ListView_InsertItem (hWnd, &LVI);

   for (nCol = 1 ; nCol < nColumnCount ; nCol++)
        ListView_SetItemText (hWnd, nRow, nCol, (TCHAR*) HMG_parvc (3, nCol+1));
}

so i have to call HB_FUNC() with Parameter and "right" Type ... hm
btw. Prefix "HMG_" is "compatible" with 64 Bit, what under FiveWin :?:

but how to pass Array and use a Loop to "fill" Member of Structure
Code: Select all  Expand view
{
   LV_COLUMN oLVCol ;
   for (nCol = 1 ; nCol < nColumnCount ; nCol++)
      // how to use Array ?
     oLVCol.pszText  := aHeader[nCol][ID_HEADER]+ chr(0)
     oLVCol.cx       := aHeader[nCol][ID_WIDTH ]
}
 

p.s. why it is called LV_ITEM under harbour while Microsoft say LVITEMA / LVITEMW for Structure
is there a List to "see" which Structure harbour use ?
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1587
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: how to use Member pszText, cx & Co from LVCOLUMN Structure

Postby Jimmy » Tue Oct 18, 2022 10:23 am

hi,

got a Solution
Code: Select all  Expand view
  AADD( aHeader, { "Name", 250, LVCFMT_LEFT, "C" } )
   AADD( aHeader, { "Size", 100, LVCFMT_RIGHT, "N" } )
   AADD( aHeader, { "Date", 80, LVCFMT_RIGHT, "D" } )
   AADD( aHeader, { "Time", 70, LVCFMT_RIGHT, "C" } )
   AADD( aHeader, { "Attr", 40, LVCFMT_CENTER, "C" } )


Code: Select all  Expand view
  FOR nCol := 1 TO LEN( ::aHeader )
      nWidth := ::aHeader[ nCol ] [ ID_WIDTH ]
      cCaption := VAR2CHAR( ::aHeader[ nCol ] [ ID_HEADER ] ) + CHR( 0 )
      nJustify := ::aHeader[ nCol ] [ ID_ALIGN ]

      LV_ADDCOLUMN( hWnd, nCol, nWidth, cCaption, nJustify )          
   NEXT


Code: Select all  Expand view
HB_FUNC( LV_ADDCOLUMN )
{
   LV_COLUMN COL;

   COL.mask= LVCF_WIDTH | LVCF_TEXT | LVCF_FMT | LVCF_SUBITEM ;
   COL.cx= hb_parni(3);
   COL.pszText = (TCHAR*) hb_parc(4);
   COL.iSubItem=hb_parni(2)-1;
   COL.fmt = hb_parni(5) ;

   ListView_InsertColumn ( (HWND) hb_parnl (1), hb_parni(2)-1, &COL );
}
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1587
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 69 guests