Code: Select all
METHOD Add( cItem, nAt ) CLASS TListBox
DEFAULT nAt := Len( ::aItems )
cItem = FW_AnsiToWide( cItem ) // New !!!
if nAt == Len( ::aItems )
AAdd( ::aItems, cItem )
::SendMsg( LB_ADDSTRING, 0, cItem )
else
ASize( ::aItems, Len( ::aItems ) + 1 )
AIns( ::aItems, nAt + 1 )
::aItems[ nAt + 1 ] = cItem
::SendMsg( LB_INSERTSTRING, nAt, cItem )
endif
::SendMsg( LB_SETCURSEL, nAt )
return nil
And add this function to listbox.prg:
Code: Select all
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
LPWSTR AnsiToWide( char * );
HB_FUNC( FW_ANSITOWIDE )
{
LPWSTR pW = AnsiToWide( hb_parc( 1 ) );
int iLen = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, hb_parc( 1 ), -1, 0, 0 );
hb_retclen( ( char * ) pW, ( hb_parclen( 1 ) * 2 ) + 1 );
hb_xfree( pW );
}
#pragma ENDDUMP