Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid with Images Problem
Message
 
À
10/06/2005 18:22:33
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01021569
Message ID:
01022433
Vues:
16
Hi Fabio

Are they fired the first time to click on the image in an unselected row? When I run the code shown below it only happens the second time I click on the image. In fact even though the grid.Mousedown event is shown in event tracking the code is not even called.

Simon


>>Hi Craig
>>
>>The event tracking shows that when you move mouse to another row and then click on the image some events are not fired. The sequence of events is:
>>
>>form.grdstd1.mousedown
>>form.grdstd1.BeforeRowColChange
>>form.paint
>>form.grdstd1.AfterRowColChange
>>form.grdStd1.MouseUp
>>
>>The second time you click the events are:
>>
>>form.grdstd1.mousedown
>>form1.grdstd1.column1.imgstd1.MouseDown
>>form1.grdstd1.MouseUp
>>form1.grdstd1.column1.imgstd1.MouseUp
>>form1.grdstd1.column1.imgstd1.Click()
>>
>>Clearly the imgStd1.MouseDown event was missed.
>>
>
>Simon, imgStd1.MouseDown,MouseUp,Click are fired for me.
>
>>So I guess I could use the grid.mousedown event to see where the mouse is located to determine if I should pass the event on to the control. These sorts of bugs are why I am very cautious about using grids and generally avoid them.
>>
>>Thanks,
>>Simon
>>
>>>A couple of thoughts, not time to check it out myself. Run your code in debug with Event Tracking on. Look at the Debug Output window and see if there any events happening that may prove useful. What I'm thinking is that if you can get a useful event that fires, then you could use the Grid Hittest method or Amouseobj() in order to check whether the left mousebutton is down and over the imagecontrol in the grid. Then delegate everything to your image's click event. I know it's a lot of work just for a stupid click event, but if you seriously need to find a way around this bug then it should work - at least that's my thinking.
>>>
>>>>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform