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. Anyone have a simple line drawing program?

Anyone have a simple line drawing program?

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicstutorialquestionannouncement
4 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.
  • G Offline
    G Offline
    getz53
    wrote on last edited by
    #1

    Hi. Does anyone have a simple C++ program that I can use to draw lines on a PC display? I would like something that I could just pass x and y start and end points, and have it plot a line. I have Microsoft Visual C++. version 4.0. I am not a professional programmer, so I would also appreciate an example of how this code could be called from the main program. Thank you. Bill

    C 1 Reply Last reply
    0
    • G getz53

      Hi. Does anyone have a simple C++ program that I can use to draw lines on a PC display? I would like something that I could just pass x and y start and end points, and have it plot a line. I have Microsoft Visual C++. version 4.0. I am not a professional programmer, so I would also appreciate an example of how this code could be called from the main program. Thank you. Bill

      C Offline
      C Offline
      Cloaca
      wrote on last edited by
      #2

      Hi Bill, I would say that it depends partly on the OS being used. Is it Windows 9X, NT (or greater), or DOS, etc. If it's Windows, there are API functions available that are as simple to use as: pDC->MoveTo(x1, y1); pDC->LineTo(x2, y2); Which together will draw a line starting at (x1, y1) and ending at (x2, y2). Are you familiar with these kinds of functions? Also, check out http://www.codeproject.com/gdi/[^] If you haven't seen these articles yet, there are a bunch of good ones, and some are marked as 'Beginner'. In particular, check out: http://www.codeproject.com/gdi/dcdrawing.asp[^] Drawing took me some getting used to (I'm also far from a pro programmer) but after a few practice programs you'll get the hang of drawing in Windows. Best, Eric

      G 1 Reply Last reply
      0
      • C Cloaca

        Hi Bill, I would say that it depends partly on the OS being used. Is it Windows 9X, NT (or greater), or DOS, etc. If it's Windows, there are API functions available that are as simple to use as: pDC->MoveTo(x1, y1); pDC->LineTo(x2, y2); Which together will draw a line starting at (x1, y1) and ending at (x2, y2). Are you familiar with these kinds of functions? Also, check out http://www.codeproject.com/gdi/[^] If you haven't seen these articles yet, there are a bunch of good ones, and some are marked as 'Beginner'. In particular, check out: http://www.codeproject.com/gdi/dcdrawing.asp[^] Drawing took me some getting used to (I'm also far from a pro programmer) but after a few practice programs you'll get the hang of drawing in Windows. Best, Eric

        G Offline
        G Offline
        getz53
        wrote on last edited by
        #3

        Thanks for the information, Eric! I will be running Windows XP. Can those APIs be used stand-alone, or do I have to use some sort of class thing? What inculdes do I have to put into my programs? Do you have a simple example? Again, thanks! Bill

        C 1 Reply Last reply
        0
        • G getz53

          Thanks for the information, Eric! I will be running Windows XP. Can those APIs be used stand-alone, or do I have to use some sort of class thing? What inculdes do I have to put into my programs? Do you have a simple example? Again, thanks! Bill

          C Offline
          C Offline
          Cloaca
          wrote on last edited by
          #4

          Hi Bill, To answer about the APIs: They are available for your use in a program without creating additional classes, they are supplied as part of Windows and your VC++ 4 compiler should let you write programs that call them. About the includes: To be honest, I'm not sure of the actual #includes needed to access them. The reason is that I take it for granted that they will be provided automatically by App Wizard (the tool provided in VC++) when I create the program skeleton. Are you familiar with using App Wizard to generate a program skeleton? This will help answer about a sample program. Best, Eric

          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