Hi,
In Richedit5, I need to find some phrase and color it red. How do I do this?
method Colorize(nStart, nEnd, nColor)
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 ) );
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
}
HB_FUNC( FINDREPLACEDLGISRELEASE )
{
hb_retl( ( BOOL ) ( hDlgFindReplace == NULL ) );
}
HB_FUNC( FINDREPLACEDLGRELEASE )
{
BOOL lDestroy = HB_ISNIL( 1 ) ? TRUE : hb_parl( 1 );
if( hDlgFindReplace != NULL && lDestroy )
DestroyWindow( hDlgFindReplace );
hDlgFindReplace = NULL;
}
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 );
}
Natter wrote:Jimmy, what does RichEdit5 have to do with it ?
if( lReplace )
hDlgFindReplace = ReplaceText( &FindReplace );
else
hDlgFindReplace = FindText( &FindReplace );
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 107 guests