Click here to Skip to main content
15,891,864 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: "InvalidateRect" leaves dirty on screen Pin
Richard MacCutchan3-Feb-12 4:02
mveRichard MacCutchan3-Feb-12 4:02 
GeneralRe: "InvalidateRect" leaves dirty on screen Pin
transoft3-Feb-12 4:11
transoft3-Feb-12 4:11 
GeneralRe: "InvalidateRect" leaves dirty on screen Pin
Richard MacCutchan3-Feb-12 4:39
mveRichard MacCutchan3-Feb-12 4:39 
AnswerRe: "InvalidateRect" leaves dirty on screen Pin
Albert Holguin3-Feb-12 5:11
professionalAlbert Holguin3-Feb-12 5:11 
GeneralRe: "InvalidateRect" leaves dirty on screen Pin
transoft3-Feb-12 6:02
transoft3-Feb-12 6:02 
GeneralRe: "InvalidateRect" leaves dirty on screen Pin
SledgeHammer013-Feb-12 14:14
SledgeHammer013-Feb-12 14:14 
GeneralRe: "InvalidateRect" leaves dirty on screen Pin
transoft4-Feb-12 4:34
transoft4-Feb-12 4:34 
GeneralRe: "InvalidateRect" leaves dirty on screen PinPopular
SledgeHammer014-Feb-12 7:49
SledgeHammer014-Feb-12 7:49 
transoft wrote:
I am sure the problem is not from the region that needed to be updated.


Then you would be highly mistaken sir! Smile | :)

Win32 drawing is message based (WM_ERASEBKGND & WM_PAINT). When you move slowly, you are getting all the messages point by point and your painting works correctly. When you are moving quickly, you MAY NOT get all messages. Windows is not going to send you a message for every single point when you are moving the mouse around like a crazy person! It compensates for that by skipping points.

What I indicated in my original response is your issue. 100% guaranteed.

You draw something at 0,0,100,100 and then move the mouse so quickly, the system never sends you an erase / paint cycle for 0,0,100,100 because you are already at 10,10,110,110.

For example:

Enlarging the rectangle by 0.0 may work for moving the mouse up to "10MPH"
Enlarging the rectangle by 1.0 may work for moving the mouse up to "20MPH"
Enlarging the rectangle by 2.0 may work for moving the mouse up to "50MPH"

So you get excited and enlarge the rectangle by 3.0 and everything works perfectly, right? NO. Everything works perfectly on YOUR machine which is a super duper gaming machine with a high end video card.

Then you take your app over to Bobs machine which has a lousy graphics card, anti-virus app running in the background and is cluttered with spyware from all his porn sites.

On Bob's machine, your app only works for moving the mouse up to "7MPH" and you get furious and start foaming at the mouth all angry!

True story Smile | :) .

I have been doing Win32 GUI apps for 16 years and am a custom control master. I am fully aware of how the system works and all the nuances Smile | :) .

BOTTOM LINE: if your update rectangle was correct, you wouldn't be here posting your question, now would you? Smile | :) Smile | :) Smile | :)

Over the years, I have learned that painting by update region is often a practice in futility and you will never get it perfect across machines at every mouse speed / video card combo.

You **MUST** double buffer your screens and keep track of what you drew on. DO NOT RELY ON WINDOWS TO SEND YOU ALL POINTS!!!

One other option is to realize that today is the year 2012 and move on to a "big boy" architecture like WPF where we don't worry about such nonsense anymore Smile | :) . MFC was fine in 1986. Sorry Smile | :) , had to be said Smile | :) . I don't program in Win32 / MFC anymore after all these years because I refuse to deal with crap like pixel droppings anymore and instead focus on the application Smile | :) .

But my response still stands. Your update rectangle can NOT be correct or your app would be working. It is not necessarily your fault... Win32 just doesn't feel like sending you all the information you need to do your "optimized" drawing.
GeneralRe: "InvalidateRect" leaves dirty on screen Pin
MikeTHennessy7-Feb-12 12:10
MikeTHennessy7-Feb-12 12:10 
QuestionCAsynSocket connection problem Pin
ForNow2-Feb-12 16:03
ForNow2-Feb-12 16:03 
AnswerRe: CAsynSocket connection problem Pin
«_Superman_»2-Feb-12 18:07
professional«_Superman_»2-Feb-12 18:07 
GeneralRe: CAsynSocket connection problem Pin
ForNow2-Feb-12 18:49
ForNow2-Feb-12 18:49 
AnswerRe: CAsynSocket connection problem Pin
pyunwang2-Feb-12 19:00
pyunwang2-Feb-12 19:00 
GeneralRe: CAsynSocket connection problem Pin
ForNow2-Feb-12 19:59
ForNow2-Feb-12 19:59 
QuestionSimple Asymetric Encryption Pin
Bram van Kampen2-Feb-12 14:23
Bram van Kampen2-Feb-12 14:23 
AnswerRe: Simple Asymetric Encryption Pin
Chris Losinger5-Feb-12 5:07
professionalChris Losinger5-Feb-12 5:07 
QuestionHow to maintain an external C++ DLL developed with Literate Programming? Pin
Stefan_Lang2-Feb-12 4:59
Stefan_Lang2-Feb-12 4:59 
QuestionRe: How to maintain an external C++ DLL developed with Literate Programming? Pin
David Crow2-Feb-12 5:29
David Crow2-Feb-12 5:29 
AnswerRe: How to maintain an external C++ DLL developed with Literate Programming? Pin
Stefan_Lang2-Feb-12 6:10
Stefan_Lang2-Feb-12 6:10 
QuestionRe: How to maintain an external C++ DLL developed with Literate Programming? Pin
David Crow2-Feb-12 9:21
David Crow2-Feb-12 9:21 
AnswerRe: How to maintain an external C++ DLL developed with Literate Programming? Pin
Stefan_Lang2-Feb-12 22:14
Stefan_Lang2-Feb-12 22:14 
AnswerRe: How to maintain an external C++ DLL developed with Literate Programming? Pin
jschell2-Feb-12 8:39
jschell2-Feb-12 8:39 
GeneralRe: How to maintain an external C++ DLL developed with Literate Programming? Pin
Stefan_Lang2-Feb-12 21:56
Stefan_Lang2-Feb-12 21:56 
GeneralRe: How to maintain an external C++ DLL developed with Literate Programming? Pin
jschell3-Feb-12 10:23
jschell3-Feb-12 10:23 
GeneralRe: How to maintain an external C++ DLL developed with Literate Programming? Pin
Stefan_Lang6-Feb-12 5:53
Stefan_Lang6-Feb-12 5:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.