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. Managed C++/CLI
  4. Want to draw a line on a Form with C++/CLI

Want to draw a line on a Form with C++/CLI

Scheduled Pinned Locked Moved Managed C++/CLI
questionc++
11 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.
  • . ...---...

    I have a beginners question. What does the code look like to use DrawLine in C++ CLI? -- thanks

    M Offline
    M Offline
    Mark Salsbery
    wrote on last edited by
    #2

    Here's one way: Graphics^graphics = CreateGraphics(); Pen AzurePen(Color::Azure); graphics->DrawLine(%AzurePen, 10, 10, 50, 50); Mark

    Mark Salsbery Microsoft MVP - Visual C++ :java:

    . 1 Reply Last reply
    0
    • M Mark Salsbery

      Here's one way: Graphics^graphics = CreateGraphics(); Pen AzurePen(Color::Azure); graphics->DrawLine(%AzurePen, 10, 10, 50, 50); Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      . Offline
      . Offline
      ...---...
      wrote on last edited by
      #3

      Thanks a lot.

      C 1 Reply Last reply
      0
      • . ...---...

        Thanks a lot.

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #4

        Of course, this line will disappear as soon as the form is invalidated. All drawing should occur in the paint event

        Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        M 1 Reply Last reply
        0
        • C Christian Graus

          Of course, this line will disappear as soon as the form is invalidated. All drawing should occur in the paint event

          Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #5

          Heh! I didn't say where to put the code, nor was I asked! LOL

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          G L 2 Replies Last reply
          0
          • M Mark Salsbery

            Heh! I didn't say where to put the code, nor was I asked! LOL

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            G Offline
            G Offline
            George L Jackson
            wrote on last edited by
            #6

            Actually, IMHO, you shouldn't give too much more information than they ask for. You learn more from trying and failing (a.k.a. experience) than someone telling you as a by-the-way comment.

            "We make a living by what we get, we make a life by what we give." --Winston Churchill

            M L 2 Replies Last reply
            0
            • G George L Jackson

              Actually, IMHO, you shouldn't give too much more information than they ask for. You learn more from trying and failing (a.k.a. experience) than someone telling you as a by-the-way comment.

              "We make a living by what we get, we make a life by what we give." --Winston Churchill

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #7

              Also, I find the distance I drift away from what the OP really wanted is often directly proportional to the amount of example code I type and/or copy :) Cheers, Mark

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              G 1 Reply Last reply
              0
              • M Mark Salsbery

                Also, I find the distance I drift away from what the OP really wanted is often directly proportional to the amount of example code I type and/or copy :) Cheers, Mark

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                G Offline
                G Offline
                George L Jackson
                wrote on last edited by
                #8

                Word!

                "We make a living by what we get, we make a life by what we give." --Winston Churchill

                1 Reply Last reply
                0
                • M Mark Salsbery

                  Heh! I didn't say where to put the code, nor was I asked! LOL

                  Mark Salsbery Microsoft MVP - Visual C++ :java:

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #9

                  Hi Mark, your code was not targetting the paint handler, it includes a CreateGraphics(), whereas A paint handler would hand you the Graphics to use ! Greetings

                  Luc Pattyn [Forum Guidelines] [My Articles]


                  this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


                  M 1 Reply Last reply
                  0
                  • L Luc Pattyn

                    Hi Mark, your code was not targetting the paint handler, it includes a CreateGraphics(), whereas A paint handler would hand you the Graphics to use ! Greetings

                    Luc Pattyn [Forum Guidelines] [My Articles]


                    this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


                    M Offline
                    M Offline
                    Mark Salsbery
                    wrote on last edited by
                    #10

                    Indeed!  Thanks Luc :) Mark

                    Mark Salsbery Microsoft MVP - Visual C++ :java:

                    1 Reply Last reply
                    0
                    • G George L Jackson

                      Actually, IMHO, you shouldn't give too much more information than they ask for. You learn more from trying and failing (a.k.a. experience) than someone telling you as a by-the-way comment.

                      "We make a living by what we get, we make a life by what we give." --Winston Churchill

                      L Offline
                      L Offline
                      led mike
                      wrote on last edited by
                      #11

                      George L. Jackson wrote:

                      You learn more from trying and failing

                      Yes but this is 2007 and you will get paid more by making your deadlines using copy/paste ! We don't don't need no stinkin learnin! :->

                      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