Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Any ideas how to do these UI features?
Message
 
À
05/09/2005 09:41:23
Mike Sue-Ping
Cambridge, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01046660
Message ID:
01047261
Vues:
20
While I am sure you are looking for something like a simple API call that achieves the effect, and I am also certain that Christof has already provided you a workable way to achieve a gradual fade to gray. The code to just turn all the controls on the form to grayscale is not that difficult from a code perspective. Though there will be looping, the judicious use of a lockscreen will help with speed and the effect as perceived by the user. Also, you would need to drill-down into containers... but here is an example that you can run that shows the principle... cut-n-paste the code into a prg and execute it then click on the Gray commandbutton that is on the form.
*!* Code does not drill-down into container
*!* objects. It is just a simple example showing
*!* the basic principal of changing colors to
*!* corresponding grayscale

PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show
RETURN

DEFINE CLASS form1 AS form

	Height = 250
	Width = 336
	DoCreate = .T.
	AutoCenter = .T.
	Caption = "Grayscale Example"
	Name = "Form1"

	ADD OBJECT text1 AS textbox WITH ;
		FontBold = .T., ;
		Value = ("This is a Test!"), ;
		Height = 25, ;
		Left = 17, ;
		Top = 50, ;
		Width = 301, ;
		ForeColor = RGB(0,0,255), ;
		Name = "Text1"

	ADD OBJECT edit1 AS editbox WITH ;
		FontBold = .T., ;
		Height = 58, ;
		Left = 17, ;
		Top = 86, ;
		Width = 301, ;
		ForeColor = RGB(255,0,0), ;
		Value = ("Hello World!"), ;
		Name = "Edit1"

	ADD OBJECT label1 AS label WITH ;
		AutoSize = .T., ;
		FontSize = 16, ;
		BackStyle = 0, ;
		Caption = "Visual FoxPro Rocks!", ;
		Height = 27, ;
		Left = 17, ;
		Top = 14, ;
		Width = 203, ;
		ForeColor = RGB(255,128,0), ;
		Name = "Label1"

	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 204, ;
		Left = 149, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Gray", ;
		Enabled = .T., ;
		BackColor = RGB(255,255,0), ;
		Name = "Command1"

	ADD OBJECT command2 AS commandbutton WITH ;
		Top = 204, ;
		Left = 233, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Color", ;
		Enabled = .F., ;
		BackColor = RGB(0,255,0), ;
		Name = "Command2"

	ADD OBJECT shape1 AS shape WITH ;
		Top = 156, ;
		Left = 24, ;
		Height = 37, ;
		Width = 49, ;
		BackColor = RGB(255,0,0), ;
		Name = "Shape1"

	ADD OBJECT shape2 AS shape WITH ;
		Top = 156, ;
		Left = 84, ;
		Height = 37, ;
		Width = 49, ;
		BackColor = RGB(128,255,128), ;
		Name = "Shape2"

	ADD OBJECT shape3 AS shape WITH ;
		Top = 156, ;
		Left = 144, ;
		Height = 37, ;
		Width = 49, ;
		BackColor = RGB(0,128,0), ;
		Name = "Shape3"

	ADD OBJECT shape4 AS shape WITH ;
		Top = 156, ;
		Left = 204, ;
		Height = 37, ;
		Width = 49, ;
		BackColor = RGB(0,255,255), ;
		Name = "Shape4"

	ADD OBJECT shape5 AS shape WITH ;
		Top = 156, ;
		Left = 264, ;
		Height = 37, ;
		Width = 49, ;
		BackColor = RGB(255,0,128), ;
		Name = "Shape5"

	PROCEDURE command1.Click
		LOCAL loControl, lnRed, lnGreen, lnBlue, lnColor, lnGray
		loControl = .NULL.
		*!* Break each control's colors into three parts
		*!* by simple addition and division transform them into 
		*!* corresponding grayscale color
		FOR EACH loControl IN thisform.Controls
			IF PEMSTATUS(loControl,"Backcolor",5)
				lnColor = loControl.BackColor
				loControl.Tag = TRANSFORM(lnColor)
				lnRed = Mod(lnColor, 256)
				lnGreen = Mod(BitRShift(lnColor, 8), 256)
				lnBlue = Mod(BitRShift(lnColor, 16), 256)
				lnGray = (lnRed + lnGreen + lnBlue)/3
				loControl.BackColor = RGB(lnGray, lnGray, lnGray)
			ENDIF
			loControl.Tag = loControl.tag + "."
			IF PEMSTATUS(loControl,"ForeColor",5)
				lnColor = loControl.ForeColor
				loControl.Tag = loControl.tag + TRANSFORM(lnColor)
				lnRed = Mod(lnColor, 256)
				lnGreen = Mod(BitRShift(lnColor, 8), 256)
				lnBlue = Mod(BitRShift(lnColor, 16), 256)
				lnGray = (lnRed + lnGreen + lnBlue)/3
				loControl.ForeColor = RGB(lnGray, lnGray, lnGray)
			ENDIF
		ENDFOR
		this.Enabled = .F.
		thisform.command2.Enabled = .T.
	ENDPROC

	PROCEDURE command2.Click
		LOCAL loControl
		loControl = .NULL.
		FOR EACH loControl IN thisform.Controls
			IF !EMPTY(loControl.tag)
				IF PEMSTATUS(loControl,"Backcolor",5)
					loControl.BackColor = INT(VAL(JUSTSTEM(loControl.tag)))
				ENDIF
				IF PEMSTATUS(loControl,"ForeColor",5)
					loControl.ForeColor = INT(VAL(JUSTEXT(loControl.tag)))
				ENDIF
			ENDIF
			loControl.tag = ""
		ENDFOR
		this.Enabled = .F.
		thisform.command1.Enabled = .T.
	ENDPROC

ENDDEFINE
>Hi Christof,
>
>Thanks for your reply. In my situation, that would be a lot of looping and setting of colors!
>
>Mike.
>
>
>>Hi Mike,
>>
>>What Windows XP does is changing the colors. XP can do this on a much better global level than we can in a VFP application. However, the idea would be the same. Basically, you need to loop through all your objects and change all color properties. To get the desired effect you need to work with HSL color codes instead of RGB (expand the GetColor dialog to see what I mean). To turn a color into gray you steadily reduce the saturation (text box in the middle) to 0.
>>
>>The older Windows effect is easier to achieve. Basically it's an image where one pixel is black and one transparent.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform