Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GdiPLusX Drawing on a form with scrollbars
Message
From
17/12/2007 06:20:06
 
 
To
17/12/2007 06:02:08
General information
Forum:
Visual FoxPro
Category:
VFPX/Sedna
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP1
Miscellaneous
Thread ID:
01276096
Message ID:
01276229
Views:
28
Sergio,

Drawing directly on the surface of the form will CERTAINLY improve your performance, but this technique is tricky also.

The main problem is to take care of the form redrawings, when resizing, minimize/maximize, moving the form. Even changing the scrollbars may delete your drawings.


My other other recommendation is that you should first create an empty bitmap, and get the Graphics hadle from it. Use this Gfx object to do all your drawings. When finished, draw the whole created image in just one time in the Screen. This will make a big difference, and will also reduce some annoying flickering effects.




>>Hi Sergio,
>>
>>I'm glad to know it worked !
>
>Hi Cesar,
>
>Your tip worked like a charm, but (speed) effect I wanted to achieve
>did not happen;
>I tought at first that drawing on ImageCanvas is what causes 'delays'
>in showing drawings, so using tip you provided me here I diverted my drawing directly to form surface hoping that my drawings will show up instantly.
>(Impression I had when I forst tried drawing directly to it)
>
>Well it might be a strange way to realise speed of ImageCanvas, but this is how I come to it <g> .
>I realised that there is not much (if any) speed difference between the two! (ImageCanvas = Fast!)
>
>So, It is NOT ImageCanvas but sheer quantity of my own drawings that causes 'delay'.
>
>Now 'delay' is quet understandable ;
>To draw full page there could be 300-400 strings
>to write across canvas, 20-30 lines, or rect. pics etc.
>This way 'Overfilled' canvas can take close to 2 seconds to surface it all.
>
>Since I am doing drawings via my own drawing class which (wrapped/automated GdiPlusX sample drawings made to be generic)
>everytime I draw string class method would I create new font ;
>
>
>.
>loFont = .font.New(loFontFamily,nFontSize , .FontStyle.Regular, .GraphicsUnit.pixel )
>.
>
>
>The same goes for pens, paths, rectangles, graphics etc.
>Since class methods are generic they would create new pen, new rectangle
>etc. everytime they are called.
>
>Now what I am interested is is there any way to optimize performance
>here by preserving let say font object for consecutive strings, or pens, or brushes, or colors etc.
>(Or simply by *not* doing something that causes performance decay)
>
>Would it make any diff to drawing speed if I sort string drawing sequences
>by top or left position. (Draw By row or by column) ?
>
>In my case, majority of renderings are as a matter of fact strings so this area for sure needs optimising (if possible) first.
>
>Any speed improvement hints are greatly appreciated :)
>
>TIA
>Sergio
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform