Blitting scaled content of CRichEditCtrl to screen DC.
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Blitting scaled content of CRichEditCtrl to screen DC.

Hybrid View

  1. #1
    Join Date
    May 2006
    Posts
    21

    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:
    Code:
    		CDC *dc = wnd->GetDC();
    		CRect cr;
    		wnd->GetClientRect( &cr );
    		dc->Rectangle(cr);
    		
    		cr.right *= 15;
    		cr.bottom *= 15;
    
    		FORMATRANGE fr;
    		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);
    
    		ReleaseDC(dc);
    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
    Location
    Belgium (Europe)
    Posts
    4,061

    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
    Location
    United States
    Posts
    56

    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
    Posts
    21

    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

This is a CodeGuru survey question.


Featured


HTML5 Development Center