Solved

saving private processor

Posted on 2003-12-12
5
234 Views
Last Modified: 2013-11-20
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...
0
Comment
Question by:joseph-r-thomas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 13

Expert Comment

by:SteH
ID: 9926763
With your code you are doing for every OnPaint event a iteration of 375000 FillRects. How often does the colors change? My suggestion is to replace the loop in some other function to fill a bitmap with that pattern and in the OnDraw handler you just BitBlt this bitmap into your device context. For updating this bitmap you should think about looking for changed colors and modify only those parts.
0
 
LVL 13

Expert Comment

by:SteH
ID: 9926853
This is highly related to your Q
www.expersts-exchange.com/Q20823821.html
The my answer there, it should solve this problem as well.
0
 
LVL 13

Expert Comment

by:SteH
ID: 9926867
0
 

Author Comment

by:joseph-r-thomas
ID: 9932738
hope u could pls drop me a line at
extremedotnet@yahoo.com.sg
i could send u m proj..its very small..
hope to hear from u soon...
tks a lot..
0
 
LVL 13

Accepted Solution

by:
SteH earned 20 total points
ID: 9940580
Solving problems with use of e-mail is forbidden by the membership agreement you signed as well. You could put it on a public www page, where everyone is able to see it as he wants to.

And I still feel that you should follow my suggestion I posted in
http://www.experts-exchange.com/Q_20823821.html
which merely is to fully understand the solution to
http://www.experts-exchange.com/Q_20817068.html
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question