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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. What device context methods are available to Crichedit

What device context methods are available to Crichedit

Scheduled Pinned Locked Moved C / C++ / MFC
5 Posts 2 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.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    Hi, I know that rich edit controls have thier own interface but would any one know which of the CDC methods are available and at what point to a rich edit Specfically I would like to set the Font and text Color initially

    K 1 Reply Last reply
    0
    • F ForNow

      Hi, I know that rich edit controls have thier own interface but would any one know which of the CDC methods are available and at what point to a rich edit Specfically I would like to set the Font and text Color initially

      K Offline
      K Offline
      karle
      wrote on last edited by
      #2

      A device context is used to render the content of the richedit to a device to intialise the width for word breaks. use CRichEditCtrl::SetDefaultCharFormat to set the default format of the text. It takes a CHARFORMAT2 to structure where you can set the font and the textcolor. Remember to initialize the cbSize with the size of CHARFORMAT2 and to set the dwMask Member to flag which properties you want to set. Use CRichEditCtrl::SetSelectionCharFormat() to format the selected text. When set SetWordWrapMode() you should also call SetTargetDevice to set the width of a line. Use FormatRange to render the content to a device.

      F 1 Reply Last reply
      0
      • K karle

        A device context is used to render the content of the richedit to a device to intialise the width for word breaks. use CRichEditCtrl::SetDefaultCharFormat to set the default format of the text. It takes a CHARFORMAT2 to structure where you can set the font and the textcolor. Remember to initialize the cbSize with the size of CHARFORMAT2 and to set the dwMask Member to flag which properties you want to set. Use CRichEditCtrl::SetSelectionCharFormat() to format the selected text. When set SetWordWrapMode() you should also call SetTargetDevice to set the width of a line. Use FormatRange to render the content to a device.

        F Offline
        F Offline
        ForNow
        wrote on last edited by
        #3

        In other words all these Richedit methods act as interface to CClientDC object

        K 1 Reply Last reply
        0
        • F ForNow

          In other words all these Richedit methods act as interface to CClientDC object

          K Offline
          K Offline
          karle
          wrote on last edited by
          #4

          I didn't get you real question! CRichEditCtrl is a control an displays its content in the wm_paint event to the paint dc. Only if the control should calculate sizes or draw it's content a device context is needed. If you require a "WYSIWYG" you should apply the device context of the desired device. If you want to calculate the size or want to draw it to a context you have to call FormatRange Method and apply the deviceContext of the target device to the formatrange structure. If you want to learn, how richeditctrl realy works, see MSDN : Rich Edit Control Examples[^]

          F 1 Reply Last reply
          0
          • K karle

            I didn't get you real question! CRichEditCtrl is a control an displays its content in the wm_paint event to the paint dc. Only if the control should calculate sizes or draw it's content a device context is needed. If you require a "WYSIWYG" you should apply the device context of the desired device. If you want to calculate the size or want to draw it to a context you have to call FormatRange Method and apply the deviceContext of the target device to the formatrange structure. If you want to learn, how richeditctrl realy works, see MSDN : Rich Edit Control Examples[^]

            F Offline
            F Offline
            ForNow
            wrote on last edited by
            #5

            Thought if you wanted to CDC::SetTextColor you would need need ther Device COntext but like you said in a Earlier post you can use SetCharformat for that

            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