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. TextOut of CDC

TextOut of CDC

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 Posts 6 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.
  • N Offline
    N Offline
    ns
    wrote on last edited by
    #1

    I am trying to write on a label. In the OnEraseBackground function I have

    		pDC->TextOut(50,42,"aaaa",30);
    

    At this location I get a black rectangle. What do I need to do to see the text? thanks, sb

    J M L D H 5 Replies Last reply
    0
    • N ns

      I am trying to write on a label. In the OnEraseBackground function I have

      		pDC->TextOut(50,42,"aaaa",30);
      

      At this location I get a black rectangle. What do I need to do to see the text? thanks, sb

      J Offline
      J Offline
      James R Twine
      wrote on last edited by
      #2

      I do not know what foreground color, background color, drawing mode you are using, or if you are drawing at the right time because the code sample is missing detail.    But the last parameter you have specified in your example is incorrect - it is supposed to be the character count of the specified string (note that the documentation may be incorrect when it says "byte count").  As such, you should be specifying 4.    Peace! -=- James


      If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
      Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
      DeleteFXPFiles & CheckFavorites (Please rate this post!)

      1 Reply Last reply
      0
      • N ns

        I am trying to write on a label. In the OnEraseBackground function I have

        		pDC->TextOut(50,42,"aaaa",30);
        

        At this location I get a black rectangle. What do I need to do to see the text? thanks, sb

        M Offline
        M Offline
        Mahesh Kulkarni
        wrote on last edited by
        #3

        As you are working with CDC you can simply set the text color using SetTextColor() API which takes COLORREF as parameter. The secret of life is not enjoyment but education through experience. - Swami Vivekananda.

        1 Reply Last reply
        0
        • N ns

          I am trying to write on a label. In the OnEraseBackground function I have

          		pDC->TextOut(50,42,"aaaa",30);
          

          At this location I get a black rectangle. What do I need to do to see the text? thanks, sb

          L Offline
          L Offline
          Laxman Auti
          wrote on last edited by
          #4

          wrote:

          I am trying to write on a label.

          Why you are trying TextOut on label ?? Simply use SetWindowText for that label if using MFC. For win32 use SendMessage(handle,WM_SETTEXT,...); Knock out 't' from can't, You can if you think you can :cool:

          1 Reply Last reply
          0
          • N ns

            I am trying to write on a label. In the OnEraseBackground function I have

            		pDC->TextOut(50,42,"aaaa",30);
            

            At this location I get a black rectangle. What do I need to do to see the text? thanks, sb

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            Any particular reason why you are writing in the OnEraseBackground() method? Why not do it in the OnPaint() method?


            "The largest fire starts but with the smallest spark." - David Crow

            "Judge not by the eye but by the heart." - Native American Proverb

            N 1 Reply Last reply
            0
            • D David Crow

              Any particular reason why you are writing in the OnEraseBackground() method? Why not do it in the OnPaint() method?


              "The largest fire starts but with the smallest spark." - David Crow

              "Judge not by the eye but by the heart." - Native American Proverb

              N Offline
              N Offline
              ns
              wrote on last edited by
              #6

              Thats what I saw in a sample program, so I used OnEraseBackground. I did get TextOut to work , thanks everybody. I'm drawing on the label because I drew a histogram on it and want to put values for the tick marks on the axes. Maybe there is a smarter control to use instead ofa label? thanks sb

              1 Reply Last reply
              0
              • N ns

                I am trying to write on a label. In the OnEraseBackground function I have

                		pDC->TextOut(50,42,"aaaa",30);
                

                At this location I get a black rectangle. What do I need to do to see the text? thanks, sb

                H Offline
                H Offline
                Hamid Taebi
                wrote on last edited by
                #7

                you can use WM_PAINT instead WM_ERASEBKGND void CAnswer::OnPaint() { CPaintDC dc(this); dc.SetBkMode(0); dc.TextOut(50,42,"aaaa",30); }_**


                **_

                whitesky


                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