Subject |
Re: Display Images on the form from a local imagefolder |
From |
Akshat Kapoor <akshat.kapoor@kapoorsons.in> |
Date |
Fri, 22 Sep 2023 11:12:30 +0530 |
Newsgroups |
dbase.getting-started |
Good Morning Agostinho,
> I've been trying to use images from my computer directory location but
> can't get it to work.
>
> I added a character field named "imagefolder" to my fish4.dbf file and wrote the image files name to this particular record "C:\Users\HOME_PC\Desktop\blueangelfish.png"
>
> Dropped an image controle from the componed pallete to the form
> and have programmed an onNavigate function into the form.
>
> this.IMAGE1 = new IMAGE(this)
> with (this.IMAGE1)
> height = 4.84
> left = 73.1111
> top = 3.96
> width = 17.8889
> endwith
>
> function form_onNavigate(nWorkArea)
> local cImageFileName
> // Assuming I have a field in my table that contains image file paths
> cImageFileName = form.fish41.rowset.fields["imagefolder"]
> // Image control's ImageFile property to display the image
> this.image1 = cImageFileName
> return
The code I use
disp_image(alltrim(form.invedatamodule1.photo.rowset.fields["path"].value)
,alltrim(z["company"].value)+" " + alltrim(z["item"].value) + " "+
alltrim(z["descrip"].value) )
function disp_image
parameters mfile , title
?mfile
?title
local image_f
image_f = new form()
with image_f
height = 22.7273
left = 5.7143
top = 0.0
width = 142.0
text = iif(type('title') = "C","Photo of "+alltrim(title),"Photo
of ")
endwith
image_f.IMAGE1 = new IMAGE(image_f)
with (image_f.IMAGE1)
height = 22.6364
left = 0.0
top = 0.0
width = 142.0
dataSource = [FILENAME "]+mfile+["]
?datasource
alignment = 3 // Keep Aspect Stretch
anchor = 3 // Left
endwith
image_f.mdi = false
?"Going to open form"
image_f.readmodal()
image_f.release()
return true
It is working perfectly.
Watch for wordwrap.
Note the property datasource and use of keyword Filename.
Test it and then customise it according to your needs.
Another line that is working well.
mform.image1.dataSource = 'FILENAME "'+
form.e_invedatamodule1.photo.rowset.fields["path"].value +'"'
Please take note of delimiters. They require special handling.
mform.image1.dataSource = 'FILENAME "myfile.jpg"'
should be the net result.
Regards
Akshat
|
|