1

Topic: How to receive the necessary line from multiline CEdit?

There is some multiline text box IDC_EDIT1 to which there corresponds a variable m_IDC_EDIT1 type CEdit. In it IDC_EDIT1 the text contains: "1\r\n2\r\n3\r\n <...> N" That is in it IDC_EDIT1 there are lines: 1 2 3 <...> N How program to receive i th (for example, the very first line) from this text box?

2

Re: How to receive the necessary line from multiline CEdit?

Hello, RussianFellow, you wrote: RF> 1 RF> 2 RF> 3 RF> <...> RF> N RF> How program to receive i th (for example, the very first line) from this text box? CEdit e;... TCHAR acBuffer [1024]; e. GetLine (0, acBuffer, sizeof (acBuffer));//the first line e. GetLine (e. GetLineCount () - 1, acBuffer, sizeof (acBuffer));//the last line

3

Re: How to receive the necessary line from multiline CEdit?

Hello, Maniacal, you wrote: M> TCHAR acBuffer [1024]; M> e. GetLine (0, acBuffer, sizeof (acBuffer));//the first line M> e. GetLine (e. GetLineCount () - 1, acBuffer, sizeof (acBuffer));//the last line It is a reliable candidate on buffer overflow. ESPECIALLY in a combination with TCHAR! https://stackoverflow.com/questions/335 … farr0-work

4

Re: How to receive the necessary line from multiline CEdit?

Hello, VladFein, you wrote: VF> It is a reliable candidate on buffer overflow. VF> ESPECIALLY in a combination with TCHAR! VF> https://stackoverflow.com/questions/335 … farr0-work It is exact, it is necessary sizeof (acBuffer) / sizeof (acBuffer [0]), At first I simply wanted to write CEdit:: GetLine (...), but thought not so it will be evident

5

Re: How to receive the necessary line from multiline CEdit?

I see. But here the such arises a question: function CEdit:: GetLine places in a variable acBuffer type TCHAR* a line, but can not complete its NULL-symbol. How to be in this case?

6

Re: How to receive the necessary line from multiline CEdit?

Hello, RussianFellow, you wrote: RF> it is clear. RF> but here the such arises a question: function CEdit:: GetLine places in a variable acBuffer type TCHAR* a line, but can not complete its NULL-symbol. How to be in this case? I am normal after such operation I appropriate to 0 last character of the buffer. TCHAR buffer [10]; static_cast <CEdit *> (GetDlgItem (IDC_EDIT1))-> GetLine (0, buffer, sizeof (buffer) / sizeof (buffer [0])); buffer [sizeof (buffer) / sizeof (buffer [0]) - 1] = 0;