Visual c++ how to read from rich text box -
i trying read rich text box line line in visual c++ don't know how it. can provide small example of how works? new visual studio , visual c++. do,is store each line rich text box in string,using loop. let's in rich text box have: text1 text2 text3 loop pretty read each line,and other operations it.
you did not kind of rich text box using.
if using .net richtextbox class, can iterate through lines property:
array<string^>^ lines = textbox->lines; int count = lines->length; (int idx = 0; idx < count; ++idx) { // use lines[idx] needed... } if using mfc cricheditctrl class, can call getlinecount(), linelength(), , getline() methods:
int count = textbox.getlinecount(); (int idx = 0; idx < count; ++idx) { std::basic_string<tchar> line; int len = textbox.linelength(idx); if (len > 0) { line.resize(len+1); len = textbox.getline(idx, &line[0], len); line.resize(len); } // use line needed... } if using win32 rich edit control, can send em_getlinecount, em_linelength, , em_getline messages:
int count = sendmessage(htextbox, em_getlinecount, 0, 0); (int idx = 0; idx < count; ++idx) { std::basic_string<tchar> line; int len = sendmessage(htextbox, em_linelength, idx, 0); if (len > 0) { line.resize(len+1); *(reinterpret_cast<word*>(&line[0])) = (word)len; len = sendmessage(htextbox, em_getline, idx, reinterpret_cast<lparam>(&line[0])); line.resize(len); } // use line needed... }
Comments
Post a Comment