FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Search in Richedit5
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Search in Richedit5
Posted: Fri Aug 04, 2023 09:29 AM

Hi,

In Richedit5, I need to find some phrase and color it red. How do I do this?

Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Search in Richedit5
Posted: Sat Aug 05, 2023 09:17 AM
Marc Venken

Using: FWH 23.08 with Harbour
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Search in Richedit5
Posted: Sat Aug 05, 2023 11:31 AM
As I understand it, you can change the color of a text fragment in RichEdit5 like this:
Code (fw): Select all Collapse
method Colorize(nStart, nEnd, nColor)
However, I didn't understand how to find this fragment in RichEdit5 :(
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Search in Richedit5
Posted: Sat Aug 05, 2023 03:09 PM

Dear Yuri,

METHOD Find( cFind, lDown, lCase, lWord ) CLASS TRichEdit5

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Search in Richedit5
Posted: Sat Aug 05, 2023 03:17 PM

Thanks !

Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Search in Richedit5
Posted: Sat Aug 05, 2023 09:57 PM
hi,

as i can say Fivewin have HB_FUNC( FINDTEXT ) but not HB_FUNC( REPLACETEXT )
but all Structure are in c:\fwh\source\winapi\findtext.c

---

under HMG i have this
Code (fw): Select all Collapse
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 );
}
Code (fw): Select all Collapse
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 ) );

      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 );

      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

   #ifndef _WIN64
    hb_retnl( ( LONG ) hDlgFindReplace );
   #else
    hb_retnll( ( LONGLONG ) hDlgFindReplace );
   #endif
}
Code (fw): Select all Collapse
HB_FUNC( FINDREPLACEDLGISRELEASE )
{
   hb_retl( ( BOOL ) ( hDlgFindReplace == NULL ) );
}
Code (fw): Select all Collapse
HB_FUNC( FINDREPLACEDLGRELEASE )
{
   BOOL lDestroy = HB_ISNIL( 1 ) ? TRUE : hb_parl( 1 );

   if( hDlgFindReplace != NULL && lDestroy )
      DestroyWindow( hDlgFindReplace );
   hDlgFindReplace = NULL;
}
Code (fw): Select all Collapse
HB_FUNC( FINDREPLACEDLGGETOPTIONS )
{
   #ifndef _WIN64
      LPARAM lParam = (LPARAM) hb_parnl (1);
   #else
      LPARAM lParam = (LPARAM) hb_parnll (1);
   #endif
   FINDREPLACE *FR = (FINDREPLACE *) lParam;
   LONG nRet = -1;
//   LPSTR pStr;

   if ( FR->Flags & FR_DIALOGTERM )
       nRet =  0;

   if ( FR->Flags & FR_FINDNEXT )
       nRet =  1;

   if ( FR->Flags & FR_REPLACE )
       nRet =  2;

   if ( FR->Flags & FR_REPLACEALL )
       nRet =  3;

   hb_reta (6);

   hb_storvnl ( (LONG) nRet,                       -1,  1 );

   #ifndef UNICODE
      hb_storvc (  FR->lpstrFindWhat,              -1,  2 );
      hb_storvc (  FR->lpstrReplaceWith,           -1,  3 );
   #else
       LPSTR pStr = WideToAnsi( FR->lpstrFindWhat );
      hb_storvc (  pStr,                           -1,  2 );
      pStr = WideToAnsi( FR->lpstrReplaceWith );
      hb_storvc (  pStr,                           -1,  3 );
   #endif

   hb_storvl  ( (BOOL) (FR->Flags & FR_DOWN),      -1,  4 );
   hb_storvl  ( (BOOL) (FR->Flags & FR_MATCHCASE), -1,  5 );
   hb_storvl  ( (BOOL) (FR->Flags & FR_WHOLEWORD), -1,  6 );
}
greeting,

Jimmy
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Search in Richedit5
Posted: Sun Aug 06, 2023 09:37 AM
Jimmy, what does RichEdit5 have to do with it ? :wink:
I tried both :Find() and :Search() - unsuccessfully
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Search in Richedit5
Posted: Sun Aug 06, 2023 05:10 PM

Please indicate the string you are looking for

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Search in Richedit5
Posted: Sun Aug 06, 2023 06:14 PM
A string of Cyrillic characters
File:
https://cloud.mail.ru/public/RLAk/Hyk87nTv4
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Search in Richedit5
Posted: Sun Aug 06, 2023 11:09 PM
hi,
Natter wrote:Jimmy, what does RichEdit5 have to do with it ?
HMG CODE work with RTF or TXT using
Code (fw): Select all Collapse
     if( lReplace )
         hDlgFindReplace = ReplaceText( &FindReplace );
      else
         hDlgFindReplace = FindText( &FindReplace );
---

i´m not sure about Fivewin HB_FUNC( FINDTEXT ) if it work with UNICODE ... have not test it yet
but i know that HMG Version does work with German "Umlaute"
greeting,

Jimmy

Continue the discussion