Event handling, Paint events of subwindows

Christoph Borgolte cb at delta-h.de
Thu Jun 28 01:32:56 PDT 2007


Here is an example how I do it inside of my wxView derived class (XpltView):

void XpltView::Canvas_ConnectEvents()
{
    //EventHandling for the canvas
    mv_pCanvas->Connect(
        wxEVT_PAINT,
        wxPaintEventHandler( XpltView::Canvas_OnPaint ), NULL, this );

...
}


void XpltView::Canvas_OnPaint( wxPaintEvent &event )
{
    if ( ! GetXpltDocument()->Ok() )
        return;
    wxPaintDC dc( mv_pCanvas );
    clock_t start = clock();
    OnDraw( dc );
    double dTot( clock() - start );
    dTot /= CLOCKS_PER_SEC;
    GetFrame()->SetStatusText( wxT("Drawing Time: ") +
wxString::Format(wxT("%10.5lf"),dTot), 2 );
}






More information about the wx-users mailing list