Page 1 of 1

Required Fix for Class TListBox and TComboBox

Posted: Sun Feb 01, 2009 9:36 pm
by Antonio Linares
In Method Add() please add this line:

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
Replace all calls to AnsiToWide() in listbox.prg with FW_AnsiToWide()

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

Re: Required Fix for Class TListBox and TComboBox

Posted: Sun Feb 01, 2009 10:08 pm
by Antonio Linares
The same fix is required for Class TComboBox: (source\classes\combobox.prg)

1. Replace all calls to AnsiToWide() with FW_AnsiToWide()

2. If you already added HB_FUNC( FW_ANSITOWIDE ) in listbox.prg then don't add it to combobox.prg

Re: Required Fix for Class TListBox and TComboBox

Posted: Sun Feb 01, 2009 11:07 pm
by Antonio Linares
You can modify, compile and replace modules in the FWPPC libraries, this way:

go.bat

Code: Select all

c:\harbour_ce\bin\harbour classes\listbox.prg /L /N /W /D__FWCE__  /I..\include;c:\harbour_ce\include
c:\harbour_ce\bin\harbour classes\combobox.prg /L /N /W /D__FWCE__  /I..\include;c:\harbour_ce\include
c:\vce\bin\clarm -c -TP /DARM /DUNICODE -Ic:\harbour_ce\include -Ic:\vce\include\arm listbox.c
c:\vce\bin\clarm -c -TP /DARM /DUNICODE -Ic:\harbour_ce\include -Ic:\vce\include\arm combobox.c
c:\vce\bin\lib ..\lib\Fivece.lib /remove:objce\LISTBOX.obj
c:\vce\bin\lib ..\lib\Fivece.lib /remove:objce\COMBOBOX.obj
c:\vce\bin\Lib ..\lib\Fivece.lib /OUT:..\lib\Fivece.lib listbox.obj
c:\vce\bin\Lib ..\lib\Fivece.lib /OUT:..\lib\Fivece.lib combobox.obj

Re: Required Fix for Class TListBox and TComboBox

Posted: Sun Feb 01, 2009 11:31 pm
by Antonio Linares
We have just published a new FWPPC 9.01 build with these changes :-)

Re: Required Fix for Class TListBox and TComboBox

Posted: Mon Feb 02, 2009 11:29 am
by Antonio Linares
Important:

clarm flag -TP should not be used as we don't want C++ mode