Solved

saving private processor

Posted on 2003-12-12
5
223 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
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
isEverywhere  challenge 19 82
matchUp  challenge 6 69
My project did see openJDK that I installed. What could be the problem 7 151
Path of Workbook 3 86
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

839 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