Problem with retrieveing number of characters in a multiline edit control
-
Hi, I have some problems with the edit control. I want to count the chars if it, but the message i send to the control only receives the right character num for the first line. For exmaple. The first line can have 60 chars. If I only enter 50 or so, the message gives me the right count. If I then enter a longer text, so that the first line have all the 60 chars and the second line have only 30 chars, then the message returns also a number of 60 chars for the second line, but why ? Where is the problem ? My line:
dwChars = (DWORD)SendDlgItemMessage(hwnd,IDC_INPUT,EM_LINELENGTH,(WPARAM)3,(LPARAM)0);
I hardcoded the line 3 here, normally I am going through a for loop.
-
Hi, I have some problems with the edit control. I want to count the chars if it, but the message i send to the control only receives the right character num for the first line. For exmaple. The first line can have 60 chars. If I only enter 50 or so, the message gives me the right count. If I then enter a longer text, so that the first line have all the 60 chars and the second line have only 30 chars, then the message returns also a number of 60 chars for the second line, but why ? Where is the problem ? My line:
dwChars = (DWORD)SendDlgItemMessage(hwnd,IDC_INPUT,EM_LINELENGTH,(WPARAM)3,(LPARAM)0);
I hardcoded the line 3 here, normally I am going through a for loop.
-
Hi, I have some problems with the edit control. I want to count the chars if it, but the message i send to the control only receives the right character num for the first line. For exmaple. The first line can have 60 chars. If I only enter 50 or so, the message gives me the right count. If I then enter a longer text, so that the first line have all the 60 chars and the second line have only 30 chars, then the message returns also a number of 60 chars for the second line, but why ? Where is the problem ? My line:
dwChars = (DWORD)SendDlgItemMessage(hwnd,IDC_INPUT,EM_LINELENGTH,(WPARAM)3,(LPARAM)0);
I hardcoded the line 3 here, normally I am going through a for loop.
EM_LINELENGTH
message wants the index of a character (of the wanted line) asWPARAM
, hence, if you need the lenght of the third line, use:INT iCharIndex = SendDlgItemMessage(hwnd,IDC_INPUT,EM_LINEINDEX,(WPARAM)2,(LPARAM)0);
INT iLineLen = SendDlgItemMessage(hwnd,IDC_INPUT,EM_LINELENGTH,(WPARAM)iCharIndex,(LPARAM)0);:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]