[futurebasic] Re: [FB] Copy of system icon to clipboard

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2006 : Group Archive : Group : All Groups

From: Alain Pastor <apastor@...>
Date: Wed, 22 Feb 2006 19:28:03 +0100
Yoshiyuki Hasegawa a écrit :
> Robert Purves wrote:
>> Yoshiyuki Hasegawa wrote:
>>
>>> Please teach the code in which the system icon is copied to the
>>> clipboard.
>>
>> Add the function PictToClip, and replace DoDialog as sbhown below:
>>
> Thank you for the response.
> 
> The copy succeeded.
> 
> However, the background becomes white, and can you do transparently?
> 

Yoshi,

Toying with your code, I chose a different approach than what Robert has 
suggested, but I don't know if it is the correct way to do such things. 
Anyway, the function below seems to copy correctly the icon on the 
Clipboard although no image is shown when you display the Clipboard's 
contents in the Finder. However, if you use a resource editor, it seems 
that you can paste the icon with its mask correctly:

local fn CopyIcon
'~'1
dim as handle                  @ iconFamilyHndl
dim as ScrapRef                @ scrap
dim as ControlButtonContentInfo  ci

def getbuttondata( 1, _kControlIconPart, _kControlIconContentTag, ¬
                    sizeof(ControlButtonContentInfo), ci, #0 )
long if ( ci.iconRef != _nil )
long if ( fn IconRefToIconFamily( ci.iconRef, ¬
                   _kSelectorAllAvailableData, ¬
                     iconFamilyHndl ) == _noErr )
Long if ( fn ClearCurrentScrap == _noErr )
Long if ( fn GetCurrentScrap( scrap ) == _noErr )
Long if ( fn PutScrapFlavor( scrap, ¬
                   _kIconFamilyType, ¬
              _kScrapFlavorMaskNone, ¬
   fn GetHandleSize(iconFamilyHndl), #[iconFamilyHndl] ) != _noErr )
end if
end if
end if
DisposeHandle( iconFamilyHndl )
end if
end if
end fn

Alain