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
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
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
Yes, mine counts lines the same way you do.
You should try adding ENM_CHANGE and ENM_KEYEVENTS just to cover all the bases.
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.
well when tring my last idea i found that it has the same problem.. :'(
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 ?
yes it works if i type something.
do you have that in EN_SELCHANGE or EN_CHANGE? Maybe thats my problem.
I figured out my Problem... It was because i had changed it to simple line break. :dance:
Thanks for all the input..
Glad to hear you fixed it :clap:
I was only using EN_SELCHANGE.