Thread: RichEdit Control

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    288

    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
    Last edited by X PaYnE X; 12-20-2003 at 01:23 PM.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Here is the reference for the Rich Edit control.
    Start with EM_SETTEXTEX Message.

    gg

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    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
    Last edited by X PaYnE X; 12-20-2003 at 11:31 PM.

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Hmmm, I don't have it either.
    Use WM_SETTEXT instead.

    gg

  5. #5
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    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

  6. #6
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    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

  7. #7
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    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

  8. #8
    Registered User
    Join Date
    Oct 2003
    Posts
    13
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading plain text into a RichEdit control
    By JustMax in forum C Programming
    Replies: 0
    Last Post: 02-03-2009, 03:15 PM
  2. Wordbreak in a RichEdit control
    By Joelito in forum Windows Programming
    Replies: 1
    Last Post: 01-05-2007, 07:18 PM
  3. WIN32 API: RichEdit control RTF data size
    By wn00 in forum Windows Programming
    Replies: 2
    Last Post: 09-05-2006, 06:15 PM
  4. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM