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#
  4. Create Graphics??

Create Graphics??

Scheduled Pinned Locked Moved C#
helpquestiongraphics
8 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.
  • A Offline
    A Offline
    azusakt
    wrote on last edited by
    #1

    Hi, I'm doing some string wrapping calculation, and need graphics.MeasureString to calculate the width of each character. One problem is, Graphics does not have constructor. How can I get or create Graphics object, if the wrapping calculation must be inside one class library, not inside a dialog? Thanks so much for your help?

    N D 2 Replies Last reply
    0
    • A azusakt

      Hi, I'm doing some string wrapping calculation, and need graphics.MeasureString to calculate the width of each character. One problem is, Graphics does not have constructor. How can I get or create Graphics object, if the wrapping calculation must be inside one class library, not inside a dialog? Thanks so much for your help?

      N Offline
      N Offline
      Nader Elshehabi
      wrote on last edited by
      #2

      You can use TextRenderer.MeasureText() method instead.

      Regards:rose:

      D 1 Reply Last reply
      0
      • A azusakt

        Hi, I'm doing some string wrapping calculation, and need graphics.MeasureString to calculate the width of each character. One problem is, Graphics does not have constructor. How can I get or create Graphics object, if the wrapping calculation must be inside one class library, not inside a dialog? Thanks so much for your help?

        D Offline
        D Offline
        DavidNohejl
        wrote on last edited by
        #3

        What about this MSDN article? How to: Create Graphics Objects for Drawing [^]


        "Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus

        A 1 Reply Last reply
        0
        • N Nader Elshehabi

          You can use TextRenderer.MeasureText() method instead.

          Regards:rose:

          D Offline
          D Offline
          DavidNohejl
          wrote on last edited by
          #4

          yeah, but TextRenderer.MeasureText() takes IDeviceContext as argument, which he doesn't have.


          "Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus

          N 1 Reply Last reply
          0
          • D DavidNohejl

            yeah, but TextRenderer.MeasureText() takes IDeviceContext as argument, which he doesn't have.


            "Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus

            N Offline
            N Offline
            Nader Elshehabi
            wrote on last edited by
            #5

            :wtf: Have you even read the the documentation[^]?

            Regards:rose:

            D 1 Reply Last reply
            0
            • N Nader Elshehabi

              :wtf: Have you even read the the documentation[^]?

              Regards:rose:

              D Offline
              D Offline
              DavidNohejl
              wrote on last edited by
              #6

              nope, just glanced :-O:doh: You are right of course. I was wondering why your correct answer got low vote, so I was bit fast in judgment. :rose:


              "Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus

              N 1 Reply Last reply
              0
              • D DavidNohejl

                nope, just glanced :-O:doh: You are right of course. I was wondering why your correct answer got low vote, so I was bit fast in judgment. :rose:


                "Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus

                N Offline
                N Offline
                Nader Elshehabi
                wrote on last edited by
                #7

                Thanks dnh. I was wondering why it got two without the voting guy telling me what's wrong. When you posted your reply I thought you were the guy and that's your reason -felt little frustrated at first:->, sorry!-. Now I wonder again. See you on the forums.

                Regards:rose:

                1 Reply Last reply
                0
                • D DavidNohejl

                  What about this MSDN article? How to: Create Graphics Objects for Drawing [^]


                  "Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus

                  A Offline
                  A Offline
                  azusakt
                  wrote on last edited by
                  #8

                  Thank you for all of your replies. I have tried to use TextRenderer.MeasureText(), it works fine.. But I still prefer using Graphics to Measure, I found that it is more accurate. Because I need to set some scaleing and measure unit in graphics. The method I get the Graphics is, I create a Form, and then use Form.CreateGraphics(), seems a stupid method ^_^, but works finally.

                  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