Then I picked one drawing using mouse and drag it ( move it) to other place. when I move the drawing very slow (using mouse to move it slowly), it looks OK. But a little bit faster, there will be some dirty (some drawing not cleared) left on screen. Is there a way to avoid this?
Yes, but I cannot recall the method. I think it's something to do with capturing the mouse and delaying repaint of the Window. Try a search on MSDN for what you are doing and see if you get any good hits.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
What are you invalidating? ...this may be caused by you invalidating only a small portion of a window independent of the rest of the window (causing unnecessary redraws) or by invalidating somewhere where you probably shouldn't (also causing unnecessary redraws).
You really need to share more of the code for a more definitive solution.
InvalidateRect() does what it is supposed to do. If you are leaving mess on the screen, it is because your rectangle is wrong / too small / etc. Or if your Invalidate / Paint rectangle is mismatched. What I mean is, if you move the mouse fast, you might erase 0,0,100,100, but by the time you get to the paint, you are working on rectangle 10,10,110,110. Also, how are you getting the rect to paint? The one that comes in through GetUpdateRect() is often wrong / slightly off.
I am sure the problem is not from the region that needed to be updated.
Then you would be highly mistaken sir!
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.
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 .
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 .
BOTTOM LINE: if your update rectangle was correct, you wouldn't be here posting your question, now would you?
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 . MFC was fine in 1986. Sorry , had to be said . 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 .
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.
Several things come to mind:
1. The parameter "rect" refers to only the "area" that will be invalidated. If the objects you're moving occupy the entire client area, try using the function as follows: InvalidateRect(NULL);
2. With a little more work you may want to "buffer" output for speedier and flicker free operation.
sometimes the operation of the non-blocking (a nonblocking) sockets, can not be completed immediately, it will return this error code. This error is not a serious error, the operation will again after some time try to perform. Since the establishment of the connection will inevitably take some time, so sometimes a nonblocking SOCK_STREAM socket call CONNECT back to the WSAEWOULDBLOCK (10 035) error code
I am looking for a simple Asymetric Encryption method, preferably implemented via the Crypto API, to encrypt a block of approx 4K Data. The Data consists of an End User Licence Structure, to be encrypted with my Private Key. The (Public) Decryption key is to be stored in one of the Core DLL's for the suite, which will be responsible of de-crypting the licence, and starting the Appilcations.
CAPICOM deals with key-stores, and other remote Items that invest themselves in the Registry. I am looking for something far simpeler.:
- A Basic Method of generating a Key Pair, to be stored in some Binary Format,
- A Basic Encryption/Decryption method using those keys.
Today I received the source code for a DLL developed by a small company for us. The source code was part of the deal, and one of it's purposes was that we should be able to continue maintenance efforts once the main functionality of the library is done, and no more big issues remain.
Unfortunately, I've found the source code to be written auto-generated as CWEB, using a Literate Programming tool. That means these files cannot be directly read by the compiler, nor interpreted with the integrated tools of the IDE. I've requested the 'tangled' C++ source files (i. e. processed by ctangle.exe into .h and .cpp files), to be able to at least read them into my UML tool, but that code has all comments and blanks removed, so is not in a suitable form to be read in the IDE either.
In the UML tool I now have several hundred classes, structs, typedefs and enums all entangled into one huge diagram. The information I get from this is nicely summarized into one word: HELP!
What I currently have is:
- 359 auto- generated CWEB files (.w extension, some with a .hw extension, and a few others), in one and the same directory (actually I believe some of these are in fact not generated and don't belong there)
- these CWEB files have comments and proper formatting, but are unreadable by my tools
- alternately 245 C++ files (no idea why there are less of these)
- C++ files have no comments or blanks or tabs (but do have linebreaks at least)
- There's no 1-1 relation between source files and classes (neither for the CWEB files nor the C++ files): the total number of classes is around 300-500. Apparently some files contain dozens of classes, others none at all.
In short, it's a total mess.
I'm now at a loss what to do about it: I can no longer trust the original programmer to maintain it (there already has been significant doubt before), but I have no idea how to take care of it myself either. Since the whole of it is just generated code, I'd have to look at the original code used to generate the .w files, but I am neither familiar with Literate Programming, nor with the tools available for them. Also I have the nagging feeling that I won't be able to use any of the tools that I know if I wanted to work with that code.
I don't see any sense in refactoring the generated code into managable packages. But what else can I do? At this point the only alternative I see is rewrite the entire library from scratch
Maybe someone with experience in Literate Programming can give me an estimate as to how much time it would take for me to get into it, to a point where I would be able to clean up on the higher level?
1. No. The only additional 'information' they contain are the comments. But then I would be better served by the original files used to generate them: they too are illegible to my tools, specifically as they do use lots of symbols that may not even be printed correctly without the right editor, but at least that code is at least theoretically meant to be human-readable
2. Yes: manually I can just press Ctrl-A, Ctrl-K, Ctrl-F. it's just that I don't feel like doing that for 245 files, and definitely not again when there is an update and the entire set of files gets regenerated. But even if there will be no updates, reformatting does not add the comments back in, nor remove the annoying compiler directives that make VA Outline all but unreadable in larger files. Besides, even formatting doesn't change the fact that the code wasn't generated with readability in mind...