Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
PNG alpha transparency in command button ?
Message
From
04/06/2006 09:41:21
Dorin Vasilescu
ALL Trans Romania
Arad, Romania
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01126955
Message ID:
01126979
Views:
110
>Does anyone know if the standard VFP8/VFP9 command button (or any third party controls) will respect alpha transparency with a PNG image so that the edges of a button image are gracefully blended with the form's background instead of creating an ugly "rough" edge around the image.
>
>I don't want to fool with MSK files -- I am looking at a third party XP-style icon library that comes off the shelf with 24 bit PNG + alpha transparency already defined in each icon file so I would like to be able to just drop it on the form (hopefully).

Hi
You need to load the PNG into an image control first for alpha transparency to be used. It is documented in help.

You can use this code to do it transparently in Iniit or _Assign methods
LOCAL cImg, cPict, cDownPict, cDisabledPict

cPict = this.Picture 
cDisabledPict = this.DisabledPicture 
cDownPict = this.DownPicture

IF NOT EMPTY(this.Picture)
	IF INLIST(UPPER(JUSTEXT(this.picture)),'PNG','GIF')
		cImg = 'btnImg'+JUSTSTEM(this.Picture)+JUSTEXT(this.Picture)
		IF TYPE('_screen.'+cImg) <> 'O'
			this.Picture = ''
			CLEAR RESOURCES cPict 
			_screen.AddObject( cImg,'Image')
			_screen.&cImg..Picture = cPict
			this.Picture = cPict
		ENDIF
	ENDIF   
ENDIF 		

IF NOT EMPTY(this.DisabledPicture)
	IF INLIST(UPPER(JUSTEXT(this.DisabledPicture)),'PNG','GIF')
		cImg = 'btnImg'+JUSTSTEM(this.DisabledPicture)+JUSTEXT(this.DisabledPicture)
		IF TYPE('_screen.'+cImg) <> 'O'
			this.DisabledPicture = ''
			CLEAR RESOURCES cDisabledPict
			_screen.AddObject( cImg ,'Image')
			_screen.&cImg..Picture = cDisabledPict
			this.DisabledPicture = cDisabledPict
		ENDIF  
	ENDIF 
ENDIF 		

IF NOT EMPTY(this.DownPicture)
	IF INLIST(UPPER(JUSTEXT(this.DownPicture)),'PNG','GIF')
		cImg = 'btnImg'+JUSTSTEM(this.DownPicture)+JUSTEXT(this.DownPicture)
		IF TYPE('_screen.'+cImg) <> 'O'
			this.DownPicture = '' 
			CLEAR RESOURCES cDownPict
			_screen.AddObject(cImg,'Image')
			_screen.&cImg..Picture = cDownPict
			this.DownPicture = cDownPict
		ENDIF  
	ENDIF 
ENDIF 		
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform