Hi,

I am tyring to write my own WinScreenLock/Unlock to prevent screen flicker but
am having some problems.  When I have "locked" the screen by using
WinSetDrawWindow I still have stuff writing to the screen and not to my
offscreen window.  Also, when the user minimizes or maximizes the graffiti
area, it does not seem to track.  I've included some code below to show what I
am doing.  I have a feeling that I am missing some baisc problem.  Anyone have
any ideas?

// globals

static WinHandle hScreen = NULL;
static WinHandle hOffscreen = NULL;


static void MyUpateForm(FormPtr pForm)
{
/*
   if(bROMOs35OrGreater)
      WinScreenLock(winLockErase);
*/
   MyScreenLock();

   MySizeForm(pForm); // handles moving of form control around

   FrmDrawForm(pForm); // draws the form

/*
   if(bROMOs35OrGreater)
      WinScreenUnlock();
*/
   MyScreenUnlock();
}


Boolean MyScreenLock(void)
{
   Err err;
   Boolean bRetVal = false;
   RectangleType rect;

   if(hScreen) {
      return false; // ??? clean me up
   }

   // ??? need to check for OS 3.5
   WinGetWindowFrameRect(WinGetDisplayWindow(), &rect);

   // setup some offscreen handles
   hOffscreen = WinCreateOffscreenWindow(rect.extent.x, rect.extent.y,
                   (bHighDensityDisplay ? nativeFormat : genericFormat),
                   &err);

   if(err == errNone) {
      hScreen = WinSetDrawWindow(hOffscreen);

      if(hScreen) {
         WinCopyRectangle(hScreen, hOffscreen, &rect, 0, 0, winPaint);
         bRetVal = true;
      }
      else {
         MyScreenUnlock();
      }
   }
   else {
      MyScreenUnlock();
   }

   return bRetVal;
}


void MyScreenUnlock(void)
{
   if(hScreen) {
      // set display back to screen
      WinSetDrawWindow(hScreen);

      if(hOffscreen) {
         RectangleType rect;

         WinGetWindowFrameRect(hOffscreen, &rect);
         WinCopyRectangle(hOffscreen, hScreen, &rect, 0, 0, winPaint);
      }

      hScreen = NULL;
   }

   // delete offscreen handles
   if(hOffscreen) {
      WinDeleteWindow(hOffscreen, false);
      hOffscreen = NULL;
   }
}

Thanks,

Mike

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to