Programming for Palm OS/C/Off-screen windows

< Programming for Palm OS‎ | C

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 windowEdit

(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 windowEdit

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

to focus on an offscreen windowEdit

 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 windowEdit

 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);