CEdit::LineLength returning zero
-
Is there a reason you need to use multi-line edit controls of a fixed width? It seems like an array of single line edit controls might do what you need and it is easier to limit the length of data in them.
-
Hi I want to limit the number of characters on a line in a multiline edit control I figured I would do CEdit::linelength and divide that by rect.right From getclientrect that would get me the number of pixels per character I would then multiply it by the number of characters I want on a line however Cedit:Linelength return zero my edit control is declared CEdit mycontrol I know under the covers it does a SendMessage EM_LINELENGTH Is there a issue that I dont have a message map The character index is 0
-
This message returns the length of the existing text at that line, not the amount of space available. How many characters are in the control when you call this?
-
Thanks that’s it I wanted to calculate the number of characters the control can hold on a line
ForNow wrote:
I wanted to calculate the number of characters the control can hold on a line
It depends on the font your control is currently using.
-
ForNow wrote:
I wanted to calculate the number of characters the control can hold on a line
It depends on the font your control is currently using.
-
If your current font is a "proportional" one (like Arial, Times New, ...) then it is not possible to calculate the number of characters in a line in a common case. It will always depend of the text itself. Example: the text "WWW" needs much more pixels than "111". But for non-proportional fonts (like Courier New) both need the same number of pixels.
-
If your current font is a "proportional" one (like Arial, Times New, ...) then it is not possible to calculate the number of characters in a line in a common case. It will always depend of the text itself. Example: the text "WWW" needs much more pixels than "111". But for non-proportional fonts (like Courier New) both need the same number of pixels.
I understand that this is the font statement from resource file dialog definition "FONT 8, "MS Shell Dlg", 400, 0, 0x1" I basically editing for hex characters so my GetTTextExtent string is "0123456789ABCDEF" these characters seem like the size even without a Font like courier new
-
Hi I want to limit the number of characters on a line in a multiline edit control I figured I would do CEdit::linelength and divide that by rect.right From getclientrect that would get me the number of pixels per character I would then multiply it by the number of characters I want on a line however Cedit:Linelength return zero my edit control is declared CEdit mycontrol I know under the covers it does a SendMessage EM_LINELENGTH Is there a issue that I dont have a message map The character index is 0
Have you considered deriving your own class from CEdit, something like:
class MyCustomEdit : public CEdit
{
}Then as each character is typed into the control but before the control is updated, figure out what line the cursor is on (I haven't used MFC in a few years so I'm not sure what these two messages would be). If there is room, let the character through, otherwise not.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Have you considered deriving your own class from CEdit, something like:
class MyCustomEdit : public CEdit
{
}Then as each character is typed into the control but before the control is updated, figure out what line the cursor is on (I haven't used MFC in a few years so I'm not sure what these two messages would be). If there is room, let the character through, otherwise not.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
I understand that this is the font statement from resource file dialog definition "FONT 8, "MS Shell Dlg", 400, 0, 0x1" I basically editing for hex characters so my GetTTextExtent string is "0123456789ABCDEF" these characters seem like the size even without a Font like courier new
-
Have you considered deriving your own class from CEdit, something like:
class MyCustomEdit : public CEdit
{
}Then as each character is typed into the control but before the control is updated, figure out what line the cursor is on (I haven't used MFC in a few years so I'm not sure what these two messages would be). If there is room, let the character through, otherwise not.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles