Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid with Images Problem
Message
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:
01022201
Views:
29
Hi Don

Yes I understand what you are saying but this happens even if the grid has foccus and the mousedown method does not solve the problem.

I have included proper repro. code to demonstrate the problem for anyone else wanting to see the problem.

Simon
PUBLIC oform1
Create Table ARMaster (AcctNo C(6),Id1 C(30))
For ln=1 To 100
   Insert Into ARMaster (AcctNo,Id1) Values (Padl(Reccount(),6,"0"),"Test "+Transform(Recno()))
EndFor

oform1=NEWOBJECT("form1")
oform1.Show
RETURN
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"
      
   Procedure grdStd1.Init
      This.column1.RemoveObject("text1")
      This.Column1.ADDOBJECT("imgstd1","imgstd")
      With This.Column1.imgStd1
         BackStyle = 1
         Height = 16
         Visible = .T.
         Width = 15
      EndWith

   PROCEDURE setlisttext
      Return ARMaster.AcctNo+" "+ARMaster.Id1
   ENDPROC


   PROCEDURE setlistpicture
*      ThisForm.grdstd1.Column1.ImgStd1.Picture=...
      Return This.grdStd1.Column1.DynamicBackColor 
   ENDPROC
EndDefine
Define Class imgStd as Image
   Procedure Click
      =MessageBox(This.Name)
   EndProc
EndDefine
>Years ago, we had similar functionality in grids...
>We changed the code to the "mousedown" event of the grid image... reason, if the grid didn't have FOCUS yet, the click brought focus to the grid, the second click actually was the image control. However, by using the mousedown of the image is what BROUGHT the focus to the grid -- so we used that.
>
>
>
>>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
>>**************************************************
>>
Simon White
dCipher Computing
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform