Re: Find The Text :-)




"Mike Williams" <mikea@xxxxxxxxxxxxxxxxx> wrote in message
news:uJqCUWPzHHA.1168@xxxxxxxxxxxxxxxxxxxxxxx
"Ivar" <Ivar.ekstromer000@xxxxxxx> wrote in message
news:5iQoi.638$mZ5.378@xxxxxxxxxxxxxxxxxxxxxxx

In that case you're just gonna' have to do it the hard way ;-)
Don't I all ways:-) Anyway, I've been playing with a few ideas, and I'm
getting there. My little prob seems quite easy IF: Text is left aligned and
the text to find is on one line.
Highlighting text on multiple lines just requires more work but quite
posible, but Center and right aligned text (I won't bother with justified
text) is causing a small (and I mean small) problem. I think the problem is
that VB is telling me lies.
Here's a small code snippet: I'm sure you can get this code to work.

Private Sub Command1_Click()
Dim S As String, R As RECT
Dim RetVal As Integer
S = "Basic programming and introduces a variety of features."
SetRect R, 0, 0, 260, 13
DrawText Me.hdc, S, Len(S), R, DT_LEFT
Me.Refresh
RetVal = TextWidth(S)
End Sub

The forms font is MS Sans Serif, Regular, size 8 (the default font on my
system)
On my system Retval = 261, but the text will print on the form even though
it has a Rect that is 260 wide.
Either the text cannot fit in the allowed area (but it does) or TextWidth is
telling lies
This small thing is causing problems :-(

Any ideas what's going wrong?

Ivar

P.S. You said you were having probs with "EM_POSFROMCHAR" I could not get it
to work either until I started to pass wParam and lParam both ByVal. will
that fix it for you?

Example
RetVal = SendMessage(Text1.hwnd, EM_POSFROMCHAR, ByVal StrPos, ByVal 0)


.