FindReplace Dialog Unicode

FindReplace Dialog Unicode

Postby Jimmy » Wed Jul 19, 2023 6:52 am

hi,

my HB_FUNC( FINDREPLACEDLG ) ANSI Version compile without Error / Warning and work
Code: Select all  Expand view
#pragma BEGINDUMP

#include <windows.h>
#include <commctrl.h>
#include <hbapi.h>
#include <shlobj.h>
#include <tchar.h>

#define UNICODE
#ifdef UNICODE
LPWSTR AnsiToWide( LPCSTR );
LPSTR  WideToAnsi( LPWSTR );
#endif

//********************************************************************
// by Dr. Claudio Soto ( January 2014 )
//********************************************************************

static TCHAR       cFindWhat[ 1024 ];
static TCHAR       cReplaceWith[ 1024 ];
static FINDREPLACE FindReplace;
static HWND        hDlgFindReplace = NULL;

HB_FUNC( REGISTERFINDMSGSTRING )
{
   UINT MessageID = RegisterWindowMessage( FINDMSGSTRING );

   hb_retnl( ( LONG ) MessageID );
}

HB_FUNC( FINDREPLACEDLG )
{
//   HWND hWnd           = HB_ISNIL( 1 ) ? GetActiveWindow() : ( HWND ) HB_PARNL( 1 );
   HWND hWnd           = GetActiveWindow() ;
   BOOL NoUpDown       = ( BOOL ) ( HB_ISNIL( 2 ) ? FALSE : hb_parl( 2 ) );
   BOOL NoMatchCase    = ( BOOL ) ( HB_ISNIL( 3 ) ? FALSE : hb_parl( 3 ) );
   BOOL NoWholeWord    = ( BOOL ) ( HB_ISNIL( 4 ) ? FALSE : hb_parl( 4 ) );
   BOOL CheckDown      = ( BOOL ) ( HB_ISNIL( 5 ) ? TRUE  : hb_parl( 5 ) );
   BOOL CheckMatchCase = ( BOOL ) ( HB_ISNIL( 6 ) ? FALSE : hb_parl( 6 ) );
   BOOL CheckWholeWord = ( BOOL ) ( HB_ISNIL( 7 ) ? FALSE : hb_parl( 7 ) );
   BOOL lReplace       = ( BOOL ) hb_parl( 10 );

#ifndef UNICODE
   LPSTR FindWhat    = ( LPSTR ) hb_parc( 8 );
   LPSTR ReplaceWith = ( LPSTR ) hb_parc( 9 );
   LPSTR cTitle      = ( LPSTR ) hb_parc( 11 );
#else
   LPWSTR FindWhat    = AnsiToWide( ( char * ) hb_parc( 8 ) );
   LPWSTR ReplaceWith = AnsiToWide( ( char * ) hb_parc( 9 ) );
   LPWSTR cTitle      = AnsiToWide( ( char * ) hb_parc( 11 ) );
#endif

   if( hDlgFindReplace == NULL )
   {
      ZeroMemory( &FindReplace, sizeof( FindReplace ) );
// next 2 lines
      lstrcpy( cFindWhat, FindWhat );
      lstrcpy( cReplaceWith, ReplaceWith );

      FindReplace.lStructSize = sizeof( FindReplace );
      FindReplace.Flags       = ( NoUpDown  ? FR_HIDEUPDOWN : 0 ) | ( NoMatchCase    ? FR_HIDEMATCHCASE : 0 ) | ( NoWholeWord    ? FR_HIDEWHOLEWORD : 0 )
                                | ( CheckDown ? FR_DOWN : 0 ) | ( CheckMatchCase ? FR_MATCHCASE : 0 ) | ( CheckWholeWord ? FR_WHOLEWORD : 0 );
      FindReplace.hwndOwner        = hWnd;
      FindReplace.lpstrFindWhat    = cFindWhat;
      FindReplace.wFindWhatLen     = sizeof( cFindWhat ) / sizeof( TCHAR );
      FindReplace.lpstrReplaceWith = cReplaceWith;
      FindReplace.wReplaceWithLen  = sizeof( cReplaceWith ) / sizeof( TCHAR );

      if( lReplace )
         hDlgFindReplace = ReplaceText( &FindReplace );
      else
         hDlgFindReplace = FindText( &FindReplace );
// and here
      if( HB_ISCHAR( 11 ) )
         SetWindowText( hDlgFindReplace, cTitle );

      ShowWindow( hDlgFindReplace, SW_SHOW );
   }

#ifdef UNICODE
   hb_xfree( ( TCHAR * ) FindWhat );
   hb_xfree( ( TCHAR * ) ReplaceWith );
   hb_xfree( ( TCHAR * ) cTitle );
#endif
}

#pragma ENDDUMP

now when
Code: Select all  Expand view
#define UNICODE

i got these Warning
Warning W8075 HBFUNC.prg 61: Suspicious pointer conversion in function HB_FUN_FINDREPLACEDLG
Warning W8075 HBFUNC.prg 62: Suspicious pointer conversion in function HB_FUN_FINDREPLACEDLG
Warning W8075 HBFUNC.prg 79: Suspicious pointer conversion in function HB_FUN_FINDREPLACEDLG

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

Re: FindReplace Dialog Unicode

Postby Antonio Linares » Wed Jul 19, 2023 7:03 am

Dear Jimmy,

Does it work fine inspite of those warnings ?
regards, saludos

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

Re: FindReplace Dialog Unicode

Postby Jimmy » Wed Jul 19, 2023 8:22 pm

hi Antonio,
Antonio Linares wrote:Does it work fine inspite of those warnings ?

have test it and it FAIL when use #define UNICODE :(
it does not find anything any more ...
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 83 guests