In the following piece of code, I am trying to get the handle for the
image I want to associate with the gadget.

static Boolean DrawGadget(FormPtr pFrm, UInt16 gadgetID)
{
        Boolean bDrawn = false;
        
        switch(gadgetID)
        {
                case CookieGadget:
                {
                        UInt16 gadgetIndex = FrmGetObjectIndex(pFrm, gadgetID);
                        MemHandle hGadgetImage = DmGetResource(bitmapRsc, 
bitmapCookieBtn);
                        BitmapType *gadgetImage = MemHandleLock(hGadgetImage);
                        RectangleType bounds;

                        // Get location of the gadget
                        FrmGetObjectBounds(pFrm, gadgetIndex, &bounds);
                        
                        WinDrawBitmap(gadgetImage, bounds.topLeft.x, bounds.topLeft.y);

                        MemHandleUnlock(hGadgetImage);
                        DmReleaseResource(hGadgetImage);
                }
                        bDrawn = true;  
                        break;
        }

        return bDrawn;
}

I have to pass bitmapCookieBtn to DmGetResource() because that is the only
time it knows which image I am putting in the gadget, right?  And, I
correctly get the location of the gadget in the form since gadgetIndex is
obtained from knowing which form and gadgetID, right?  I just want to know
that I am not screwing anything here =)


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