News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Richedit and current line

Started by jckl, March 25, 2006, 11:40:35 PM

Previous topic - Next topic

jckl

I am tring to get the current line that the mouse cursor is on using the EN_SELCHANGE notification and everything there seems fine but using my code to get the current line will not add 1 to the line index if i dont type on the new line.. For example if i am on line 5 and i hit enter to go to line 6 and i dont type anything then i will still get the line index as 5. If i hit a key then the index will increase 1. This should not be this way tho and i was wondering if someone could tell me how to fix this. my code to get the current line is below..


invoke SendMessage, hwndRichEdit, EM_LINEFROMCHAR, -1, 0

anon

I used the same method that you are using, and it works OK for me.
Did you use EM_SETEVENTMASK ? Not sure if it is the problem as it has
been quit some time since I worked with Richedit. These are the masks
I used :

invoke SendMessage,hRichEdit,EM_SETEVENTMASK,0,ENM_MOUSEEVENTS or ENM_CHANGE or ENM_SELCHANGE or ENM_KEYEVENTS

jckl

yours didnt count the lines like mine is??? Also i used different options for mine since i dont use all the ones you do.. here is mine..

invoke SendMessage, hwndRichEdit, EM_SETEVENTMASK, 0, ENM_SELCHANGE or ENM_MOUSEEVENTS

anon

Yes, mine counts lines the same way you do.
You should try adding ENM_CHANGE and ENM_KEYEVENTS just to cover all the bases.

jckl

i did and it did nothing..

If you only hit enter 1 time your line count will increase?? meaning there is nothing on the next line where the cursor is???  The only thing i can think of is to try and use charfrompos and then linefromchar but i dont know if i will get the same result.

jckl

well when tring my last idea i found that it has the same problem.. :'(

anon

If you only hit enter 1 time your line count will increase??   YES
meaning there is nothing on the next line where the cursor is???   YES

invoke SendMessage, hwndRichEdit, EM_LINEFROMCHAR, -1, 0

This method WILL work. I am not sure what is going wrong with your
code. Does the  line count work properly in a line with text in it ?

jckl

yes it works if i type something.

jckl

do you have that in EN_SELCHANGE or EN_CHANGE?  Maybe thats my problem.

jckl

I figured out my Problem... It was because i had changed it to simple line break.  :dance:

Thanks for all the input..

anon

Glad to hear you fixed it  :clap:
I was only using EN_SELCHANGE.