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. saving private processor

saving private processor

Scheduled Pinned Locked Moved C / C++ / MFC
c++csshelpquestion
2 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.
  • R Offline
    R Offline
    R Thomas 0
    wrote on last edited by
    #1

    hi, below is my on draw... it works fine as below... code: -------------------------------------------------------------------------------- void CEditorView::OnDraw(CDC* dc) { CMemDC pDC(dc); OnPrepareDC(pDC); CEditorDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here - use pDC //as the device context to draw to // //Set the mapping mode to LOENGLISH // pDC->SetMapMode(MM_LOENGLISH); // //Convert arguments to coordinates to MM_LOENGLISH units. // CSize szTemp; szTemp.cx = pDoc->GetGridX(); szTemp.cy = pDoc->GetGridY(); pDC->DPtoLP(&szTemp); // // then draw the grid lines // CRect clipBoxRect; pDC->GetClipBox(&clipBoxRect); for(int x = 10 ; x <= pDoc->GetGridX() ; x += 10) { pDC->MoveTo(x, -10); pDC->LineTo(x, -pDoc->GetGridY()); } for(int y = -10 ; y >= -pDoc->GetGridY() ; y -=10) { pDC->MoveTo(10, y); pDC->LineTo(pDoc->GetGridX(), y); } }-------------------------------------------------------------------------------- it works perfectly fine as below.... now the problem is i wanan add this to my above code code: -------------------------------------------------------------------------------- // //Draw the squares // /*for(int i = 0 ; i < 500 ; i ++) { for(int j = 0 ; j < 750 ; j ++) { COLORREF color = pDoc->GetSquareColor(i, j); CBrush brush(color); int x1 = (j * 10) + 10; int y1 = (i * -10) - 10; int x2 = x1 + 10; int y2 = y1 - 10; CRect rect(x1, y1, x2, y2); pDC->FillRect(rect, &brush); } }*/-------------------------------------------------------------------------------- when i do this... all the processing power of the processor is eaten up by the processor.... can someone pls tell me a solution by which i can incorporate the above code to my View's OnDraw such that i can still retain my processing power???? tks a lot... Have a Super Blessed Day! ------------------------- For God has not given us a spirit of fear, but of power and of love and of a sound mind. 2 Timothy 1:7 "For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life." John 3:16 "Therefore you also be ready, for the Son of Man is coming at an hour you do not expet." Luke 12:40

    P 1 Reply Last reply
    0
    • R R Thomas 0

      hi, below is my on draw... it works fine as below... code: -------------------------------------------------------------------------------- void CEditorView::OnDraw(CDC* dc) { CMemDC pDC(dc); OnPrepareDC(pDC); CEditorDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here - use pDC //as the device context to draw to // //Set the mapping mode to LOENGLISH // pDC->SetMapMode(MM_LOENGLISH); // //Convert arguments to coordinates to MM_LOENGLISH units. // CSize szTemp; szTemp.cx = pDoc->GetGridX(); szTemp.cy = pDoc->GetGridY(); pDC->DPtoLP(&szTemp); // // then draw the grid lines // CRect clipBoxRect; pDC->GetClipBox(&clipBoxRect); for(int x = 10 ; x <= pDoc->GetGridX() ; x += 10) { pDC->MoveTo(x, -10); pDC->LineTo(x, -pDoc->GetGridY()); } for(int y = -10 ; y >= -pDoc->GetGridY() ; y -=10) { pDC->MoveTo(10, y); pDC->LineTo(pDoc->GetGridX(), y); } }-------------------------------------------------------------------------------- it works perfectly fine as below.... now the problem is i wanan add this to my above code code: -------------------------------------------------------------------------------- // //Draw the squares // /*for(int i = 0 ; i < 500 ; i ++) { for(int j = 0 ; j < 750 ; j ++) { COLORREF color = pDoc->GetSquareColor(i, j); CBrush brush(color); int x1 = (j * 10) + 10; int y1 = (i * -10) - 10; int x2 = x1 + 10; int y2 = y1 - 10; CRect rect(x1, y1, x2, y2); pDC->FillRect(rect, &brush); } }*/-------------------------------------------------------------------------------- when i do this... all the processing power of the processor is eaten up by the processor.... can someone pls tell me a solution by which i can incorporate the above code to my View's OnDraw such that i can still retain my processing power???? tks a lot... Have a Super Blessed Day! ------------------------- For God has not given us a spirit of fear, but of power and of love and of a sound mind. 2 Timothy 1:7 "For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life." John 3:16 "Therefore you also be ready, for the Son of Man is coming at an hour you do not expet." Luke 12:40

      P Offline
      P Offline
      Peter Molnar
      wrote on last edited by
      #2

      It is not advisable to have a lenghty operation like yours within the UI thread because it gets blocked. Look up worker threads in MSDN. Peter Molnar

      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