Oops, just realised I forgot to Unlock the handles.
You need to add MemHandleUnlock(resHandle) after both of the MemMove you
see in the code.
Regards
John  

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of John Sutton
Sent: 28 September 2006 09:51
To: Palm Developer Forum
Subject: RE: winBitmap

Durgesh,
I think the easiest way to achieve what you want is to put a normal
button on your form the exact same size and position that you intend to
draw the application icon/bitmap.
When you get a lstSelectEvent, draw the new bitmap/icon over the top of
the button.
When you get a ctlSelectEvent, make sure it's the right button and
respond by launching the relevant app.

As for getting the bitmap pointer for the relevant application creator,
see the code below.
Regards
John Sutton

Here's a function that will return a bitmap pointer for an application
given the creator id.  Enjoy...

BitmapPtr GetApplicationIcon(ULong creator) {
        DmOpenRef dbR;
        DmSearchStateType stateInfo;
        LocalID dbID;
        UInt16 cardNo;
        Int resIndex;
        VoidHand resHandle;
        static BitmapPtr bitmap=NULL;
        BitmapPtr appBitmap;
        
        // Free the previous bitmap memory if there was any
        if(bitmap)
                MemPtrFree(bitmap);
        // If there's no creator id - this was a clean up so just return
        if(!creator)
                return 0;
        // Find the most recent version of the 'appl' database for this
creator
        if(DmGetNextDatabaseByTypeCreator(true,
&stateInfo,'appl',creator,true,&cardNo,&dbID))
                return 0;
        // Open the database if it was found
        if(!(dbR=DmOpenDatabase(cardNo,dbID,dmModeReadOnly)))
                return 0;
        // Find the application icon resource
        resIndex=DmFindResource(dbR, 'tAIB',1000,NULL);
        // If the application resource was found
        if(resIndex!=-1)
        {
                // Make an in memory copy of the application icon
                resHandle=DmGetResourceIndex(dbR,resIndex);
                appBitmap=MemHandleLock(resHandle);
                bitmap=MemPtrNew(MemHandleSize(resHandle));
                MemMove(bitmap,appBitmap,MemHandleSize(resHandle));
        }
        // Close the database
        DmCloseDatabase(dbR);
        // If we didn't already find the application icon, check in the
'ovly'
        if(resIndex==-1)
        {
                // Is there an 'ovly' database for this creator
                if(DmGetNextDatabaseByTypeCreator(true,
&stateInfo,'ovly',creator,true,&cardNo,&dbID))
                        return 0;
                // Open the 'ovly' database for this creator
                if(!(dbR=DmOpenDatabase(cardNo,dbID,dmModeReadOnly)))
                        return 0;
                // Find the application icon resource
                resIndex=DmFindResource(dbR, 'tAIB',1000,NULL);
                // If the application resource was found
                if(resIndex!=-1)
                {
                        // Make an in memory copy of the application
icon
                        resHandle=DmGetResourceIndex(dbR,resIndex);
                        appBitmap=MemHandleLock(resHandle);
                        bitmap=MemPtrNew(MemHandleSize(resHandle));
        
MemMove(bitmap,appBitmap,MemHandleSize(resHandle));
                }
                // Close the database
                DmCloseDatabase(dbR);
        }
        // Return the pointer to the bitmap
        // The calling function must check for null being returned if
the icon was not found
        return bitmap;
} 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Durgesh
Trivedi
Sent: 28 September 2006 05:52
To: Palm Developer Forum
Subject: RE: winBitmap


But it is able to draw only the bitmap of only my application means if i
give the creator id of my application it will draw bitmap on frm but if
i give the creator id of any other application it is not doing any
thing.And if i use 'ovly' wat u suggest it will give baddbref error

And my actual problem to draw that bitmap on graphic button is still
their or i have to try 4 key over event on the bitmap such a way that it
wrk like a button.Bcz i allready told in my previous thread the way i
have to wrk,is  when ever i click on the button  it would be launch the
related application and that application icon should be on that button.
please help me .
  
--
For information on using the PalmSource Developer Forums, or to
unsubscribe, please see http://www.palmos.com/dev/support/forums/

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

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

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

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

Reply via email to