Solved

Flikering

Posted on 2000-02-20
8
200 Views
Last Modified: 2013-11-20
I am working on istrument interfacing project on VC++ 6.0.
in which i am showing differerent displayes like grpah ,tabular,analog,digital.
i am using bitblt function to draw background of grah & platting graoh in onDraw with linto moveto function.
i am invalidating area bounded by x- y axis of graph.
Then also i am getting flikering,
can anybody will suggest me how to go for this problem.
0
Comment
Question by:jaydeep
  • 3
  • 3
  • 2
8 Comments
 

Expert Comment

by:bertp
ID: 2540394
two suggestions

first and easiest:
override the CWnd::OnEraseBkgnd()mesage;
afx_msg BOOL OnEraseBkgnd( CDC* pDC )
simply return TRUE to tell
windows to not erase the client area
before you draw.  this might be sufficient for you...

second if you still see flicker aand you have confirmed that your OnEraseBkgrnd is being called and is  returning a nonzero value.. then you shoud draw instead to a memory DC instead of to a window dc..
after you have finished building your memory dc, just blit the memory dc to the window dc....

In case you need it I have found an explicit example with explanation at:
http://codeguru.developer.com/misc/flicker_free_drawing.shtml

good luck


 
0
 

Author Comment

by:jaydeep
ID: 2541076
hi!
i tried erase background,if i override
that & return true it doesn't do anything.it doesn't paint at all
one more thing i am arealy using bilblt
using memory DC.i will explain you what io am doing.
1.i am drawing on memedc(that bkgroung og graph
2.draeong(plaotting graph in ondraw))
3.to show updated regoin i have to invalidate bounded rect by x-y.
4. so that invalidted region flikers.

i ahve seen one example in MSDN help.
a cor moving ,there is tree behind it.it doesn't fliker at all,even yoy can see tree through car window,there is not at all flokering.they have used masking,i did not uderstand it.

one more thing the rate at which i am getting reading from intruments is 10 raedings/sec
0
 

Expert Comment

by:bertp
ID: 2543005
hmmm, I used this technique back in the days of  c & the sdk and it worked fine so I would  suspect that it has something to do with the doc/view system of MFC... except that the example in the link I posted specifically mentions a view...

guessing bigtime here,  perhaps you are rendering only a portion but redrawing the whole view with a MemDC that is mostly the background color...  see what happens if you rerender the whole view each time and redraw the whole view with each OnDraw... If this works then you can continue on a figure out why you cannot draw just the portion. But unless your view requires alot of
complex calculations or disk access it will probably be just as flicker-free to redraw the whole view on each OnDraw()
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Expert Comment

by:bertp
ID: 2558479
Hi
  If you're still having trouble you should consider rejecting my answer so that you can again get help from others
Good Luck!
0
 

Accepted Solution

by:
leandrobecker earned 15 total points
ID: 2619944
First:

Only return TRUE when receive the WM_ERASEBKGND:

Example

BOOL CYourWnd::OnEraseBkgnd(CDC* pDC)
{
      return FALSE;
}

Second:

In your paint function use a memory DC like this:

void CYourWnd::OnPaint()
{
      CPaintDC dc(this); // device context for painting
      CDC memDC;
      CBitmap bitMem,*bitOld;
        CRect rect;
        GetClientRect(&rect);

      memDC.CreateCompatibleDC(&dc);

      
bitMem.CreateCompatibleBitmap(&dc,rect.Width(),rect.Height());

      bitOld = memDC.SelectObject(&bitMem);

       memDC.FillSolidRect(&rect,0x00FFFFFF);
      
      //do your paints using memDC

      dc.BitBlt(0,0,rect.Width(), rect.Height()),&memDC,0,0,SRCCOPY);

      memDC.SelectObject(OldFont);
      memDC.SelectObject(bitOld);
}
0
 

Author Comment

by:jaydeep
ID: 2620828
hi!
thanks for help.
i could solve this problem,
There was problem with sequence of function call.

Now i am i am not erasing present background i am calling Invalidate(FALSE)
 & where i need immidiate refelction of change i am calling UpdateWindow,which
calls WM_PAINT with priority,
this solved my problem

thanks for help
0
 

Expert Comment

by:leandrobecker
ID: 2623580
HI jaydeep

If the answer has helped you, please
select it how the answer for you question. Thanks
0
 

Author Comment

by:jaydeep
ID: 2787001
i have already solved the problem ,
thanks for help.

jaydeep
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeatEnd java challenge 42 84
iSeries FTP Exit Program 8 135
sum13 challenge 24 105
Bartender label printing - switch on and off graphics 3 36
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. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now