hello!

I've a problem with receiving the line-index of the current sel-position in a richedit. I did it this way:

Call SendMessageA, hRichEdit, EM_LINEFROMCHAR, -1, 0
Inc eax

but if the selection is in the last line and in this line aren't any chars typed then eax has the number of the line before!

It would be nice if some coders who already did such a function can help me!

Cheers!
Posted on 2002-02-22 12:51:42 by Rennsemmel
first off you should be using EM_EXLINEFROMCHAR and not EM_LINEFROMCHAR.

EM_LINEFROMCHAR was designed for multiline editboxes

EM_EXLINEFROMCHAR was designed for richedit
Posted on 2002-02-22 13:01:49 by smurf
thanks for this tip...
unfortunately this doesn't fix the bug!

| Hello | <-- lineindex 1
| how are you? | <-- lineindex 2
| | <-- lineindex 2, too!

to visualize my problem...

anyone else can help me?
Posted on 2002-02-22 13:22:09 by Rennsemmel
well i know you want help from someone who has done this before, but you will at least get some ideas from me in the mean time.:grin: anyways have you tried EM_LINEINDEX yet?
Posted on 2002-02-22 13:46:59 by smurf
first: I am happy for every answer!

I tried this:

First I set EM_SETEVENTMASK with ENM_SELCHANGE as lParam

Then I handle WM_NOTIFY and check for EN_SELCHANGE.
If so, I call EM_EXLINEFROMCHAR with lParam = -1

It works fine until the sel reaches the very last line...
if in this line is NOTHING entered, then the returnvalue gives me the lineindex of the line before the last line.

I also tied it with EM_LINEFROMCHAR and EM_EXLINEFROMCHAR
with same results!
Posted on 2002-02-22 14:11:36 by Rennsemmel
I think, this feature is by design.
Its difficult to sort the newline character in the sequence of chars,
either it belongs as last char to the old line, or as first to the new line.
In richedit it seems to be the first case.
Posted on 2002-02-25 03:39:06 by beaster
Hi Rennsemmel
invoke SendMessage,hWin,EM_EXGETSEL,0,addr chrg

invoke SendMessage,hWin,EM_EXLINEFROMCHAR,0,chrg.cpMin
inc eax
mov Line,eax

Works well

KetilO
Posted on 2002-02-25 04:36:11 by KetilO