跳至內容

Palm OS/C/離屏視窗程式設計

來自華夏公益教科書,開放的書籍,開放的世界

請確保在所有啟動應用程式的事件傳遞完畢後,將焦點設定到您的離屏視窗上。


建立離屏視窗

[編輯 | 編輯原始碼]

(並記住您的應用程式最初啟動的原始視窗)

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


釋放離屏視窗

[編輯 | 編輯原始碼]
 Boolean  eraseIt = false;
 if ( offWin != NULL)
 {
   WinDeleteWindow( offWin, eraseIt);
 }


將焦點設定到離屏視窗

[編輯 | 編輯原始碼]
 WinSetDrawWindow( offWin);

在呼叫此函式之後,諸如WinEraseRectangle, WinDrawLine等等函式將繪製到離屏視窗上。


將您的離屏繪製內容轉存到原始視窗

[編輯 | 編輯原始碼]
 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);
華夏公益教科書