-
RichEdit Control
I am trying to create a log so that i can monitor statistics in the program im running.
Ive successfully set up the Richedit control and everything, i was wondering if someone could explain to me how I could actually add data to it, also if someone could explain how i could format the data (change color, size, bold, italics) and how i could save all the data to a .txt file.
I have the file stream code set up:
Code:
case LOG_BUTTON_SAVE:
{
SaveFile(hWnd); //Just an Open Save Dialog Function - Ignore
char *Buffer = new char[1000];
//**saving code goes here**
ofstream fout;
fout.open(FileName, ios::ate);
fout << Buffer;
fout.close();
if (Buffer)
delete[] Buffer;
break;
}
I was wondering which message I would have to send to the Richedit control in order to get its contents into the Buffer i declared in the code above.
Thanks
PaYnE
-
Here is the reference for the Rich Edit control.
Start with EM_SETTEXTEX Message.
gg
-
Thanx for the reply Codeplug,
Ive never used MSDN before and I just now realized how valuable it is!
Thanx again
Theres still 1 problem though:
When i try to compile the program MSVC++ says that EM_SETTEXTEX is not defined, ive included the richedit.h header but it wont work
-
Hmmm, I don't have it either.
Use WM_SETTEXT instead.
gg
-
i found out you need richedit 3.0 or 4.1 which supposedly comes with windows xp, somehow I dont have it, so im looking around MSDN until I find a download link, ill post the site once I do, in the meantime ill try windows update maybe i missed something
-
So far ive search all of MSDN and Microsoft.com and found NOTHING, so i tried google instead, apparently the only way to get it is to steal it from the office 2000 resource kit:
http://home.att.net/~robertdunn/FAQs/RE30New.html
Im still looking around, i cant beleive its this hard to download 1 dll which microsoft is supposed to make available on MSDN.
Also WM_SETTEXT cant append strings to the end of the edit control, instead it just sets that text alone, I need a function which will append the text to the end on the rich edit control
-
You can also use mose the Edit control messages for Richedit controls as well.
Use EM_REPLACESEL to insert text at the caret position.
EM_SETSEL will set the caret posistion.
I've only ever used WM_SETTEXT and EM_REPLACESEL to add text.
gg
-
Quote:
Originally posted by Codeplug
You can also use mose the Edit control messages for Richedit controls as well.
Use EM_REPLACESEL to insert text at the caret position.
EM_SETSEL will set the caret posistion.
I've only ever used WM_SETTEXT and EM_REPLACESEL to add text.
gg
I might be mistaken, but I think you can only use EM_SETSEL if you want to place the cursor at a position < 64K on Windows 95/98 machines.
If you want to scroll through a larger piece of text then you should use EM_EXSETSEL.