Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I change the Command Button colors?
Message
From
07/08/1998 15:58:34
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00124920
Message ID:
00124930
Views:
14
>Is there any way to change the color of the command button? My form color designer (wife) has come up with a good looking set of colors for our forms but says the gray command button clashes.

Now it's your wife then you should change the colors otherwise I would advice not to hack with those standarts. AFAIK w/o hacking with windows own registry the way of doing it having a label in a container with raised effect. Here is a class code for that :
**************************************************
*-- Class:        mybutton (c:\temp\test.vcx)
*-- ParentClass:  container
*-- BaseClass:    container
*
DEFINE CLASS mybutton AS container


	Width = 108
	Height = 34
	SpecialEffect = 0
	Name = "mybutton"


	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 3, ;
		Left = 4, ;
		Height = 27, ;
		Width = 100, ;
		Caption = "Command1", ;
		Style = 1, ;
		Name = "Command1"


	ADD OBJECT image1 AS image WITH ;
		Height = 21, ;
		Left = 4, ;
		Top = 5, ;
		Width = 21, ;
		Name = "Image1"


	ADD OBJECT label1 AS label WITH ;
		WordWrap = .T., ;
		BackStyle = 0, ;
		Caption = "Label1", ;
		Height = 53, ;
		Left = 27, ;
		Top = 3, ;
		Width = 74, ;
		Name = "Label1"


	PROCEDURE Click
		this.command1.click
	ENDPROC


	PROCEDURE MouseDown
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		if nButton = 1
			this.specialeffect = 1
			this.visible = .f.
			this.visible = .t.
		endif
	ENDPROC


	PROCEDURE MouseUp
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		if nButton = 1
			this.specialeffect = 0
			this.visible = .f.
			this.visible = .t.
		endif
	ENDPROC


	PROCEDURE MouseMove
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		#define threshhold 5
		if nButton = 0
		lc =  this.left
		tc = this.top
		bc = this.top + this.height
		rc = this.left + this.width
			if between(nXcoord, lc + threshhold, rc - threshhold ) ;
				and between(nYcoord, tc + threshhold, bc - threshhold)
				this.backcolor = rgb(255,0,0)
			else
				this.resettodefault("backcolor")
			endif
		endif

	ENDPROC


	PROCEDURE command1.LostFocus
		this.parent.resettodefault("backcolor")
	ENDPROC


	PROCEDURE command1.GotFocus
		this.parent.backcolor = rgb(255,0,0)
	ENDPROC


	PROCEDURE command1.MouseDown
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		this.parent.mouseup(nButton, nShift, nXCoord, nYCoord)
	ENDPROC


	PROCEDURE command1.MouseUp
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		this.parent.mouseup(nButton, nShift, nXCoord, nYCoord)
	ENDPROC


	PROCEDURE command1.MouseMove
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		this.parent.mousemove(nButton, nShift, nXCoord, nYCoord)
	ENDPROC


	PROCEDURE command1.Click
		* 
		* Placeholder - to make click event snippet open when dblclicked in designer
		*
	ENDPROC


	PROCEDURE image1.Click
		this.parent.command1.click
	ENDPROC


	PROCEDURE image1.MouseDown
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		this.parent.mousedown(nButton, nShift, nXCoord, nYCoord)
	ENDPROC


	PROCEDURE image1.MouseUp
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		this.parent.mouseup(nButton, nShift, nXCoord, nYCoord)
	ENDPROC


	PROCEDURE image1.MouseMove
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		this.parent.mousemove(nButton, nShift, nXCoord, nYCoord)
	ENDPROC


	PROCEDURE label1.Click
		this.parent.command1.click
	ENDPROC


	PROCEDURE label1.MouseDown
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		this.parent.mousedown(nButton, nShift, nXCoord, nYCoord)
	ENDPROC


	PROCEDURE label1.MouseUp
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		this.parent.mouseup(nButton, nShift, nXCoord, nYCoord)
	ENDPROC


	PROCEDURE label1.MouseMove
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		this.parent.mousemove(nButton, nShift, nXCoord, nYCoord)
	ENDPROC


ENDDEFINE
*
*-- EndDefine: mybutton
**************************************************
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform