Thread: Changing font in rich edit, without affecting undo buffer

  1. #1
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905

    Changing font in rich edit, without affecting undo buffer

    is there any way to change the font in a control without having it be set in the undo buffer? (like, for my case, I'm using it in a syntax highlighter, but it REALLY screws up the undoing whenever i call it, so it basically ends up making it so that i can't undo anymore without undoing font settings and making the syntax highlighting go crazy...)

    here's my basic code that i use:

    Code:
    	SendMessage(hCtrl,WM_SETREDRAW,0,0);
    	int started,end;
    	SendMessage(hCtrl,EM_GETSEL,(WPARAM)&started,LPARAM)&end);
    	POINT ScrollPos;
    	SendMessage(hCtrl,EM_GETSCROLLPOS,NULL,(LPARAM)&ScrollPos);
    
    	long dwEventMask=(SendMessage(hCtrl,EM_GETEVENTMASK,0,0));
    	SendMessage(hCtrl,EM_SETEVENTMASK,0,dwEventMask^=ENM_CHANGE);
    
    // then we do that actual coloring of the code which involves a lot of selecting and font changing......
    
    	CHARRANGE select2={started,end};
    	SendMessage(hCtrl,EM_EXSETSEL,0,(LPARAM)&select2);
    	SendMessage(hCtrl,EM_SETSCROLLPOS,NULL,(LPARAM)&ScrollPos);
    	SendMessage(hCtrl,EM_SETEVENTMASK,0,dwEventMask|=ENM_CHANGE);
    	SendMessage(hCtrl,WM_SETREDRAW,1,0);
    	RedrawWindow(hCtrl,NULL,NULL,RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE);
    -note-
    This richedit control can support over 10000 undos....that's why i need to fix this. If my editor only had one undo, i suppose it wouldn't matter, but i'd like to be able to undo more (i suppose I could figure out my own "undo algorithm" or something)
    Last edited by jverkoey; 01-17-2004 at 08:01 PM.

  2. #2
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    I came across this problem when I was implementing my own syntax highlighter too.

    I eventually gave up and just used Scintilla for my syntax highlight control.

  3. #3
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    that's the problem, i can't just resort to another editor because this compiler is for my programming language, OpenScript, so I need to do everything with my own tools....

    -edit-
    i suppose i can look at the source to see how they did it.....................................*looks*
    Last edited by jverkoey; 01-17-2004 at 08:25 PM.

  4. #4
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    alas, from what i can see in both visual studio and scintilla, it looks like i'll have to design my own undo buffer algorithm...In other words, I'm just going to go with a single undo buffer until I feel up to designing a full undo buffer....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Printing from a Rich Edit control
    By JustMax in forum Windows Programming
    Replies: 10
    Last Post: 02-14-2009, 07:12 PM
  2. edit control text buffer
    By scurvydog in forum Windows Programming
    Replies: 4
    Last Post: 12-11-2008, 10:13 AM
  3. Changing the font of the edit to Courier
    By Garfield in forum Windows Programming
    Replies: 3
    Last Post: 02-12-2002, 02:03 PM
  4. Font In Edit Box??
    By (TNT) in forum Windows Programming
    Replies: 7
    Last Post: 11-10-2001, 11:12 PM
  5. Rich edit control example Win API
    By Echidna in forum Windows Programming
    Replies: 1
    Last Post: 09-17-2001, 02:12 AM