Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DisabledPicture can not equal Picture for command button
Message
 
To
12/05/2005 10:42:43
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01013356
Message ID:
01013411
Views:
11
This message has been marked as the solution to the initial question of the thread.
>Chad,
>
>Thank you for confirming my observation, for your explanation and for sharing how you implemented your own button class.
>
>Can you share a little more about your decision to use PNG vs. BMP images? Are your images using PNG specific features like transparency and alpha blending?
>
>Also, it sounds like you've created your own replacement composite controls for command buttons using images, labels and shapes? Did I understand that correctly?
>
>Malcolm

Malcolm,

We bought a library of images to use in applications here and they happen to be PNGs. They look good because they do utilize transparency and alpha blending. But, as we found out, they also brought some challenges. I didn't do anything so elaborate as a composite control to get the proper image support on the buttons. We use VMP here and I augmented the SuperClass command button as follows (as copied from the view code of the class browser):
DEFINE CLASS cmdvmpsuperclass AS commandbutton
	Height = 27
	Caption = "cmdVMPSuperClass"
	*-- Specifies whether or not an image control (added on the fly) is to be used
	*-- for displaying the image set in the Picture and DisabledPicture properties.
	tmlimagefordisplay = .F.
	Name = "cmdvmpsuperclass"


	*-- Reload images associated with this object using image controls
	*-- to load the properly displayed image into cache.
	PROCEDURE tmdisplayimages
		*JCJB*	See if augmented display behavior is desired.
		IF this.TMlImageForDisplay
			*JCJB*	Display the images properly for the 4 Picture properties.
			this.tmDisplayImage('Picture')
			this.tmDisplayImage('DisabledPicture')
			this.tmDisplayImage('DownPicture')
			this.tmDisplayImage('OLEDragPicture')
		ENDIF
	ENDPROC


	*-- Reload a single image associated with this object using an image control.
	PROCEDURE tmdisplayimage
		LPARAMETERS tcProperty AS String

		LOCAL	lcPicture AS String, ;
				lcImage AS String

		*JCJB*	Make sure a valid property is passed.
		IF VARTYPE(tcProperty) # 'C' OR !PEMSTATUS(this, tcProperty, 5)
			RETURN .f.
		ENDIF

		*JCJB*	See if a Picture is specified.
		IF !EMPTY(this.&tcProperty)
			*JCJB*	Save the current Picture setting.
			lcPicture = this.&tcProperty

			*JCJB*	Build the Image control name.
			lcImage = 'TMo' + tcProperty

			*JCJB*	Create an Image control for proper image display.
			this.AddProperty(lcImage, NEWOBJECT('Image'))

			*JCJB*	Release the picture from this button.
			this.&tcProperty = ''

			*JCJB*	Clear the copy in cache. This will only be successful if nothing else
			*JCJB*	is using this resource. This means if you have multiple buttons using
			*JCJB*	the same image, you should create multiple copies of the picture with
			*JCJB*	different names and use one for each button.
			CLEAR RESOURCES (lcPicture)

			*JCJB*	Load the Picture into the Image control for proper display.
			this.&lcImage..Picture = lcPicture

			*JCJB*	Load the cached copy back onto this button.
			this.&tcProperty = lcPicture
		ENDIF
	ENDPROC


	PROCEDURE Destroy
		*JCJB*	See if augmented display behavior is desired.
		IF this.TMlImageForDisplay
			*JCJB*	Release all the Image controls that were added.
			IF PEMSTATUS(this, 'TMoPicture', 5)
				this.TMoPicture = null
			ENDIF

			IF PEMSTATUS(this, 'TMoDisabledPicture', 5)
				this.TMoPicture = null
			ENDIF

			IF PEMSTATUS(this, 'TMoDownPicture', 5)
				this.TMoPicture = null
			ENDIF

			IF PEMSTATUS(this, 'TMoOLEDragPicture', 5)
				this.TMoPicture = null
			ENDIF
		ENDIF
	ENDPROC


	PROCEDURE Init
		*JCJB*	See if augmented display behavior is desired.
		this.tmDisplayImages()
	ENDPROC
ENDDEFINE
The enhancements were solely for displaying PNGs with proper transparency and alpha blending. The final result is what we were ultimately after by purchasing the images in the first place.

HTH,
Chad
_________________________________
There are 2 types of people in the world:
    Those who need closure
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform