Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Emerson Reed
  Where is Emerson Reed?
 Americana - SP
 Brazil
 Emerson Reed
 To: Jirí Bureš
  Where is Jirí Bureš?
 Prag
 Czech Republic
 Jirí Bureš
 Tags
Subject: RE: RichText - position in the text
Thread ID: 373635 Message ID: 373690 # Views: 46 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Windows 7 and VFP
Date: Monday, March 25, 2013 1:01:32 PM         
   


> Anybody got any idea how to find a position in an RTF file. If the text click on any place in the text so this place (eg beginning of a word) found using SELSTART but how do I know where the word begins in RTF "code" when you insert sequences of course, thanks for the format, etc., the initial position of other words. Thank you for your answer
> J. Bures

Hi Jirí.
Try the following code:

Local lnCurrentPosition, lnCurrentLine, ;
   lnLine, lnColumn
m.lnCurrentPosition = This.oleRTF.SelStart
m.lnCurrentLine = This.oleRTF.GetLineFromChar(m.lnCurrentPosition)
If m.lnCurrentLine = 0
   m.lnColumn = m.lnCurrentPosition
Else
   Local lnStartPosition
   m.lnStartPosition = m.lnCurrentPosition
   Do While This.oleRTF.GetLineFromChar(m.lnCurrentPosition) = m.lnCurrentLine
      m.lnCurrentPosition = m.lnCurrentPosition - 1
   Enddo
   m.lnColumn = m.lnStartPosition - m.lnCurrentPosition - 1
Endif
m.lnLine = m.lnCurrentLine
? "Line", Alltrim(Transform(m.lnLine+1,"999,999,999,999,999,999")), ;
   "Column", Alltrim(Transform(m.lnColumn+1,"999,999,999,999,999,999"))

I've placed this code in a method that is called from Init method from my form and from SelChange method of my rtf control.

Emerson Santon Reed
"One Developer CAN Make a Difference. A community CAN make a future." - Craig Boyd

ENTIRE THREAD

RichText - position in the text Posted by Jirí Bureš @ 3/24/2013 3:42:44 PM
RE: RichText - position in the text Posted by Rick Hodgin @ 3/24/2013 3:58:25 PM
RE: RichText - position in the text Posted by Jirí Bureš @ 3/24/2013 4:10:08 PM
RE: RichText - position in the text Posted by Emerson Reed @ 3/25/2013 1:01:32 PM
RE: RichText - position in the text Posted by Cetin Basoz @ 3/25/2013 1:10:51 PM