CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2006

    Blitting scaled content of CRichEditCtrl to screen DC.

    Hi, I need to render content of CRichEditCtrl on device context of some CWnd. This code works ok:
    		CDC *dc = wnd->GetDC();
    		CRect cr;
    		wnd->GetClientRect( &cr );
    		cr.right *= 15;
    		cr.bottom *= 15;
    		fr.hdc = dc->m_hDC;
    		fr.hdcTarget = dc->m_hDC;
    		fr.rc = cr;
    		fr.rcPage = cr;
    		fr.chrg.cpMin = 0;
    		fr.chrg.cpMax = -1;
    		m_cEditor.FormatRange(&fr, TRUE);
    		m_cEditor.FormatRange(NULL, TRUE);
    The problem is that I want to scale the output. I was trying to send message to my control before blitting: SendMessage( EM_SETZOOM, numer, denom ). It scaled the control itself, but the blitted context was still the same size as original content CRichEditCtrl (befeoe scaling). Is there any way to blit/render scaled content of CRichEditCtrl to any device context (screen/paper) ?

  2. #2
    Join Date
    Apr 2000
    Belgium (Europe)

    Re: Blitting scaled content of CRichEditCtrl to screen DC.

    it's not entirely clear what you want to achieve, but FormatRange() is for formatting text for a specific DC.
    This doesn't actually draw something, it prepares for drawing, which is typically done with DisplayBand()

    If your rich text contains an image and you want this image scaled according to the DC, then you need to properly set the properties of the OLE object that holds the image. If you've set this to pixel sizes, then it'll display differently on different devices, if you want the image to scale, you want either a % based or measurement in (milli)meters, inches or points.

  3. #3
    Join Date
    Feb 2013
    United States

    Re: Blitting scaled content of CRichEditCtrl to screen DC.

    If you want the text to scale, you could change the font size.

  4. #4
    Join Date
    May 2006

    Re: Blitting scaled content of CRichEditCtrl to screen DC.

    Thanks for answers. I can't change font size for entire control because I need to preserve text format (colours, style and font size also). I solve my problem using enhanced-format metafile for transformation. First I create device context for meta-file: HDC hDCEMF = CreateEnhMetaFile( dc->m_hDC, NULL, cHiMetricRect, NULL ). Then copy CRichControl content using CrichEditCtrl::FormatRange. Next metafile context should be closed: HENHMETAFILE hEMF = CloseEnhMetaFile(hDCEMF). Then I can do the transformation using SetWorldTransform. Next I copy my metafile to my destination dc: dc->PlayMetaFile(hEMF,&cr). And it works

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.