Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check box query

Status
Not open for further replies.

StewartUK

Programmer
Feb 19, 2001
860
GB
When working in XP, when you move the mouse over a checkbox object, the actual box gets a little border highlight. I suspect this is a Themes thing but....

I've always felt that MS missed a trick when they enabled us to use Wordwrap with check boxes as it doesn't seem possible to have the box in line with the top line of text, which I prefer.

So what I've got is a lable class where the click event runs runs the Click of a specified checkbox.

What would be really neat is if I could get the border hightlight to appear on the check box.

Any ideas?

Thanks,

Stewart

Hope that helps,

Stewart
PS If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Stewart,

I tried to so something similar a while ago, but never got very far with it. First, I had a problem in determing the colour of the highlight. I eventually cracked this with a lot of help from this form (see thread1254-1246425).

But then I found I just couldn't get the highlight to behave in the way I wanted. No matter what I tried, it never looked right. I didn't try doing it with a checkbox, so you might have better luck than me, although offhand I can't see any obvious way of doing it.

I'd be interested in hearing if anyone else has any ideas.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Sure you can do this, but the question is, is it worth it? If you think it is, here is how you do it:

Put a checkbox on your form, Caption = ""
Put a label next to it, WordWrap = .t.
Put a shape around both of them. Set Visible to .f.. Border style = 3 - Dot, send to back. If you like make it opaque and put some color in it
Mouseenter of the Label = Thisform.shape1.visible = .t.
Mouseleave of the label = Thisform.shape1.visible = .F.
Checkbox Init:
BINDEVENT(this,"mouseenter",thisform.label1,"mouseenter")
BINDEVENT(this,"mouseleave",thisform.label1,"mouseleave")


 
I did have a little play with MouseEnter etc.

Maybe I'm being dim, but I don't see how that gets the little golden-brown highlight to appear on the checkbox.

In the end, I set the label MousePointer to Hand and in the MouseEnter, I set the FontUnderline of the label & check box to .T.

Stewart
 
I created a class for you, to give you an idea on how to do it. The "golden-brown" color; I could not recreate.
Code:
**************************************************
*-- Class Library:  c:\imaginecorp\libraries\stewart.vcx
**************************************************


**************************************************
*-- Class:        check_highlight (c:\imaginecorp\libraries\stewart.vcx)
*-- ParentClass:  container
*-- BaseClass:    container
*-- Time Stamp:   04/10/07 09:38:05 AM
*
DEFINE CLASS check_highlight AS container


	Width = 130
	Height = 57
	BackStyle = 0
	BorderWidth = 0
	Name = "check_highlight"


	ADD OBJECT shape1 AS shape WITH ;
		Top = 2, ;
		Left = 2, ;
		Height = 54, ;
		Width = 126, ;
		BackStyle = 0, ;
		BorderStyle = 3, ;
		Visible = .F., ;
		BorderColor = RGB(207,72,48), ;
		Name = "Shape1"


	ADD OBJECT check1 AS checkbox WITH ;
		Top = 6, ;
		Left = 6, ;
		Height = 17, ;
		Width = 18, ;
		AutoSize = .T., ;
		Alignment = 0, ;
		Caption = "", ;
		Name = "Check1"


	ADD OBJECT label1 AS label WITH ;
		WordWrap = .T., ;
		BackStyle = 0, ;
		Caption = "this is a test for a check box that will display a highlight", ;
		Height = 49, ;
		Left = 25, ;
		Top = 7, ;
		Width = 101, ;
		Name = "Label1"


	PROCEDURE shape1.MouseLeave
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		This.parent.shape1.visible = .f.
	ENDPROC


	PROCEDURE shape1.MouseEnter
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
	ENDPROC


	PROCEDURE check1.Init
		BINDEVENT(this,"mouseenter",this.parent.label1,"mouseenter")
		BINDEVENT(this,"mouseleave",this.parent.label1,"mouseleave")
	ENDPROC


	PROCEDURE label1.MouseLeave
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		This.parent.shape1.visible = .f.
	ENDPROC


	PROCEDURE label1.MouseEnter
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		This.parent.shape1.visible = .t.
	ENDPROC


ENDDEFINE
*
*-- EndDefine: check_highlight
**************************************************
 
If you want an additional highlight Re: Themes, put another shape around the first one, make it Visible = .f. and put the Bindevent() in its Init() also
You will not get the gradient though.
 
Imaginecorp,

Sorry I never got back about this.

In the end I created a label class with a new property AssociatedCheckBox with the following method code:
Code:
PROCEDURE myclick
  LOCAL MyCheckBox
  MyCheckBox = [THIS.Parent] + THIS.AssociatedCheckBox
  &MyCheckBox..DoClick = .T.
ENDPROC

PROCEDURE MouseLeave
  LPARAMETERS nButton, nShift, nXCoord, nYCoord
  LOCAL MyCheckBox
  MyCheckBox = [THIS.Parent] + THIS.AssociatedCheckBox
  STORE .F. TO THIS.FontUnderline, &MyCheckBox..FontUnderline
ENDPROC

PROCEDURE MouseEnter
  LPARAMETERS nButton, nShift, nXCoord, nYCoord
  LOCAL MyCheckBox
  MyCheckBox = [THIS.Parent] + THIS.AssociatedCheckBox
  STORE .T. TO THIS.FontUnderline, &MyCheckBox..FontUnderline
ENDPROC

As you can see, this underlines the label caption and checkbox caption when the mouse is over the label object.

I decided not to try getting the CheckBox & Label underlined when the mouse is over the CheckBox as then the golden-brown highlight appears and to the user it looks like it refers to the whole caption. Yes, it does end up working slightly differently in the 2 situations, but I felt that was a minor difference.

I really appreciate the time you've taken to help in this.

Stewart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top