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. drawing a circle

drawing a circle

Scheduled Pinned Locked Moved C / C++ / MFC
4 Posts 4 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 Offline
    I Offline
    imran
    wrote on last edited by
    #1

    hi all, i need to make a start on this project which requires me to draw rectangels and circles in VC++. and i don't a have a CLUE where to start, and HOW to start! anybuddy there to help me out??? imran help me today, and i'll help YOU out tomorrow...

    C C 2 Replies Last reply
    0
    • I imran

      hi all, i need to make a start on this project which requires me to draw rectangels and circles in VC++. and i don't a have a CLUE where to start, and HOW to start! anybuddy there to help me out??? imran help me today, and i'll help YOU out tomorrow...

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      CDC::Rectangle CDC::Ellipse ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com

      1 Reply Last reply
      0
      • I imran

        hi all, i need to make a start on this project which requires me to draw rectangels and circles in VC++. and i don't a have a CLUE where to start, and HOW to start! anybuddy there to help me out??? imran help me today, and i'll help YOU out tomorrow...

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

        If you're just drawing them ( i.e. they will not change ), you can do this in your OnPaint handler. Just use the methods already mentioned. If you want them to change/move, you will probably want to double buffer them, which means drawing them to another bitmap then copying it across just after creating the paintDC, to avoid flicker. To create a DC you do the following: CDC dc; dc.CreateCompatibleDC(NULL); // Creates a device context compatible with the screen CBitmap bm, *pOldBitmap; bm.Create(width, height, 1, GetDeviceCaps(dc.m_hDC, BITSPIXEL)); // Create a bitmap to draw onto pOldBitmap = dc.SelectObject(&bm); // Whenever you select something into a DC, a pointer to the old one is released // You *must* catch it and put it back in to avoid memory leaks CPen pen, *pOldPen; pen.Create(PS_SOLID, 1, RGB(255,0,0)); // Create a red pen, one pixel wide pOldPen = dc.SelectObject(&pen); // Now we can draw stuff using DrawREctangle, DrawEllipse, MoveTo, LineTo, etc. To draw filled shapes we need also create and select a brush to fill them. Then you create the paintDC, blt the CDC onto it, select the pointers you grabbed back into the DC and delete it ( using dc.DeleteDC(); ) I hope that helps. Christian I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in. The early bird may get the worm, but it's the second mouse that gets the cheese.

        M 1 Reply Last reply
        0
        • C Christian Graus

          If you're just drawing them ( i.e. they will not change ), you can do this in your OnPaint handler. Just use the methods already mentioned. If you want them to change/move, you will probably want to double buffer them, which means drawing them to another bitmap then copying it across just after creating the paintDC, to avoid flicker. To create a DC you do the following: CDC dc; dc.CreateCompatibleDC(NULL); // Creates a device context compatible with the screen CBitmap bm, *pOldBitmap; bm.Create(width, height, 1, GetDeviceCaps(dc.m_hDC, BITSPIXEL)); // Create a bitmap to draw onto pOldBitmap = dc.SelectObject(&bm); // Whenever you select something into a DC, a pointer to the old one is released // You *must* catch it and put it back in to avoid memory leaks CPen pen, *pOldPen; pen.Create(PS_SOLID, 1, RGB(255,0,0)); // Create a red pen, one pixel wide pOldPen = dc.SelectObject(&pen); // Now we can draw stuff using DrawREctangle, DrawEllipse, MoveTo, LineTo, etc. To draw filled shapes we need also create and select a brush to fill them. Then you create the paintDC, blt the CDC onto it, select the pointers you grabbed back into the DC and delete it ( using dc.DeleteDC(); ) I hope that helps. Christian I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in. The early bird may get the worm, but it's the second mouse that gets the cheese.

          M Offline
          M Offline
          mohini1989
          wrote on last edited by
          #4

          good

          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