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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Photos in a grid: Strange behavior

Status
Not open for further replies.

Dronner

Technical User
Apr 19, 2024
15
0
0
US
Hi,
I'm learning to configure a grid with photos (in Visual FoxPro 6) when creating a grid either with a cursor or with a database, the column that displays the photos presents a strange behavior: when clicking on a photo, one or two photos of the other cells in that column are changed (the change affects only the display, not the original file) I have reviewed the properties and I cannot find a single clue as to what could be causing this strange behavior. I have based it on an example that I found on the web, here I attach the example that I found in the hope that someone can detect the error. The idea is that when you click on a photo, this photo and the others stay in place.
Thank you for your help.
 
 https://files.engineering.com/getfile.aspx?folder=765d7ac3-f095-4ee1-84be-94213d537d50&file=Photos_in_a_grid.rar
Hi,

You may want to have a look at the code snippet below. It's a contribution from Olaf Doschke in thread184-1738143. I fine tuned it only a little bit.

Code:
Public oForm

oForm = Createobject('myForm')
oForm.Show()

READ EVENTS

CLOSE ALL
CLEAR ALL 

**********

DEFINE Class myForm As Form
  Height = 360
  Width = 840
  Add Object myGrid As Grid With Height = 360, Width = 840, RecordSource = 'tblImageList'

  Procedure Load
    Local Array laImageList[1]
    Local lcPath
    
    lcPath = Home()+'Graphics\Bitmaps\Offctlbr\Large\Color'
    
    Create Cursor tblImageList (FileName M)
    
    For lix = 1 To Adir(laImageList, Addbs(m.lcPath) + '*.*')
      Insert Into tblImageList Values (Addbs(m.lcPath) ++ laImageList[lix,1])
    Endfor
 
*!*	    For lix = 1 To Adir(laImageList, "*.jpg")
*!*	      Insert Into tblImageList Values (laImageList[lix,1])
*!*	    Endfor
     
    Go Top
  Endproc

  Procedure Init
    With This.myGrid
      .ColumnCount = 2
      .RowHeight = 24
      .Anchor = 15

      With .Columns(1)
        .AddObject('edtBox','EditBox')
        .CurrentControl = 'edtBox'
        .Width = 720
        .Sparse = .F.
        .edtBox.Visible = .T.
      Endwith

      With .Columns(2)
      	.Header1.Caption = ""
        .AddObject('imgImage','myImage')
        .CurrentControl = 'imgImage'
        .Width = 24
        .Sparse = .F.
        .imgImage.ImageFilename = "tblImageList.FileName"
        .imgImage.Visible = .T.
      Endwith
    Endwith
  ENDPROC
  
  PROCEDURE Destroy()
  	ThisForm.Release()
  	CLEAR EVENTS()
  ENDPROC 
  
ENDDEFINE 

**********

DEFINE Class myImage as Image
   ImageFileName = ""
   
   PROCEDURE Backstyle_Access()
      This.Picture = Evaluate(this.ImageFileName)
      Return This.BackStyle
   ENDPROC
   
ENDDEFINE

It also works with your pictures - but please don't use this kind of offensive pictures in a demo.

hth

MarK
 
Thank you very much for the source code, I will try to implement it.

Mark said:
but please don't use this kind of offensive pictures in a demo
About the images, the demo originally includes those adult women in lingerie, I just limited to forwarding it without modifying anything to avoid altering the demo in any way. I'm sorry if you were offended, that was not my intention.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top