So... from that point,do you can tell me is my function ok now after adding DeleteObject,because i think that now work fine?
Yes Aurel, if you are talking about the entire set of drawing functions in ruben2
after you added my corrections, then I can say that they are OK and they do not cause GDI leaks in this particular program.
In order to revise any other 3rd-party functions before you add them to ruben2, or create your own ones, just memorise a few simple rules of handling Windows device contexts and GDI objects:
1.
Release the device contexts that you
Get in your code when you are done working with them.
2.
Delete the device contexts that you have
Create'd when they are no longer needed.
3. Always store the GDI objects that are already present in your device contexts which you have
Get'ed (gotten) or
Create'd, whenever you use SelectObject() to add a new GDI object to a device context. The device contexts are never empty; even newly created DC's already have their default font, pen, brush, and 1x1 px BMP pre-selected into them.
4. Always restore the old GDI objects
before you try to delete the new ones with a call to DeleteObject(). GDI objects including BMP's
cannot be deleted if they are still selected into a DC.
5. Some drawing functions, e.g. FillRect(), don't need the respective GDI object (in this case, a brush) to be selected into the device context. Such a GDI object can
and should be deleted directly with a call to DeleteObject() when it is no longer needed.
6. When deleting a device context, first re-select
all the old GDI objects that you have changed with your calls to SelectObject() and only then delete the DC proper. There's no sense in trying to re-select anything into a DC that's already been deleted.
Simple, eh?
There is no big difference if i have some calculations or some other executions
inside this loop...it looks to me that speed(time) depend of number of iteration.
Again ...maybe i am completely wrong .
You simply can't see the real speed with which your integer tokens can run in a Select Case- or in a jump table-based loop as long as everything else works 100 times slower with string arguments. You have to change the entire concept of ruben
3 to some decent 3rd-party prototype, perhaps, this toy2 proggy.
Ok about Ed toy2 i will open new topic in interpreters..
Yes, please do.