Page 1 of 1

How to find and replace a Word in RTF File using DCRTF

Posted: Fri Apr 30, 2021 10:35 am
by digitsoft
Hello Roger
How to find and replace a Word in RTF File using DCRTF

Re: How to find and replace a Word in RTF File using DCRTF

Posted: Sat May 01, 2021 1:10 pm
by rdonnay
DCRTF is simply a command interface to the Xbase++ class XbpRtf.

I have never used it. It inherits from Microsoft's RTF editor class.
Sorry, I don't have an answer for you.

Re: How to find and replace a Word in RTF File using DCRTF

Posted: Sun May 02, 2021 5:58 pm
by Auge_Ohr
hi,

as i know ActiveX of Rich32.OCX is limited and have no "FindReplace" Function.

i wonder why Alaska still use ActiveX for "Controls" as all can be done "native".

---

you can try EM_FINDTEXTEX
https://docs.microsoft.com/de-de/window ... findtextex

Code: Select all

SendMessage ( hWndControl, EM_FINDTEXTEX,  (WPARAM) Options, (LPARAM) &FindText )

Code: Select all

FUNCTION RichEditBox_ReplaceText( hWndControl, cFind, cReplace, lMatchCase, lWholeWord, lSelectFindText )
LOCAL lDown := .T.
LOCAL aPos  := { 0, 0 }
   aPos := RichEditBox_GetSelRange( hWndControl )
   RichEditBox_SetSelRange( hWndControl, { aPos[ 1 ], aPos[ 1 ] } )
   aPos := RichEditBox_FindText( hWndControl, cFind, lDown, lMatchCase, lWholeWord, lSelectFindText )
   IF aPos[ 1 ] <> - 1
      RichEditBox_SetSelRange( hWndControl, aPos )
      RichEditBox_SetText( hWndControl, .T., cReplace )
      aPos := RichEditBox_FindText( hWndControl, cFind, lDown, lMatchCase, lWholeWord, lSelectFindText )
   ENDIF
RETURN aPos

Re: How to find and replace a Word in RTF File using DCRTF

Posted: Fri May 07, 2021 1:52 pm
by digitsoft
Hi jimmy
You can give me an example of how to do it because I can't compile the example without errors

Thanks.

Re: How to find and replace a Word in RTF File using DCRTF

Posted: Fri May 07, 2021 8:10 pm
by Auge_Ohr
hi,

as i say Xbase++ use ActiveX for RTF and have NO "find/replace"
you have to write your own Code, than you can try the Code which i show you.

it does work with "native" RTF Control (RichEdit20A) like in my DXE LIB (using Ot4xb)
it use Riched20.dll like harbour / HMG where "that" Code work

! Note : Sample is for Xbase++ v1.9x and include SOURCE of XBP_RTF.PRG using Ot4xb
EDITOR.zip
v1.9.355 using Ot4xb
(957.85 KiB) Downloaded 527 times
p.s. Riched20.dll is also available under 64 Bit
---

Alaska have introduce ActiveX Technique 2008 when Microsoft have stopped Support for ActiveX.
since Windows 7 does NOT have anymore those ActiveX "on-Board" so when (re)install it you brake Rule

i wonder that Alaska is still using ActiveX for controls and no Xbase++ User is protesting against it.
Microsoft have stop it for Security Reason while it is no safe :!:

Re: How to find and replace a Word in RTF File using DCRTF

Posted: Fri May 14, 2021 12:05 pm
by digitsoft
The selected attachment does not exist anymore.

Re: How to find and replace a Word in RTF File using DCRTF

Posted: Fri May 14, 2021 12:55 pm
by Auge_Ohr
hi,
digitsoft wrote: Fri May 14, 2021 12:05 pm The selected attachment does not exist anymore.
it work for me.

but i must agree that "often" i got Message "file not found" in this Forum ...
it might help to delete all Cookies.