Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RTF Highlight command 1

Status
Not open for further replies.

Koen Piller

Programmer
Jun 30, 2005
841
NL
Hi,

With RTF you can search and highlight for words in your RTF-text. However the highlight function is not as the default highlight in Word or Excel: it changes the forecolor to a given color and not the backcolor. Anybody to give me the code to change the highlight to true highlight?

I am using these procedures now:
Code:
PROCEDURE SEARCHIT
* cmd Search

Local ;
	lcFindExpression As String, ;
	liExpressionFound As Integer


If Empty(Thisform.Text1.Value)
	Return
Endif

With Thisform
	m.lcFindExpression = Alltrim(.Text1.Value)

	m.liExpressionFound = .oleDetails.Find(m.lcFindExpression ,0, -1)
	If m.liExpressionFound >-1
		.nStart = m.liExpressionFound + 1
	Endif
Endwith
ENDPROC

PROCEDURE SEARCHALL
Local ;
	lcExpressionSought As String, ;
	liFound As Integer

If Empty(Thisform.Text1.Value)
	Return
Endif

m.lcExpressionSought = Alltrim(Thisform.Text1.Value)

With Thisform
	.nStart = 0
	m.liFound = 0
	Do While m.liFound >=0
		m.liFound = .oleDetails.Find(m.lcExpressionSought ,.nStart, -1)
		If m.liFound >-1
			.nStart = m.liFound + 1
* highlight it
			.oleDetails.SelColor = Rgb(255,0,0)  &&red
			.oleDetails.SelBold = .T.
		Else
			Exit
		Endif
	Enddo
Endwith
ENDPROC

Anyone who has the code to change the highlight to as it should be?

Stay healthy,
Koen
 
I have a custom framework for my applications that I have created. I don't want to just zip the whole directory and send. My intent was to give you the code as an example and not has a fully working application. I believe that I have sufficiently sent you the code needed to make what you wanted to work. It was to just highlight the found text. You have the classes and code to support this.
 
Greg,
Thanks, but if you dont want to supply the minimum of files I need to run your example then I wont be able to run.
Surely I dont want your the whole directory, jut the files needed.
Stay healthy,
Koen
 
It was not my intention to provide a running example -- only the code that you need to use to make your need work... I expected that you would be able to place into your own forms/classes and adapt it.
 
Greg,
I understand, however I cannot adapt your code to my class: too many important files, which I cannot invent/construct myself are missing.
I do understand your situation and thank you for your time and effort.
It forces me to look around further for an working example.
Stay healthy,
Koen
 
Koen--

Attached is a simple working example. Enter the text in the textbox to highlight...

Sorry -- I missed that the DeclareDLL was already in my SET PROCEDURE to path when I was testing. It is now fixed in the updated attachment.

Greg
 
 https://files.engineering.com/getfile.aspx?folder=b8c4412f-232e-4642-ad53-7397bf303d52&file=Example.zip
Greg,

Thank you, works like a charm. I will now convert and add this to my RTFEdit class
Stay healthy,
Koen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top