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. Assertion error in OnDraw

Assertion error in OnDraw

Scheduled Pinned Locked Moved C / C++ / MFC
questiondata-structureshelp
5 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
    Anu_Bala
    wrote on last edited by
    #1

    I have drawn graph in OnDraw function,i got the graph..but when i minimized the window and getting back the position..it shows assertion error..What is tht? How cud i get rid of tht?

    A _ 2 Replies Last reply
    0
    • A Anu_Bala

      I have drawn graph in OnDraw function,i got the graph..but when i minimized the window and getting back the position..it shows assertion error..What is tht? How cud i get rid of tht?

      A Offline
      A Offline
      Abebe
      wrote on last edited by
      #2

      Perhaps you can provide us with the code of the OnDraw function? Er zit een korstje op mijn aars.

      A 1 Reply Last reply
      0
      • A Anu_Bala

        I have drawn graph in OnDraw function,i got the graph..but when i minimized the window and getting back the position..it shows assertion error..What is tht? How cud i get rid of tht?

        _ Offline
        _ Offline
        _anil_
        wrote on last edited by
        #3

        Try to debug and find where exactly is the assertion is? After minimizin place the break point in OnDraw and then maximize and debug.

        1 Reply Last reply
        0
        • A Abebe

          Perhaps you can provide us with the code of the OnDraw function? Er zit een korstje op mijn aars.

          A Offline
          A Offline
          Anu_Bala
          wrote on last edited by
          #4

          void CLineView::OnDraw(CDC* pDC) { //CLineDoc* pDoc = GetDocument(); //ASSERT_VALID(pDoc); // TODO: add draw code for native data here GetClientRect(&rect); pDC->FillRect((LPCRECT)rect,&CBrush(RGB(0,0,0))); CPoint PtLine[] = { CPoint( 100, 20), CPoint(100, 420), CPoint(700, 420) }; pDC->SelectStockObject(WHITE_PEN); pDC->SetBkColor(RGB(0,0,0)); pDC->SetTextColor(RGB(19,133,255)); pDC->MoveTo(PtLine[0]); pDC->LineTo(PtLine[1]); pDC->LineTo(PtLine[2]); int x1=160,y1=420,x2=100,y2=60; for(int i = 0;i<9;i++) { pDC->MoveTo(x1,y1); pDC->LineTo(x1,y1+5); x1=x1+60; pDC->MoveTo(x2,y2); pDC->LineTo(x2-5,y2); y2=y2+40; } gpen1.CreatePen(PS_SOLID,2,RGB(255,0,0)); pDC->SelectObject(&gpen1); for(int j= 0;j<8;j++) { pDC->SetPixel(a[j]+100,420-b[j],RGB(0,255,0)); pDC->MoveTo(a[j]+100,420-b[j]); pDC->LineTo(a[j+1]+100,420-b[j+1]); } pDC->TextOut(650,450,"X-AXIS"); pDC->TextOut(45,25,"Y-AXIS"); }

          _ 1 Reply Last reply
          0
          • A Anu_Bala

            void CLineView::OnDraw(CDC* pDC) { //CLineDoc* pDoc = GetDocument(); //ASSERT_VALID(pDoc); // TODO: add draw code for native data here GetClientRect(&rect); pDC->FillRect((LPCRECT)rect,&CBrush(RGB(0,0,0))); CPoint PtLine[] = { CPoint( 100, 20), CPoint(100, 420), CPoint(700, 420) }; pDC->SelectStockObject(WHITE_PEN); pDC->SetBkColor(RGB(0,0,0)); pDC->SetTextColor(RGB(19,133,255)); pDC->MoveTo(PtLine[0]); pDC->LineTo(PtLine[1]); pDC->LineTo(PtLine[2]); int x1=160,y1=420,x2=100,y2=60; for(int i = 0;i<9;i++) { pDC->MoveTo(x1,y1); pDC->LineTo(x1,y1+5); x1=x1+60; pDC->MoveTo(x2,y2); pDC->LineTo(x2-5,y2); y2=y2+40; } gpen1.CreatePen(PS_SOLID,2,RGB(255,0,0)); pDC->SelectObject(&gpen1); for(int j= 0;j<8;j++) { pDC->SetPixel(a[j]+100,420-b[j],RGB(0,255,0)); pDC->MoveTo(a[j]+100,420-b[j]); pDC->LineTo(a[j+1]+100,420-b[j+1]); } pDC->TextOut(650,450,"X-AXIS"); pDC->TextOut(45,25,"Y-AXIS"); }

            _ Offline
            _ Offline
            _anil_
            wrote on last edited by
            #5

            Anu_Bala wrote:

            gpen1.CreatePen(PS_SOLID,2,RGB(255,0,0)); pDC->SelectObject(&gpen1);

            First when ever you use SelectObject don't forget to Select back the old object e.g CPen NewPen; CPen* pOldPen; NewPen.CreatePen((PS_SOLID,2,RGB(255,0,0)); pOldPen = pDC->SelectObject(&NewPen); : :Draw the rest.... : // After Drawing pDC->SelectObject(pOldPen);

            Anu_Bala wrote:

            for(int j= 0;j<8;j++) { pDC->SetPixel(a[j]+100,420-b[j],RGB(0,255,0)); pDC->MoveTo(a[j]+100,420-b[j]); pDC->LineTo(a[j+1]+100,420-b[j+1]); }

            Second .. I think you might have problem in data of array a[] and b[] which may cause assertion. Where they are changing plz check. Regards Anil

            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