Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid with Images Problem
Message
From
28/06/2005 13:45:29
Walter Meester
HoogkarspelNetherlands
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01021569
Message ID:
01027136
Views:
23
Simon,

I Today I tried to more or less the same as you and found a suitable workarround for me.
In stead of using images, I use command buttons. The following example.

There are some drawbacks here:

1. You do not see which checkbox has the focus: There is no dotted square to indicate this.
2. There are some issues when you want to use highlight colors or dynamicbackcolor's. They probably can be workarround with by having a function in you dynamicbackcolor expression of the column the 'graphical checkbox' resides in, but I did not come that far yet.

Walter,
**************************************************
*-- Form:         form1 (i:\tax\ids5b134\x2.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   06/28/05 07:32:13 PM
*
DEFINE CLASS form1 AS form


	Top = 0
	Left = 0
	Height = 292
	Width = 375
	DoCreate = .T.
	Caption = "Form1"
	BackColor = RGB(255,255,255)
	Name = "Form1"


	ADD OBJECT grid1 AS taxgrid WITH ;
		ColumnCount = 3, ;
		GridLines = 0, ;
		Height = 204, ;
		Highlight = .T., ;
		HighlightRow = .T., ;
		Left = 12, ;
		Panel = 1, ;
		RecordSource = "x", ;
		Top = 12, ;
		Width = 336, ;
		HighlightStyle = 2, ;
		Name = "Grid1", ;
		Column1.ControlSource = "x.test", ;
		Column1.Width = 126, ;
		Column1.Name = "Column1", ;
		Column2.ControlSource = "x.check1", ;
		Column2.Width = 53, ;
		Column2.Sparse = .F., ;
		Column2.Name = "Column2", ;
		Column3.ControlSource = "x.check2", ;
		Column3.Name = "Column3"


	ADD OBJECT form1.grid1.column1.header1 AS header WITH ;
		Caption = "Header1", ;
		Name = "Header1"


	ADD OBJECT form1.grid1.column1.text1 AS textbox WITH ;
		BorderStyle = 0, ;
		Margin = 0, ;
		ForeColor = RGB(0,0,0), ;
		BackColor = RGB(255,255,255), ;
		Name = "Text1"


	ADD OBJECT form1.grid1.column2.header1 AS header WITH ;
		Caption = "Header1", ;
		Name = "Header1"


	ADD OBJECT form1.grid1.column2.unchecked AS commandbutton WITH ;
		Top = 23, ;
		Left = 18, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "", ;
		SpecialEffect = 1, ;
		BackColor = RGB(255,255,255), ;
		Name = "Unchecked"


	ADD OBJECT form1.grid1.column2.checked AS commandbutton WITH ;
		Top = 47, ;
		Left = 18, ;
		Height = 27, ;
		Width = 84, ;
		Picture = "source\bmps\check.bmp", ;
		Caption = "", ;
		SpecialEffect = 1, ;
		PicturePosition = 12, ;
		BackColor = RGB(255,255,255), ;
		Name = "Checked"


	ADD OBJECT form1.grid1.column3.header1 AS header WITH ;
		Caption = "Header1", ;
		Name = "Header1"


	ADD OBJECT form1.grid1.column3.check1 AS checkbox WITH ;
		Top = 23, ;
		Left = 28, ;
		Height = 17, ;
		Width = 60, ;
		Alignment = 0, ;
		Centered = .T., ;
		Caption = "Check1", ;
		Name = "Check1"


	PROCEDURE Load
		CREATE CURSOR x (Test C(30), Check1 L, Check2 L)

		FOR nT = 1 TO 10
			INSERT INTO x VALUES("Test"+ALLTRIM(STR(nT)), (nT % 2 = 1), (nT % 2 = 0))
		ENDFOR
		GO TOP
	ENDPROC


	PROCEDURE grid1.Init
		THIS.Column2.DynamicCurrentControl="IIF(X.Check1,'Checked','Unchecked')"
	ENDPROC


	PROCEDURE unchecked.KeyPress
		LPARAMETERS nKeyCode, nShiftAltCtrl

		IF nkeyCode = 13
			NODEFAULT
			KEYBOARD '{TAB}'
		ENDIF
	ENDPROC


	PROCEDURE unchecked.Click
		REPLACE Check1 WITH !check1 IN x
	ENDPROC


	PROCEDURE unchecked.GotFocus
		WAIT WINDOW "gotfocus" nowait
	ENDPROC


	PROCEDURE unchecked.MouseDown
		LPARAMETERS nButton, nShift, nXCoord, nYCoord

		NODEFAULT
	ENDPROC


	PROCEDURE checked.KeyPress
		LPARAMETERS nKeyCode, nShiftAltCtrl

		IF nkeyCode = 13
			NODEFAULT
			KEYBOARD '{TAB}'
		ENDIF
	ENDPROC


	PROCEDURE checked.Click
		REPLACE Check1 WITH !Check1 IN x
	ENDPROC


	PROCEDURE checked.MouseDown
		LPARAMETERS nButton, nShift, nXCoord, nYCoord

		NODEFAULT
	ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************
>Hi
>
>I am beginning to remember why I stopped using grids back in VFP6. It just took too much time to get everything to work the way you wanted. Yesterday after a post from Joel Leach I began investigating the grid again. The following code is test form with a grid using images in the first column. I want to use the first column to be able to select a checked on unchecked image. In the final version when a person clicks the image it should toggle the checked or unchecked state. In this version I just display a message saying the image was clicked.
>
>However, it always takes 2 mouse clicks for this to happen why? The same appears to happen with the MouseUp event as well. It is like the first click is being lost for some reason.
>
>Thanks,
>Simon White
>P.S. Please do not tell me I could use a checkbox in the first column to accomplish my goal. The purpose of this form is to test the use of images with a grid.
>
>
>DEFINE CLASS form1 AS form
>	Top = -1
>	Left = -1
>	DoCreate = .T.
>	Caption = "Form1"
>	Visible = .T.
>	Name = "Form1"
>	ADD OBJECT grdstd1 AS grid WITH ;
>		ColumnCount = 2, ;
>		DeleteMark = .F., ;
>		Left = 18, ;
>		Panel = 1, ;
>		RecordSource = "ARMaster", ;
>		ScrollBars = 2, ;
>		Top = 46, ;
>		Name = "Grdstd1", ;
>		Column1.Width = 16, ;
>		Column1.Sparse = .F., ;
>		Column1.DynamicBackColor = "ThisForm.SetListPicture()", ;
>		Column1.Name = "Column1", ;
>		Column2.ControlSource = "ThisForm.SetListText()", ;
>		Column2.Width = 275, ;
>		Column2.Name = "Column2"
>	ADD OBJECT form1.grdstd1.column1.header1 AS header WITH ;
>		Caption = "Header1", ;
>		Name = "Header1"
>	ADD OBJECT form1.grdstd1.column1.imgstd1 AS imgstd WITH ;
>		Picture = "..\..\bmp\grddone.bmp", ;
>		BackStyle = 1, ;
>		Height = 16, ;
>		Visible = .T., ;
>		Width = 15, ;
>		Name = "Imgstd1"
>	ADD OBJECT form1.grdstd1.column2.header1 AS header WITH ;
>		Caption = "Header1", ;
>		Name = "Header1"
>	ADD OBJECT form1.grdstd1.column2.text1 AS textbox WITH ;
>		BorderStyle = 0, ;
>		Margin = 0, ;
>		ForeColor = RGB(0,0,0), ;
>		BackColor = RGB(192,192,192), ;
>		Name = "Text1"
>	ADD OBJECT imgstd1 AS imgstd WITH ;
>		Picture = "..\..\bmp\grddone.bmp", ;
>		Height = 16, ;
>		Left = 84, ;
>		Top = 12, ;
>		Width = 15, ;
>		Name = "Imgstd1"
>	ADD OBJECT imgstd2 AS imgstd WITH ;
>		Picture = "..\..\bmp\grdnormal.bmp", ;
>		Height = 11, ;
>		Left = 216, ;
>		Top = 12, ;
>		Width = 15, ;
>		Name = "Imgstd2"
>	PROCEDURE setlisttext
>		Return ARMaster.AcctNo+" "+ARMaster.Id1
>	ENDPROC
>	PROCEDURE setlistpicture
>		ThisForm.grdstd1.Column1.ImgStd1.Picture=Iif(Mod(Recno("ARMaster"),2)=0,;
>		"c:\business\dciphercomputing\bmp\grddone.bmp","c:\business\dciphercomputing\bmp\grdNormal.bmp")
>		Return This.grdStd1.Column1.DynamicBackColor
>	ENDPROC
>	PROCEDURE Load
>		Use ARMaster Order Tag Id1
>	ENDPROC
>	PROCEDURE imgstd1.Click
>		=MessageBox(This.Name+" Clicked")
>	ENDPROC
>ENDDEFINE
>*
>*-- EndDefine: form1
>**************************************************
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform