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