Bill Woodruff
10/28/2004 12:48:00 PM
For a while I had a "mental model" that for controls (say, a panel) that the
Graphics object you would get inside the Paint event by doing :
Graphics panelPaintGraphics = e.Graphics;
// do something ....
Was probably a pointer to an object that might be moved around in memory, that
it was "automagically" disposed when the Paint event was exited.
Thus, I assumed that you had to get the pointer "fresh" every time to do the
drawing business you wanted to do. But a friend here suggested just creating a
Graphics object off the control using 'CreateGraphics :
Graphics panelGraphics = thePanel.CreateGraphics();
And, to my surprise, I found that was re-usable across many Paint events.
I would appreciate any insights you may have into the behavior of Forms,
UserControls, etc. compared to Panels in this regard.
The specific project I am working on involves bit-blitting from a very large
source image, and I have it working fairly well to a panel surface, but am
curious is it might be better to be blitting to a form surface, or a usercontrol
surface.
thanks, Bill
"wisdom is when no one doubts your own hypotheses more than you do, honesty is
when no one is more willing to revise your incorrect hypotheses than you are,
and humanity is when you abandon your hypotheses and face the beauty and
complexity of life with an open, vulnerable, and sincere heart."