The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: jckl on March 25, 2006, 11:40:35 PM

Title: Richedit and current line
Post by: jckl on March 25, 2006, 11:40:35 PM
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
Title: Re: Richedit and current line
Post by: anon on March 26, 2006, 12:26:16 AM
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
Title: Re: Richedit and current line
Post by: jckl on March 26, 2006, 12:32:52 AM
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
Title: Re: Richedit and current line
Post by: anon on March 26, 2006, 12:44:11 AM
Yes, mine counts lines the same way you do.
You should try adding ENM_CHANGE and ENM_KEYEVENTS just to cover all the bases.
Title: Re: Richedit and current line
Post by: jckl on March 26, 2006, 12:49:24 AM
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.
Title: Re: Richedit and current line
Post by: jckl on March 26, 2006, 12:56:07 AM
well when tring my last idea i found that it has the same problem.. :'(
Title: Re: Richedit and current line
Post by: anon on March 26, 2006, 01:01:06 AM
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 ?
Title: Re: Richedit and current line
Post by: jckl on March 26, 2006, 01:05:08 AM
yes it works if i type something.
Title: Re: Richedit and current line
Post by: jckl on March 26, 2006, 01:08:35 AM
do you have that in EN_SELCHANGE or EN_CHANGE?  Maybe thats my problem.
Title: Re: Richedit and current line
Post by: jckl on March 26, 2006, 01:13:32 AM
I figured out my Problem... It was because i had changed it to simple line break.  :dance:

Thanks for all the input..
Title: Re: Richedit and current line
Post by: anon on March 26, 2006, 01:17:20 AM
Glad to hear you fixed it  :clap:
I was only using EN_SELCHANGE.