Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

saving private processor

Posted on 2003-12-12
5
Medium Priority
?
245 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 60 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

610 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