Programming for Palm OS/C/Off-screen windows

Be sure to focus on your offscreen window after all the events have been delivered for the start-up of your application.


to create an offscreen window

edit

(and to remember the original window that your application started with)

 WinHandle  offWin;
 WinHandle  sysWin;
 Coord             width  = 160;
 Coord             height = 160;
 WindowFormatType  format = screenFormat;
 UInt16            error;
 offWin = WinCreateOffscreenWindow( width, height, format, &error);
 sysWin = WinGetDrawWindow();


to release an offscreen window

edit
 Boolean  eraseIt = false;
 if ( offWin != NULL)
 {
   WinDeleteWindow( offWin, eraseIt);
 }


to focus on an offscreen window

edit
 WinSetDrawWindow( offWin);

After this invocation, functions such as WinEraseRectangle, WinDrawLine and so on will draw to the offscreen window.


to blit your offscreen drawing to the original window

edit
 WinHandle         srcWin;
 WinHandle         destWin;
 RectangleType     r;
 Coord             destX;
 Coord             destY;
 WinDrawOperation  mode;
 
 srcWin = offWin;
 destWin = sysWin;
 r.topLeft.x = 0;
 r.topLeft.y = 0;
 r.extent.x = 160;
 r.extent.y = 160;
 destX = 0;
 destY = 0;
 mode = winPaint;
 WinCopyRectangle( srcWin, destWin, &r, destX, destY, mode);