Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to gray a picture in an image control ?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Photos et traitement d'images
Divers
Thread ID:
00464312
Message ID:
00464507
Vues:
25
>Hi all,
>
>When I assign a picture to a CommandButton and I turn it disabled, the picture is GRAYED with the color schema of the user machine.
>I need to do this with a Image control, but it have not the Enabled property.
>I create a bitmap with the disbled picture cutting the disabled commandbutton picture in MS-Paint (Alt+PrtScr | and paste in Paint).
>When I need to disable the Image control, I change the picture property to the new disabled bitmap. If I change the color schema my new bitmap looks horrible in the screen. OK?
>
>What I need?? Exist any API function to gray a picture ?????
>

SubClass the Image control to add EnabledPicture and DisablePicture custom properties. Add an Assign method to the Enabled property that resets the Picture Property of the Image control to the appropriate source whenever you change the Enabled property of the subclassed image control. Rather than assigning a value to the Picure property directly, store values to the two custom properties, and during Init assign the appropriate Picture based on the status of Enabled at Init(). Any subsequent changes will trigger the Assign method, which would then switch Picture t the appropriate image for the Enabled status.

The code would look something like:
PUBLIC oform1

SET CLASSLIB TO f:\program files\microsoft visual studio\vfp98\enddisimage.vcx ADDITIVE

oform1=NEWOBJECT("form1")
oform1.Show
RETURN
**************************************************
*-- Class Library:  f:\program files\microsoft visual studio\vfp98\enddisimage.vcx
**************************************************


**************************************************
*-- Class:        endisimage (f:\program files\microsoft visual studio\vfp98\enddisimage.vcx)
*-- ParentClass:  image
*-- BaseClass:    image
*-- Time Stamp:   01/16/01 08:56:12 PM
*
DEFINE CLASS endisimage AS image


	Height = 17
	Width = 100
	enabledpicture = (getpict())
	disabledpicture = (getpict())
	Name = "endisimage"


	PROCEDURE enabled_assign
		LPARAMETERS vNewVal
		*To do: Modify this routine for the Assign method

		IF m.vNewVal
		   this.picture = this.enabledpicture
		ELSE
		   this.picture = this.disabledpicture
		endif
		THIS.Enabled = m.vNewVal
	ENDPROC


	PROCEDURE Init
		this.enabled = .t.
	ENDPROC


ENDDEFINE
*
*-- EndDefine: endisimage
**************************************************

**************************************************
*-- Form:         form1 (f:\program files\microsoft visual studio\vfp98\ff1.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   01/16/01 09:04:05 PM
*
DEFINE CLASS form1 AS form


	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"


	ADD OBJECT im1 AS endisimage WITH ;
		Height = 60, ;
		Left = 96, ;
		Top = 72, ;
		Width = 120, ;
		disabledpicture = (getpict()), ;
		enabledpicture = (getpict()), ;
		Name = "im1"


	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 168, ;
		Left = 156, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Command1", ;
		Name = "Command1"


	PROCEDURE command1.Click
		thisform.im1.enabled = ! thisform.im1.enabled
	ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************
The demo class and form were created visually, and exported as code using the Class Browser.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform