Subject Re: Closing an image on a form
From Mervyn Bick <invalid@invalid.invalid>
Date Sun, 4 Apr 2021 10:51:37 +0200
Newsgroups dbase.getting-started
Attachment(s) swap_tables.wfm

On 2021/04/04 02:39, roy price wrote:
> I have a dmd linking a table with three other tables that contain images (three files because of file size limitations)
>
> The form works by stepping through the table, and selecting a matched image from one of the three files. (currently shown on different areas of the form)
>
> My problem is that I cannot close an image from the first table, when stepping through the table, if it selects an image from one of the other two files.
> ? I cannot close the image because the events in the image setup do not include OnOpen or OnClose.?
> How can I close one image when another is opened from another file?
>

Simply changing the datasource property of the image control to point to
a record in the next table should automatically replace the image.

A little example showing the concept is attached.

Unless you need high resolution images so as to be able to print
enlargements there is no need to save high resolution images in your
table.  Not only will using a lower resolution make it possible to
reduce your table size but the images will load and display faster.  I
use IrfanView to reduce resolution but a quick Google will find you many
more programs with the capability to resize multiple images in a batch.

Mervyn.



** END HEADER -- do not remove this line
//
// Generated on 2021-04-04
//
parameter bModal
local f
f = new swap_tablesForm()
if (bModal)
   f.mdi = false // ensure not MDI
   f.readModal()
else
   f.open()
endif

class swap_tablesForm of FORM
   with (this)
      metric = 6        // Pixels
      height = 352.0
      left = 126.0
      top = 10.0
      width = 280.0
      text = ""
   endwith

   this.DBASESAMPLES1 = new DATABASE(this)
   with (this.DBASESAMPLES1)
      left = 126.0
      width = 78.0
      height = 37.0
      databaseName = "DBASESAMPLES"
      active = true
   endwith

   this.FISH2 = new QUERY(this)
   with (this.FISH2)
      left = 91.0
      width = 27.0
      height = 37.0
      database = form.dbasesamples1
      sql = "select * from FISH.DBF where id = 1"
      active = true
   endwith

   this.FISH1 = new QUERY(this)
   with (this.FISH1)
      left = 35.0
      width = 27.0
      height = 37.0
      database = form.dbasesamples1
      sql = "select * from FISH.DBF where id = 2"
      active = true
   endwith

   this.IMAGE1 = new IMAGE(this)
   with (this.IMAGE1)
      height = 140.0
      left = 37.0
      top = 85.0
      width = 200.0
      dataSource = form.fish1.rowset.fields["fish image"]
   endwith

   this.RADIOBUTTON1 = new RADIOBUTTON(this)
   with (this.RADIOBUTTON1)
      onChange = class::RADIOBUTTON1_ONCHANGE
      height = 24.0
      left = 64.0
      top = 273.0
      width = 110.0
      text = "Table 1"
      group = true
      value = true
   endwith

   this.RADIOBUTTON2 = new RADIOBUTTON(this)
   with (this.RADIOBUTTON2)
      height = 24.0
      left = 63.0
      top = 310.0
      width = 110.0
      text = "Table 2"
   endwith

   this.rowset = this.fish1.rowset

   function RADIOBUTTON1_onChange()
      if this.value = true
         form.image1.dataSource = form.fish1.rowset.fields["fish image"]
      else  
         form.image1.dataSource = form.fish2.rowset.fields["fish image"]
      endif  
      return

endclass