Need to get X,Y coordinates of word within text. 
Author Message
 Need to get X,Y coordinates of word within text.

I'm drawing text onto a DC using the DrawText API.  The text is variable in
length and may span multiple lines.  I need to be able to figure out the X,Y
coordinates of a word within the text.  For instance:

Let's assume that
this is my text.

I would need to know the X,Y coordinates of the word "my".

Anyone know how to do this?

-jef



Sat, 26 Feb 2005 22:28:29 GMT  
 Need to get X,Y coordinates of word within text.

Quote:
> I'm drawing text onto a DC using the DrawText API.  The text is variable
in
> length and may span multiple lines.  I need to be able to figure out the
X,Y
> coordinates of a word within the text.  For instance:

> Let's assume that
> this is my text.

> I would need to know the X,Y coordinates of the word "my".

Sounds like you want to have a play with the GetCharacterPlacement() or
GetTextExtentPoint32() API calls.
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/




Sun, 27 Feb 2005 00:04:45 GMT  
 Need to get X,Y coordinates of word within text.
Mike,
It seems (as far as I can tell) that these API's work with a single line of
text.  Not multiple lines. Any other ideas?
-jef



Quote:
> > I'm drawing text onto a DC using the DrawText API.  The text is variable
> in
> > length and may span multiple lines.  I need to be able to figure out the
> X,Y
> > coordinates of a word within the text.  For instance:

> > Let's assume that
> > this is my text.

> > I would need to know the X,Y coordinates of the word "my".

> Sounds like you want to have a play with the GetCharacterPlacement() or
> GetTextExtentPoint32() API calls.
> Hope this helps,

>     Mike

>  -- EDais --

>  - Microsoft Visual Basic MVP -
> WWW: Http://EDais.earlsoft.co.uk/





Sun, 27 Feb 2005 00:55:59 GMT  
 Need to get X,Y coordinates of word within text.

Quote:
> It seems (as far as I can tell) that these API's work with a single line
of
> text.  Not multiple lines. Any other ideas?

I've never really experimented much in the area, however this section in the
MSDN may reveal some useful hints:
http://msdn.microsoft.com/library/en-us/gdi/fontext_8ctw.asp
I'll keep looking here too and let you know what I come up with.
Have you tried the afore mentioned calls with multi-line text?
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/




Sun, 27 Feb 2005 01:34:58 GMT  
 Need to get X,Y coordinates of word within text.

writes

Quote:
>I'm drawing text onto a DC using the DrawText API.  The text is variable in
>length and may span multiple lines.  I need to be able to figure out the X,Y
>coordinates of a word within the text.  For instance:

>Let's assume that
>this is my text.

>I would need to know the X,Y coordinates of the word "my".

I'm not clear about the question.

Would not the X,Y coords would be taken from the start of "this" so the
offset coords are given by GetTextExtentPoint32 with the string
"this is ", or are you saying that you don't know where the line
break(s) are coming?

Instead of GetTextExtent32 you get the same results for width/height
from an autosized Label.

--
Richard Mason



Sun, 27 Feb 2005 11:08:55 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. getting text out of a word text file

2. How do I coordinate the screen's coordinates with a form coordinate

3. Find actual coordinates of a control within another control

4. Coordinates Within a Polygon

5. Getting formatted text from Word into Richtextbox

6. Getting Text from a word doc

7. getting text from Excel to Word by VBA

8. getting text width in word (vba)

9. getting text width in word (vba)

10. Getting/Setting a Forms Window Coordinates

11. Getting coordinates to set mousepointer

12. Getting Mouse Coordinates

 

 
Powered by phpBB® Forum Software