Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CRichEditCtrl halt any visual updates for a sec !!

CRichEditCtrl halt any visual updates for a sec !!

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sdancer75
    wrote on last edited by
    #1

    Hi, I am using a CRichEditCtrl with an almost black background and white text. The problem is that when I want to print the text, the printer tries to simulate the original screen colors. In my case, I would like to print with standard black text & white background. What i am doing now, is that : Before that print start, I change the control with the standard colors and after the end of the printing I revert to the original screen colors. The code seems like the following :

    //hide selection 
    HideSelection(TRUE,FALSE);	
    //to view this correctly in MS Word or to any other word processor
    //You should change the colors. Do the background white and the text black
    
    //Disable the ENM\_CHANGE events manually. We dont want to make the handler think that where was
    //indeed an event.
    SetEventMask(~ENM\_CHANGE & GetEventMask());
    
    
    int CurChar=CharFromPos(currentpos);
    long len=GetTextLength();
    SetSel(0 , len);
    SetBackgroundColor(FALSE, RGB(255,255, 255));
    SetColor(RGB(0,0,0));
    
        //--------------------------------------------------------
        //**\-------> Printing code here** <--------------------
        //--------------------------------------------------------
    
    
    SetSel(0 , len);
    SetBackgroundColor(FALSE, RGB(61,61, 56));
    SetColor(RGB(255,255,255));
    SetSel(CurChar,CurChar);
    
    
    //Re-enable the ENM\_CHANGE events manually.
    SetEventMask(ENM\_CHANGE | GetEventMask());
    
    //reenable selection
    HideSelection(FALSE,FALSE);
    

    The above code creates a flicker, especially if the pages to be printed are many. Is there any solution, like to halt visual updating of the CRichEditCtrl control for a specific period of time to avoid flicker ?

    sdancer75

    J C 2 Replies Last reply
    0
    • S sdancer75

      Hi, I am using a CRichEditCtrl with an almost black background and white text. The problem is that when I want to print the text, the printer tries to simulate the original screen colors. In my case, I would like to print with standard black text & white background. What i am doing now, is that : Before that print start, I change the control with the standard colors and after the end of the printing I revert to the original screen colors. The code seems like the following :

      //hide selection 
      HideSelection(TRUE,FALSE);	
      //to view this correctly in MS Word or to any other word processor
      //You should change the colors. Do the background white and the text black
      
      //Disable the ENM\_CHANGE events manually. We dont want to make the handler think that where was
      //indeed an event.
      SetEventMask(~ENM\_CHANGE & GetEventMask());
      
      
      int CurChar=CharFromPos(currentpos);
      long len=GetTextLength();
      SetSel(0 , len);
      SetBackgroundColor(FALSE, RGB(255,255, 255));
      SetColor(RGB(0,0,0));
      
          //--------------------------------------------------------
          //**\-------> Printing code here** <--------------------
          //--------------------------------------------------------
      
      
      SetSel(0 , len);
      SetBackgroundColor(FALSE, RGB(61,61, 56));
      SetColor(RGB(255,255,255));
      SetSel(CurChar,CurChar);
      
      
      //Re-enable the ENM\_CHANGE events manually.
      SetEventMask(ENM\_CHANGE | GetEventMask());
      
      //reenable selection
      HideSelection(FALSE,FALSE);
      

      The above code creates a flicker, especially if the pages to be printed are many. Is there any solution, like to halt visual updating of the CRichEditCtrl control for a specific period of time to avoid flicker ?

      sdancer75

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      I'm not quite sure if this helps, but you may give it a try: Call SetRedraw(0) just after HideSelection() and re-enable it before showing the selection. This will prevent the screen from being updated with the control content while printing.

      1 Reply Last reply
      0
      • S sdancer75

        Hi, I am using a CRichEditCtrl with an almost black background and white text. The problem is that when I want to print the text, the printer tries to simulate the original screen colors. In my case, I would like to print with standard black text & white background. What i am doing now, is that : Before that print start, I change the control with the standard colors and after the end of the printing I revert to the original screen colors. The code seems like the following :

        //hide selection 
        HideSelection(TRUE,FALSE);	
        //to view this correctly in MS Word or to any other word processor
        //You should change the colors. Do the background white and the text black
        
        //Disable the ENM\_CHANGE events manually. We dont want to make the handler think that where was
        //indeed an event.
        SetEventMask(~ENM\_CHANGE & GetEventMask());
        
        
        int CurChar=CharFromPos(currentpos);
        long len=GetTextLength();
        SetSel(0 , len);
        SetBackgroundColor(FALSE, RGB(255,255, 255));
        SetColor(RGB(0,0,0));
        
            //--------------------------------------------------------
            //**\-------> Printing code here** <--------------------
            //--------------------------------------------------------
        
        
        SetSel(0 , len);
        SetBackgroundColor(FALSE, RGB(61,61, 56));
        SetColor(RGB(255,255,255));
        SetSel(CurChar,CurChar);
        
        
        //Re-enable the ENM\_CHANGE events manually.
        SetEventMask(ENM\_CHANGE | GetEventMask());
        
        //reenable selection
        HideSelection(FALSE,FALSE);
        

        The above code creates a flicker, especially if the pages to be printed are many. Is there any solution, like to halt visual updating of the CRichEditCtrl control for a specific period of time to avoid flicker ?

        sdancer75

        C Offline
        C Offline
        chaau
        wrote on last edited by
        #3

        Try LockWindowUpdates() before the printing and UnlockWindowUpdates() after it

        S 1 Reply Last reply
        0
        • C chaau

          Try LockWindowUpdates() before the printing and UnlockWindowUpdates() after it

          S Offline
          S Offline
          sdancer75
          wrote on last edited by
          #4

          Thank you Andrew, It worked just fine, but I was wondering if there is a solution using the CRichEditCtrl itself (that it would be a non quick & dirty method and the right way to solve the problem). Best Regards,

          sdancer75

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups