|
-
December 12th, 2003, 03:02 AM
#1
saving the 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...
R. Thomas
"Be anxious for nothing, but in everything by prayer and supplication, with thanksgiving, let your requests be made know to God; and the peace of God, which surpasses all understanding, will guard your hearts and minds through Christ Jesus."Philippians 4:6-7
"Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|