Groups > dBase > Getting Started with dBase > Re: Picture in a table




Picture in a table

Picture in a table
Thu, 13 Mar 2008 20:57:33 -050
Hi,
In the staff table, one field is dedicated to the person picture.
In the update table form, I would like to have the user be able to select a
picture from a specific subdirectory to update the person file.
I've no clue how to start with
Was thinking about "treeview" but no example in the Help
Could you suggest ?
Thanks
Post Reply
Re: Picture in a table
Thu, 13 Mar 2008 23:20:13 -040
In article <Etr3EbXhIHA.1088@news-server>, michel.pain@free.fr says...
> Hi,
> In the staff table, one field is dedicated to the person picture.
> In the update table form, I would like to have the user be able to select a
picture from a specific subdirectory to update the person file.
> I've no clue how to start with
> Was thinking about "treeview" but no example in the Help
> Could you suggest ?
> Thanks
> Michel
> 

Michel,

To get the file from a specific folder, you can do this (change the 
patth to the right one):

cFile = getFile( "c:\" )

if empty( cFile )
	msgBox( "You cancelled getFile" )
else
	msgBox( "Your file is " + cFile )
endif

To save the file, the FIELD object has a .replaceFromFile() method.

So...

YourROWSET.FIELDS[ "yourFieldName" ].replaceFromFile( cFile )

-- 
Geoff Wass [dBVIPS]
Montréal, Québec, Canada

.|.|.|        dBASE info at http://geocities.com/geoff_wass       |.|.|.
.|.|.| ---------------------------------------------------------- |.|.|.
Post Reply
Re: Picture in a table
Thu, 13 Mar 2008 23:23:52 -040
In article <Etr3EbXhIHA.1088@news-server>, michel.pain@free.fr says...
> 
> I would like to have the user be able to select a picture
> from a specific subdirectory to update the person file.

See below. It just need buttons to add and to delete records, and 
buttons to navigate in the database.

Jean-Pierre Martel, editor
The dBASE Developers Bulletin
Blue Star dBASE Plus Core Concepts Graduate

========= Start of Pain.wfm ========

if not file('Membres.dbf')   // If the tables aren't found...
   create table Membres (Prenom char(20),;
                         Nom char(35),;
                         Adresse char(30),;
                         Photo Blob(10,2))
   q = new query("Select * from Membres")
   q.rowset.beginAppend()
   q.rowset.fields[1].value = "Michel"
   q.rowset.fields[2].value = "Pain"
   q.rowset.fields[3].value = "Palais de l'Élysée, Paris"
   q.rowset.save()
   q.active = false
   q = null
endif

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

class PainForm of FORM
   with (this)
      metric = 6	// Pixels
      height = 233.0
      left = 256.0
      top = 156.0
      width = 417.0
      text = ""
      mdi = false
      maximize = false
   endwith

   this.MEMBRES1 = new QUERY()
   this.MEMBRES1.parent = this
   with (this.MEMBRES1)
      left = 142.0
      top = 187.0
      sql = 'select * from "Membres.DBF"'
      active = true
   endwith

   this.PUSHBUTTON1 = new PUSHBUTTON(this)
   with (this.PUSHBUTTON1)
      onClick = class::PUSHBUTTON1_ONCLICK
      height = 22.0
      left = 386.0
      top = 54.0
      width = 24.0
      text = ""
      upBitmap = "RESOURCE #136"
      downBitmap = "RESOURCE #137"
   endwith

   this.TEXTLABEL1 = new TEXTLABEL(this)
   with (this.TEXTLABEL1)
      height = 14.0
      left = 14.0
      top = 54.0
      width = 84.0
      text = "Prénom"
      fontSize = 8.0
   endwith

   this.TEXTLABEL2 = new TEXTLABEL(this)
   with (this.TEXTLABEL2)
      height = 14.0
      left = 14.0
      top = 90.0
      width = 84.0
      text = "Nom"
      fontSize = 8.0
   endwith

   this.TEXTLABEL3 = new TEXTLABEL(this)
   with (this.TEXTLABEL3)
      height = 14.0
      left = 14.0
      top = 128.0
      width = 84.0
      text = "Adresse"
      fontSize = 8.0
   endwith

   this.ENTRYFIELD1 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD1)
      dataLink = form.membres1.rowset.fields["prenom"]
      height = 20.0
      left = 12.0
      top = 68.0
      width = 237.0
   endwith

   this.ENTRYFIELD2 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD2)
      dataLink = form.membres1.rowset.fields["nom"]
      height = 20.0
      left = 12.0
      top = 104.0
      width = 237.0
   endwith

   this.ENTRYFIELD3 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD3)
      dataLink = form.membres1.rowset.fields["adresse"]
      height = 20.0
      left = 12.0
      top = 142.0
      width = 237.0
   endwith

   this.IMAGE1 = new IMAGE(this)
   with (this.IMAGE1)
      height = 161.0
      left = 252.0
      top = 53.0
      width = 132.0
      dataSource = form.membres1.rowset.fields["photo"]
   endwith

   this.TEXT1 = new TEXT(this)
   with (this.TEXT1)
      height = 47.0
      left = 0.0
      top = 0.0
      width = 422.0
      colorNormal = "White/0xc08000"
      alignVertical = 1	// Middle
      alignHorizontal = 1	// Center
      fontSize = 21.0
      fontBold = true
      text = "Carte d'identité"
   endwith

   this.rowset = this.membres1.rowset

   Function Pushbutton1_onClick
      local cFile
      cFile = getfile("", "Veuiller choisir " + ;
                      "une photo...", true, "jpg")
      if empty(cFile)
         msgBox("Aucune image choisie.   ", ;
                " Erreur...", 48)
       else
          Form.rowset.fields["photo"].replaceFromFile(cFile)
          Form.rowset.refreshControls()
      endif      
      return

endclass

========= End of Pain.wfm ========
Post Reply
Re: Picture in a table
Thu, 13 Mar 2008 23:48:01 -040
In article <MPG.2243b9d4b94ff72a9898bc@news.dbase.com>, 
nospam@nospam.com says...

Among the image properties, I would also add...
      alignment = 3	// Keep Aspect Stretch

Jean-Pierre Martel, editor
The dBASE Developers Bulletin
Post Reply
Re: Picture in a table
Fri, 14 Mar 2008 03:03:38 -050
Thanks a lot to both of you : I didn't know the existence of the getfile
command. It's 100% what I needed
I feel stronger
Michel

Geoff Wass [dBVIPS] Wrote:

> In article <Etr3EbXhIHA.1088@news-server>, michel.pain@free.fr
says...
> > Hi,
> > In the staff table, one field is dedicated to the person picture.
> > In the update table form, I would like to have the user be able to
select a picture from a specific subdirectory to update the person file.
> > I've no clue how to start with
> > Was thinking about "treeview" but no example in the Help
> > Could you suggest ?
> > Thanks
> > Michel
> > 
> 
> Michel,
> 
> To get the file from a specific folder, you can do this (change the 
> patth to the right one):
> 
> cFile = getFile( "c:\" )
> 
> if empty( cFile )
> 	msgBox( "You cancelled getFile" )
> else
> 	msgBox( "Your file is " + cFile )
> endif
> 
> To save the file, the FIELD object has a .replaceFromFile() method.
> 
> So...
> 
> YourROWSET.FIELDS[ "yourFieldName" ].replaceFromFile( cFile )
> 
> -- 
> Geoff Wass [dBVIPS]
> Montréal, Québec, Canada
> 
> .|.|.|        dBASE info at http://geocities.com/geoff_wass       |.|.|.
> .|.|.| ---------------------------------------------------------- |.|.|.
> .|.|.|             IT Consultant http://Geoff_Wass.com            |.|.|.
Post Reply
<< Previous 1 2 Next >>
( Page 1 of 2 )
about | contact