Search in Richedit5

Search in Richedit5

Postby Natter » Fri Aug 04, 2023 9:29 am

Hi,

In Richedit5, I need to find some phrase and color it red. How do I do this?
Natter
 
Posts: 1222
Joined: Mon May 14, 2007 9:49 am

Re: Search in Richedit5

Postby Marc Venken » Sat Aug 05, 2023 9:17 am

Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1437
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Search in Richedit5

Postby Natter » 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: Select all  Expand view  RUN
method Colorize(nStart, nEnd, nColor)

However, I didn't understand how to find this fragment in RichEdit5 :(
Natter
 
Posts: 1222
Joined: Mon May 14, 2007 9:49 am

Re: Search in Richedit5

Postby Antonio Linares » Sat Aug 05, 2023 3:09 pm

Dear Yuri,

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

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

Re: Search in Richedit5

Postby Natter » Sat Aug 05, 2023 3:17 pm

Thanks !
Natter
 
Posts: 1222
Joined: Mon May 14, 2007 9:49 am

Re: Search in Richedit5

Postby Jimmy » Sat Aug 05, 2023 9: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: Select all  Expand view  RUN
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: Select all  Expand view  RUN
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: Select all  Expand view  RUN
HB_FUNC( FINDREPLACEDLGISRELEASE )
{
   hb_retl( ( BOOL ) ( hDlgFindReplace == NULL ) );
}

Code: Select all  Expand view  RUN
HB_FUNC( FINDREPLACEDLGRELEASE )
{
   BOOL lDestroy = HB_ISNIL( 1 ) ? TRUE : hb_parl( 1 );

   if( hDlgFindReplace != NULL && lDestroy )
      DestroyWindow( hDlgFindReplace );
   hDlgFindReplace = NULL;
}

Code: Select all  Expand view  RUN
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
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Search in Richedit5

Postby Natter » Sun Aug 06, 2023 9:37 am

Jimmy, what does RichEdit5 have to do with it ? :wink:
I tried both :Find() and :Search() - unsuccessfully
Natter
 
Posts: 1222
Joined: Mon May 14, 2007 9:49 am

Re: Search in Richedit5

Postby cnavarro » Sun Aug 06, 2023 5: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
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Search in Richedit5

Postby Natter » Sun Aug 06, 2023 6:14 pm

A string of Cyrillic characters
File:
https://cloud.mail.ru/public/RLAk/Hyk87nTv4
Natter
 
Posts: 1222
Joined: Mon May 14, 2007 9:49 am

Re: Search in Richedit5

Postby Jimmy » 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: Select all  Expand view  RUN
    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
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: No registered users and 63 guests