Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Articles
Recherche: 

Images, containers in grid
Cetin Basoz, August 9, 2000
With grids it's a little problematic to show different images or container objects per row. You might have only image filenames stored in a table or you might want to show something like a time table with shape controls where you only store start-end values as numeric. Grid shows the same thing on a...
Summary
With grids it's a little problematic to show different images or container objects per row. You might have only image filenames stored in a table or you might want to show something like a time table with shape controls where you only store start-end values as numeric. Grid shows the same thing on all rows. Solution is a simple trick using Dynamic* properties. Dynamic* properties get evaluated each time a grid refresh is done and -thanks to Fox team- done only for visible cells. We'll get image control in a container as sample but applies to other objects as well (except ActiveX). Normally there is no one Dynamic* property you could use for this. Instead you get just anyone of them and 'cheat' :) Here's the sample code. Create a directory and put there a number of image files that your version can process, then try this (no check if a valid dir is selected, files are imagefiles etc) :
Description
lcPath = getdir()
lnFiles = adir(aImageList, lcPath+'*.*')
Create cursor myImageList (FileName m)
For ix=1 to alen(aImageList,1)
  Insert into myImageList values (lcPath+aImageList[ix,1])
Endfor
Go top
oForm = createobject('myForm')
With oForm
  .Lockscreen = .t.
  .Height = 400
  .Width = 600
  .Addobject('myGrid','Grid')
  .Addobject('clbutton','closebutton')
  .clbutton.visible = .t.
  With .myGrid
    .Left = 0
    .Top = 20
    .Height = 370
    .Width = 590
    .Columncount = -1
    .Recordsource = 'myImageList'
    .Columncount = 2
    .RowHeight = .RowHeight * 7
    With .Columns(2)
      .Addobject('myContainer','Container')
      .CurrentControl = 'myContainer'
      .Sparse = .f.
      With .myContainer
        .Addobject('myImage','Image')
        .myImage.Visible = .t.
      Endwith
      .Dynamicbackcolor = 'thisform.fake()'
    Endwith
    .Visible = .t.
  Endwith
  .Lockscreen = .f.
Endwith
oForm.Show
Read events

Define class myForm as Form
  Procedure fake
  Thisform.myGrid.Columns(2).myContainer.myImage.Picture = myImageList.FileName
  Return thisform.myGrid.Backcolor
Endproc
Enddefine
Define class CloseButton as commandbutton
  Height = 15
  Caption ='close'
  Procedure click
  Clear events
  Thisform.release
Endproc
Enddefine
As you can see DynamicBackColor of column 2 (where image container is) calls a custom fake() method. Fake() simply assigns row's filename to picture property and returns backcolor (in a sense nothing - no change). Cetin Basoz
Cetin Basoz, Engineerica Inc.
Çetin is Engineerica's lead developer and also administering "Institute of Marine Sciences and Technology-Izmir" computer division. He specializes in using Visual FoxPro, .NET and SQL server. He is using Foxbase, Foxpro and Visual FoxPro since 80's, .NET since 2004. He has been a Microsoft MVP 1999-2010. His expertise has been used in prototyping, development, training and testing. Now he continues his carrier on VFP and C#.Net doing mostly Silverlight RIA applications. Though Çetin is well known for his programming skills, very few people know that he is also a licensed Medical Doctor. After practicing medicine for about ten years Çetin switched careers and went to his true passion - software programming.
More articles from this author
Cetin Basoz, September 20, 2000
This will get you the RGB equivalent from a color number. These are 2 little functions doing it different ways. You may try which one fits better your needs. The first one uses the 256 syntax to get the color. The second one is using the BITAND and BITRSHIFT approach.
Cetin Basoz, February 16, 1998
Here is two sample functions one is just for using wordbasic and the second is using wordbasic in mailmerge. Wordbasic PEMs are defined in wrdbasic.hlp located in winword directory. This help file contains the arguments as named arguments which are not suitable for calling via VFP. In files section...
Cetin Basoz, April 26, 2001
Well it started when I found it hard to check rtf files for MSDN subscription index. In last few shipments there were also an MDB in 'UN-SUPPED' directory but my Access is too perfect to use an MDB so I decided to get Access data to VFP tables.
Cetin Basoz, January 6, 1998
Databases have a little different header from tables thus making it impossible to copy them online through SQL or "copy to". The code below accomplishes this opening the DBC readonly and creating a copy of it using lowlevel IO.
Cetin Basoz, June 1, 2001
Introduction Any data that could be represented in an hierarchical way is a candidate for a treeview listing. This article will show you how to use the MS Active X treeview control in your own applications in a simple way, populate it fast and apply drag&drop to it. Note that this control is ...