Board index » cppbuilder » TRichEdit detecting font attributes under cursor

TRichEdit detecting font attributes under cursor

I am trying to detect not the text, but the text attributes under the mouse
cursor in a TRichEdit.

I assume that this is possible, but I cannot find any method in Delphi or in
the API that seems to do this.

At the moment I am using a cheat by having a second and hidden TRichEdit.
First I detect the position of the text under the cursor then I copy the
whole of the text to the hidden richedit and then I move the cursor in the
hidden richedit accordingly.  In this way, I can detect the text attributes
of the second richedit.  This seems to work well enough and is very fast
even in large text documents.  But it seems to me to be a lot of work for
something that should really be quite simple.

I am trying to achieve the same effect as the cursor passing over a
hypertext link as you see in various wordprocessing packages.

Can anyone help please.

Mark Williams

 

Re:TRichEdit detecting font attributes under cursor


Hi, Mark.

Quote
Mark Williams wrote:

> I am trying to detect not the text, but the text attributes under the mouse
> cursor in a TRichEdit.

> I assume that this is possible, but I cannot find any method in Delphi or in
> the API that seems to do this.

> At the moment I am using a cheat by having a second and hidden TRichEdit.
> First I detect the position of the text under the cursor then I copy the
> whole of the text to the hidden richedit and then I move the cursor in the
> hidden richedit accordingly.  In this way, I can detect the text attributes
> of the second richedit.  This seems to work well enough and is very fast
> even in large text documents.  But it seems to me to be a lot of work for
> something that should really be quite simple.

> I am trying to achieve the same effect as the cursor passing over a
> hypertext link as you see in various wordprocessing packages.

I just happened to be working on a similar problem over the last several
days and I think I have a better way, at least if you are using RE 2.0.

The Text Object Model (TOM) OLE interfaces are supported by Rich Edit
2.0+.  They include methods that, if they are actually implemented in RE
controls should provide a way to get the formatting of text in an
arbitrary location.  (Note, some interface methods are not implemented,
but the only way I know to find out is to code it and try it.)  They
also include methods that allow you to track the current location of a
range of text, say, the hyperlinks, while the user is editing the text.

See Microsoft's developer site for TOM information.  See
http://home.att.net/~robertdunn/Yacs.html for information on getting the
RE 3.0 DLL and RE controls generally.

HTH.

robert

--
Robert Dunn
http://home.att.net/~robertdunn/Yacs.html
mailto: robertSPAMMENOTd...@worldnet.att.net
(Please remove "SPAMMENOT" from return address)

Re:TRichEdit detecting font attributes under cursor


Robert

Thanks for your help.   I will check out the Microsoft site and post
anything I find.

Mark Williams

Quote
Robert Dunn <robertSPAMMENOTd...@worldnet.att.net> wrote in message

news:3CCCBDFD.FE2547F1@worldnet.att.net...
Quote
> Hi, Mark.

> Mark Williams wrote:

> > I am trying to detect not the text, but the text attributes under the
mouse
> > cursor in a TRichEdit.

> > I assume that this is possible, but I cannot find any method in Delphi
or in
> > the API that seems to do this.

> > At the moment I am using a cheat by having a second and hidden
TRichEdit.
> > First I detect the position of the text under the cursor then I copy the
> > whole of the text to the hidden richedit and then I move the cursor in
the
> > hidden richedit accordingly.  In this way, I can detect the text
attributes
> > of the second richedit.  This seems to work well enough and is very fast
> > even in large text documents.  But it seems to me to be a lot of work
for
> > something that should really be quite simple.

> > I am trying to achieve the same effect as the cursor passing over a
> > hypertext link as you see in various wordprocessing packages.

> I just happened to be working on a similar problem over the last several
> days and I think I have a better way, at least if you are using RE 2.0.

> The Text Object Model (TOM) OLE interfaces are supported by Rich Edit
> 2.0+.  They include methods that, if they are actually implemented in RE
> controls should provide a way to get the formatting of text in an
> arbitrary location.  (Note, some interface methods are not implemented,
> but the only way I know to find out is to code it and try it.)  They
> also include methods that allow you to track the current location of a
> range of text, say, the hyperlinks, while the user is editing the text.

> See Microsoft's developer site for TOM information.  See
> http://home.att.net/~robertdunn/Yacs.html for information on getting the
> RE 3.0 DLL and RE controls generally.

> HTH.

> robert

> --
> Robert Dunn
> http://home.att.net/~robertdunn/Yacs.html
> mailto: robertSPAMMENOTd...@worldnet.att.net
> (Please remove "SPAMMENOT" from return address)

Other Threads