-
July 18th, 2019, 10:18 PM
#1
Count number of physical lines in the text control
Hi, ALL,
In the text control there are 2 types of line: physical and logical.
Physical lines are divided by "\n\r" characters ("\n" on *nix), logical lines are used when the control is narrower than the text typed and there is a so-called soft "\n\r" character inserted by the control in order for not to display the horizontal scrollbar.
It looks like EM_GETLINECOUNT will return the number of logical lines, according to this. Is there anything that will return me a number of physical lines? Or I will have to manually go through the text buffer and count number of "\n\r" characters?
Thank you.
-
July 18th, 2019, 10:45 PM
#2
Re: Count number of physical lines in the text control
Does MFC offer any methods that help? Even if you aren't using MFC you can look at its source code for implementation.
-
July 19th, 2019, 01:32 AM
#3
Re: Count number of physical lines in the text control
Originally Posted by OneEyeMan
...
It looks like EM_GETLINECOUNT will return the number of logical lines, according to this. Is there anything that will return me a number of physical lines? Or I will have to manually go through the text buffer and count number of "\n\r" characters?
1. Are you using a multi-line edit control?
2. How did you check that EM_GETLINECOUNT will return the number of logical lines?
Victor Nijegorodov
-
July 19th, 2019, 08:58 PM
#4
Re: Count number of physical lines in the text control
Hi, VictorN,
Sorry for the late reply...
Originally Posted by VictorN
1. Are you using a multi-line edit control?
Yes. It doesn't make sense otherwise.
Originally Posted by VictorN
2. How did you check that EM_GETLINECOUNT will return the number of logical lines?
MSDN says so. And I tested.
It counts number of wrapped lines ("logical"), not the physical ones.
Thank you.
-
July 20th, 2019, 12:52 AM
#5
Re: Count number of physical lines in the text control
Originally Posted by OneEyeMan
MSDN says so. And I tested.
It counts number of wrapped lines ("logical"), not the physical ones.
Well, i can understand (or just guess) why. To have a way to exactly know/calculate the position (in the control) of any character in the text depending on the "word wrap" option.
Why do you need to know the number of "physical lines"?
Victor Nijegorodov
-
July 23rd, 2019, 07:09 AM
#6
Re: Count number of physical lines in the text control
Why not just get the text and count the new lines?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|