In article <65518@palm-dev-forum>,
 Joe Programmer <[EMAIL PROTECTED]> wrote:
> I am using the code below to show or hide the bitmap
> and the button.  On OS versions < 3.2 (I tested on
> 2.0, 3.0, 3.1 , 3.3, 3.5, and 4.0), the button gets
> corrupted (a sloppy rectangle is displayed at the
> wrong location and it doesn't respond to taps).  On OS
> versions >= 3.3 it works as expected.
> 
> Does anyone have any suggestions?

The documentation for FrmHideObject states explicitly that prior to 3.2, 
the usable bit wasn't cleared, and that you should explicitly clear it 
yourself. This unfortunately means directly touching system structures, 
which is now a no-no, but I don't think there's any way around it, yet. 
So if you're running in the emuolator, you need to turn off the 
UIDataMagr Access checkbox in the Debugging panel (or put up with the 
alerts it generates). Here's a routine that I use that might help:

void FrmReallyHideObject(FormPtr frmP, UInt16 objIndex)
{
   FormObjectKind objKind;
   void*       objP;
   UInt32         osVersion;
   
   FtrGet( sysFtrCreator, sysFtrNumROMVersion, &osVersion );

   // Prior to OS 3.2, FrmHideObject doesn't actually set the usable bit.
   // As recommended, we set it manually here (a pain, since the location
   // of the bit is type-dependent!).
   FrmHideObject(frmP, objIndex);
   objKind = FrmGetObjectType(frmP, objIndex);
   objP = FrmGetObjectPtr(frmP, objIndex);
   
   // !!! Note: this is not a complete list of types. We're only doing
   // the ones we know we need right now

   if (osVersion < sysMakeROMVersion(3,2,0,sysROMStageRelease,0))
   {
      switch( objKind )
      {
         case frmControlObj:
            ((ControlType*)(objP))->attr.usable = 0;
            break;
         
         case frmBitmapObj:
            ((FormBitmapType*)(objP))->attr.usable = 0;
            break;
         
         case frmGadgetObj:
            ((FormGadgetType*)(objP))->attr.usable = 0;
            break;
         
         case frmLabelObj:
            ((FormLabelType*)(objP))->attr.usable = 0;
            break;
         
         case frmScrollBarObj:
            ((ScrollBarType*)(objP))->attr.usable = 0;
            break;
         
         default:
            break;
      }
   }
}

Hope that helps,

Dave Johnson

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

Reply via email to