I do this:
:
form->Paint += new PaintEventHandler( this,
$ThisClass:
aint_Event_Handler ) ;
:
void Paint_Event_Handler( Object^, PaintEventArgs^ e)
{
Graphics^ graphics = e->Graphics ;
// use graphics to draw your primitives here, like this:
Pen^ pen = gcnew Pen(Color::Red) ;
graphics->DrawRectangle( pen, 0, 0, 20, 20 ) ; // etc.
}
Note this draws your graphics every time the 'form's Paint event occurs.
This happens whenever some portion of 'form' is covered and then uncovered.
Hence, to actually SEE the graphics drawn in this way you need to execute
form->Refresh() to put on the screen what your drawing in the Paint event (I
think Refresh() causes the Paint event to fire, or at least executes the
Paint event handler).
This was all assuming /clr syntax in 2005. If you do use 2005, then I
STRONGLY recommend setting the DoubleBuffered property of your 'form' to
true, this will eliminate any flicker you might get. I personally also
double buffer manually, but that's another topic... : )
[==P==]