Listview Unicode for CLASS TGrid()

Listview Unicode for CLASS TGrid()

Postby Jimmy » Wed Aug 30, 2023 1:14 pm

hi,

i have found in c:\fwh\source\winapi\listview.c what was change for Unicode

Code: Select all  Expand view  RUN
  LPWSTR pWide = fw_parWide( 3 );

//   lvi.pszText  = ( LPTSTR ) hb_parc( 3 );
   lvi.pszText  = pWide;

Question : is fw_parWide() the same as AnsiToWide() :?:

---

i have now include
Code: Select all  Expand view  RUN
#define UNICODE    // Made Unicode compatible 2023-07-07
#include <CommCtrl.h>
#undef UNICODE
#include "fwh.h"

Question : why "#undef UNICODE" :?:

---

now i get Warning
Warning W8075 .\\HB_FUNC.PRG 702: Suspicious pointer conversion in function HB_FUN_LV_ADDITEM
Warning W8075 .\\HB_FUNC.PRG 717: Suspicious pointer conversion in function HB_FUN_LV_ADDITEM
Warning W8075 .\\HB_FUNC.PRG 764: Suspicious pointer conversion in function HB_FUN_LV_ADDITEMS
Warning W8075 .\\HB_FUNC.PRG 778: Suspicious pointer conversion in function HB_FUN_LV_ADDITEMS
Warning W8075 .\\HB_FUNC.PRG 813: Suspicious pointer conversion in function HB_FUN_LV_ADDCOLUMN
Warning W8075 .\\HB_FUNC.PRG 942: Suspicious pointer conversion in function HB_FUN_LV_GETITEMTEXT
Warning W8075 .\\HB_FUNC.PRG 948: Suspicious pointer conversion in function HB_FUN_LV_GETITEMTEXT
Warning W8075 .\\HB_FUNC.PRG 1265: Suspicious pointer conversion in function HB_FUN_LV_INSERTCOLUMN
Warning W8075 .\\HB_FUNC.PRG 1407: Suspicious pointer conversion in function HB_FUN_LV_SETITEMTEXT
Warning W8075 .\\HB_FUNC.PRG 1601: Suspicious pointer conversion in function HB_FUN_LV_SETGRIDQUERYDATA
Warning W8075 .\\HB_FUNC.PRG 1601: Suspicious pointer conversion in function HB_FUN_LV_SETGRIDQUERYDATA

i guess it is while i have not use fw_parWide() / LPWSTR but LPTSTR

---

how to use this with Unicode
Code: Select all  Expand view  RUN
  lvi.pszText    = (TCHAR*) hb_parvc (2, 1);


Code: Select all  Expand view  RUN
   LPSTR lpText;
   char *   caption;
   ...
   for (nCol = 1; nCol < nColumnCount; nCol++)
   {
      caption  = (TCHAR*) hb_parvc (2, nCol+1) ;
      lpText = caption;
      ListView_SetItemText (hWnd, nRow, nCol, lpText );
   }
 


Code: Select all  Expand view  RUN
1599   // lstrcpyn( pDispInfo->item.pszText, ( CHAR * ) hb_parc( 2 ), pDispInfo->item.cchTextMax );
1600   LPWSTR lpText = fw_parWide( 2 );
1601   lstrcpyn( pDispInfo->item.pszText, lpText, pDispInfo->item.cchTextMax );
 


Code: Select all  Expand view  RUN
HB_FUNC( LV_GETITEMTEXT )
{
   TCHAR buffer [1024] ;
...
   lvi.pszText = buffer;
   buffer[ 0 ] = 0;
   buffer[ 1023 ] = 0;

   ListView_GetItem( hWnd, &lvi );

   hb_retc (lvi.pszText);
}

how can help me please
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1733
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Listview Unicode for CLASS TGrid()

Postby nageswaragunupudi » Wed Aug 30, 2023 2:50 pm

Question : is fw_parWide() the same as AnsiToWide() :?:

No.
if the parameter is UTF8 it uses "MultiByteToWideChar()", Windows API function and if not, then it is ANSI and uses AnsiToWide()
See:
https://learn.microsoft.com/en-us/windo ... towidechar
https://learn.microsoft.com/en-us/windo ... omultibyte

It is safer to use FWH built-in functions to make properly working Unicode library.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Listview Unicode for CLASS TGrid()

Postby nageswaragunupudi » Wed Aug 30, 2023 6:06 pm

Code: Select all  Expand view  RUN
#define UNICODE    // Made Unicode compatible 2023-07-07
#include <CommCtrl.h>
#undef UNICODE
#include "fwh.h"
 

Sole purpose of this def and undef is to get the our program defines to work with Wide structures and Wide api functions.
Beyond that we have no use for this define.


In some cases Wide api handle normal ansi strings also well.
In this small module this is enough for us.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Listview Unicode for CLASS TGrid()

Postby nageswaragunupudi » Wed Aug 30, 2023 6:08 pm

i guess it is while i have not use fw_parWide() / LPWSTR but LPTSTR

Yes.
If you like we can make the modifications.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Listview Unicode for CLASS TGrid()

Postby nageswaragunupudi » Wed Aug 30, 2023 6:11 pm

how to use this with Unicode
Code:
lvi.pszText = (TCHAR*) hb_parvc (2, 1);

can I see the full HB_FUNC?
Or you can send to me.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Listview Unicode for CLASS TGrid()

Postby Jimmy » Thu Aug 31, 2023 3:21 am

hi,
nageswaragunupudi wrote:can I see the full HB_FUNC?

you can find Source of CLASS TGrid and Hb_Func.PRG ( all "C" Code ) at
https://github.com/AugeOhr/TGRID

---

i try to learn "C" but for these "Problem" my "C" Knowledge is to small
my ANSI Version , using TCHAR / LPSTR , work but how with Unicode :?:

need some help please
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1733
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Listview Unicode for CLASS TGrid()

Postby nageswaragunupudi » Mon Sep 04, 2023 2:25 pm

i try to learn "C" but for these "Problem" my "C" Knowledge is to small

I am also still learning Sir.
We will surely assist you on this.
Please give me a little more time.
Too many things on hand right now.

Note:
This is my personal opinion. I will stand corrected if I am wrong.
I think if the application is not at all meant for East Asian Languages which are totally dependent on Unicode, better we stick to ANSI mode only ( I mean for applications meant for West European Languages only.
Only requirement for UTF8 is when writing to and reading data from Utf encoded database tables.
We have other ways of handling that.
Just an idea for you and other friends to consider.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Listview Unicode for CLASS TGrid()

Postby Jimmy » Mon Sep 04, 2023 9:53 pm

hi,

i do understand that East Asian Languages are not the biggest Problem for Fivewin

my TGrid() ANSI Version work so far but when enable LVS_OWNERDATA it does not work with FW_SetUnicode( .T. ) :(
Code: Select all  Expand view  RUN
     ::nStyle := nOR( ::nStyle, LVS_OWNERDATA )
      ::bDisplay := { | nPtrNMHDR | ::OnDISPINFO( nPtrNMHDR ) }


when set FW_SetUnicode( .T. ) it does "block" notify Event LVN_GETDISPINFO
Code: Select all  Expand view  RUN
METHOD Notify( nIdCtrl, nPtrNMHDR ) CLASS TGrid
LOCAL nCode := GetNMHDRCode( nPtrNMHDR )
LOCAL nItem := GETNMHEAITEM( nPtrNMHDR )
LOCAL nKey
LOCAL nPosi, nRow, r

STATIC nOption

   DO CASE
      CASE nCode == LVN_GETDISPINFO
         IF ::bDisplay != nil
            EVAL( ::bDisplay, nPtrNMHDR, Self )
         ENDIF

i "hope" that it work when my CLASS TGrid() is Unicode "ready" to use "virtual Grid"
it does now work only with "virtual Grid" when use FW_SetUnicode( .F. )
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1733
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 102 guests