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

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
digitsoft
Posts: 451
Joined: Thu Jan 28, 2010 1:33 pm
Location: Republica Dominicana
Contact:

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

#1 Post by digitsoft »

Hello Roger
How to find and replace a Word in RTF File using DCRTF
Nolberto Paulino
Regards

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

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

#2 Post 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.
The eXpress train is coming - and it has more cars.

User avatar
Auge_Ohr
Posts: 1407
Joined: Wed Feb 24, 2010 3:44 pm

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

#3 Post 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
greetings by OHR
Jimmy

User avatar
digitsoft
Posts: 451
Joined: Thu Jan 28, 2010 1:33 pm
Location: Republica Dominicana
Contact:

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

#4 Post 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.
Nolberto Paulino
Regards

User avatar
Auge_Ohr
Posts: 1407
Joined: Wed Feb 24, 2010 3:44 pm

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

#5 Post 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 379 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 :!:
greetings by OHR
Jimmy

User avatar
digitsoft
Posts: 451
Joined: Thu Jan 28, 2010 1:33 pm
Location: Republica Dominicana
Contact:

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

#6 Post by digitsoft »

The selected attachment does not exist anymore.
Nolberto Paulino
Regards

User avatar
Auge_Ohr
Posts: 1407
Joined: Wed Feb 24, 2010 3:44 pm

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

#7 Post 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.
greetings by OHR
Jimmy

Post Reply