device context overviewclasses: wxbuffereddc, wxbufferedpaintdc, wxdc, wxpostscriptdc, wxmetafiledc, wxmemorydc, wxprinterdc, wxscreendc, wxclientdc, wxpaintdc, wxwindowdc. a wxdc is a device context onto which graphics and text can be drawn. the device context is intended to represent a number of output devices in a generic way, with the same api being used throughout. some device contexts are created temporarily in order to draw on a window. this is true of wxscreendc, wxclientdc, wxpaintdc, and wxwindowdc. the following describes the differences between these device contexts and when you should use them.
to use a client, paint or window device context, create an object on the stack with the window as argument, for example:
void mywindow::onmycmd(wxcommandevent& event) { wxclientdc dc(window); drawmypicture(dc); }try to write code so it is parameterised by wxdc - if you do this, the same piece of code may write to a number of different devices, by passing a different device context. this doesn't work for everything (for example not all device contexts support bitmap drawing) but will work most of the time.
|