Ruskin
9th September 2003, 06:34
Firstly, I can not take any credit for the development of this code... It was posted in the thread: Photo Display on Form (http://www.baanboard.com/baanboard/showthread.php?s=&threadid=5825) , by '~Vamsi'. I have just turned it into an easy to use include....
Simply call it by;
igen0100.display.photo.default(<full path and filename to GIF file>)
Don't forget to destroy the objects with;
igen0100.clear.photo.display()
either in the choice.end.program and choice.abort.program, or when you need the picture cleared..
en@frrom
9th September 2003, 10:56
will this code not work for Baan V?
Ruskin
9th September 2003, 23:06
never tried in Baan V, but can't see why not (it wouldn't be a difficult job to port it to Baan V, if it doesn't)...
en@frrom
17th September 2003, 15:09
Hi Ruskin,
Used this function, and seems to work well. Have got one problem though:
Say I use this in a display session, where the session opens let's say on nearly full screen. In the init.form (tried also before.form) I call the function to display a gif in the top-right corner. This works ok. Then I resize the window (just with the mouse) and make it smaller. The gif's location will not be adjusted accordingly (i.e. recalculate the proportions from the window edges), and as a result the whole window looks clumsy with this gif stuck out there on an unsuitable location. Basically it will be impossible to decrease the window-width smaller than the original size, because this gif stays stuck on the original (width) location.
Encountered this? Have a solution for it? Would be great, because the way it is now, I cannot apply it.
Tia,
En.
NvanBeest
17th September 2003, 15:19
Hi En.
Have a look at the function change.sub.object (http://www.baanboard.com/programmers_manual_baanerp_help_functions_user_interface_objects_create_sub_object). You could call this to move and/or resize the picture in the choice.resize.frm section.
Ruskin
18th September 2003, 06:50
Not sure if the solution by NvanBeest will work (redrawing the sub-object, when the main object is not large enough, won't work)... It may automatically resize the main object, so will be worth trying. But the best solution, is as he suggested, in the choice.resize.frm
What you should do, is call;
igen0100.clear.photo.display
Then call the;
igen0100.display.photo.in.location
function, to recreate the photo, with the new x,y co-ordinates and photo height/width. You may need to determine the x.y co-ordinates yourself in this case.
Thus, when the user resizes the form, it clears and redraws the image.
learner
22nd September 2003, 19:22
Hello,
Could u please provide a screen shot of the form with the pic on it.... I don't have an access to the system right now.
Regards
Learner
en@frrom
23rd September 2003, 13:58
Hey Ruskin,
Thanks for your advice. I had already tried the way you described, but received bw-errors. Thought it was as a result. After debugging, I saw that in the function clear.photo.display(), there is a destroy on object.mimg which caused the errors, for there was never an update.object on object.mimg...
I now use a clear.photo.display() and display.photo.in.location() in the choice.resize.frm after.choice section (and in case of multiple forms -> tabs, it is necessary to re-display also on each before.form), and now it works perfectly.
Thanks a lot!!
Kind regards,
En.
~Vamsi
23rd September 2003, 15:49
En,
Could you please post the code with the updates.
en@frrom
23rd September 2003, 17:35
I made only few little changes.
Here it goes:
In function init.photo.settings:
function igen0100.init.photo.settings()
{
long int.value(MWINMAXSIZE)
| if not igen0100.init or
| igen0100.form.width = 0 or
| igen0100.form.height = 0 then
| igen0100.init = true
igen0100.object.main = current.mwindow()
get.mwindow.attrs(int.value)
igen0100.form.width = int.value(11)
igen0100.form.height = int.value(12)
| endif
}
I pipe-lined the conditions, because I want the window attributes to be re-read every time the function is called [in order to get the right location when resizing a form].
In function clear.photo.display()
function igen0100.clear.photo.display()
{
destroy.object(igen0100.object.mpix)
destroy.object(igen0100.object.midc)
destroy.object(igen0100.object.midp)
| destroy.object(igen0100.object.mimg)
update.object(igen0100.object.main)
}
I pipe-lined the destroy.object(igen0100.object.mimg), because there is never an update.object on mimg; therefor it results in a bw-error 'Object %d not found'.
For the rest I only changed some of the default sizing and positioning, but this is depending on each one's personal preferences. I for instance do not understand why the minimum height+width sizes have to be 100 (any reason Ruskin??), so I pipe-lined this piece:
| if igen0100.hght < 100 then
| igen0100.hght = 100
| endif
| if igen0100.wdth < 100 then
| igen0100.wdth = 100
| endif
I finally changed the default locations in the default.x/y.position() functions to be displayed default in the far top right corner. So for default x pos I have:
return(igen0100.form.width - igen0100.wdth)
and for y pos:
return(20).
Regards,
En.
Ruskin
25th September 2003, 03:32
Thanks En...
Sorry I haven't responded earlier, haven't been to the site for a few days.
You are quite correct, the sub object does not need a 'destroy.object' function for it. Thanks for pointing that out... Also, I found I got some BW errors when destroying the object multiple times, so amended the clear function as follows;
function igen0100.clear.photo.display()
{
if igen0100.object.mpix then
destroy.object(igen0100.object.mpix)
igen0100.object.mpix = 0
endif
if igen0100.object.midc then
destroy.object(igen0100.object.midc)
igen0100.object.midc = 0
endif
if igen0100.object.midp then
destroy.object(igen0100.object.midp)
igen0100.object.midp = 0
endif
| destroy.object(igen0100.object.mimg)
if igen0100.object.main then
update.object(igen0100.object.main)
endif
}
The only reason I made the minimum height and width at 100, was for our photos. At that size they fit on our form perfectly and aren't dis-proportional. It's entirely up to you, whether you use that minimum size or create your own...
kind regards...
en@frrom
25th September 2003, 10:29
Thanks Ruskin!
en@frrom
12th June 2006, 16:11
To all that may find it usefull...
I have used Ruskin's function for the past couple of years for displaying of logo's on some customized sessions. I was now working on a good efficient item file as a display session in Baan. One of the requirements, was including images of the item, up-to 5 images per item.
I wanted to use my existing function (Ruskin's), but saw that the function can actually only handle display of one image per form. I therefor improved the function to be able to handle display of up-to 5 images each time.
There is an optional argument in the function call, which passes the image number. I have done it in the way of an optional argument, so that I will not have to change all the program scripts which call the function till now... If the optional argument is not filled, then the image number will be defaulted to 1 (for display of one image only).
Attached is the code...
If anyone has further suggestions and/or remarks, I'm always here to listen...
Regards,
En
jhansirani
1st July 2006, 09:26
Is this is helpful for multiple records? Example - if we select empno and we select photo - it will go for particular employee.gif and display?
Thanks & Regards,
Jhansi Rani B
en@frrom
3rd July 2006, 10:26
Of course you can do it. I use it for instance for items. Per item I could have up to five different images. So the file names are <itemcode>1, <itemcode>2 etc, and the session calls the corresponding images.
The same you can do with your employees...
Good luck!
raikar_raviraj
30th September 2006, 09:37
Hi,
I ve used the script that was provided in this thread and used it in a form to display a gif image on the form.
But when i actually ran the form it showed file not found message on the form.
I debugged it and found that in the following code, r.return equals to false.
In the stat.info function r.mode value is false so r.return doesnt gets assigned to value true so the message gets displayed on the form.
ret.info = stat.info( igen0100.phto, r.size,
r.mode, r.inode,
r.dev, r.uid,
r.gid, r.nlink,
r.ctime, r.mtime,
r.atime )
r.return = false
if ( S_ISDIR(r.mode) ) then
|* DIRECTORY SPECIFIED !!!!
else
if ret.info then
|* FILE OR DIRECTORY IS INVALID !!!!
else
|File exists
r.return = true
endif
endif
What could be the problem? i have specified the correct path and i tried putting it on server as well as client machine but the problem still exist.
please help.
Thanks
Regards
Raviraj
vaishrii
3rd October 2006, 07:43
Thanks 2 all involved in this post.. (picture on form) specially Vamsi for your valuable suggestions.
I tried this solution for getting employee photo on form & its working fine.
thanks again,
Regards,
Vaishali
en@frrom
3rd October 2006, 10:52
Hi Raviraj,
There must be something wrong with your file path. Can you post your file path? Is it hard coded or based on form field (user's selection)? Please post your script also.
Regards,
En
en@frrom
3rd January 2007, 15:09
To all who are displaying images on Baan-forms:
I am displaying gif-files on Baan forms, but unfortunately the quality of the images is reduced/decreased. I.e. the actual gif, when opening in any editor or windows-application (Word, Excel, etc) has a much sharper and better quality than when displaying on a Baan form.
Have others encountered this too? Does anyone know why this is? And does anyone have a solution to this issue??
And last but not least: has anyone anno 2007 found a solution for displaying jpg-format on the baan forms rather than being limited to gif only...???
Regards,
Eli Nager
en@frrom
9th January 2007, 16:05
To all,
Just to let you know that I have found the reason for the bad quality of the images. The rgb values were (128,128,128) which gives nearly every second pixel as black/grey worthless quality. After fixing this and matching the rgb-values to be exactly the same as the screen-colour the images are displayed on, it works like a charm..
Regards,
Eli Nager
en@frrom
9th January 2007, 16:22
See my new thread (http://www.baanboard.com/baanboard/showthread.php?p=106458#post106458) for the next funtional step in using images on Baan forms... Any input is appreciated!
Regards,
Eli Nager
tnzabo
15th May 2007, 23:39
How do you implement this code? Do you make it a 3gl program script that is called from in a normal session code? Do you make it a library?
very interested in trying this out.
thanks - Nikkiz
george7a
16th May 2007, 09:18
Hi,
You will have to include the script that is attached in this thread to your main script and then use the function:
igen0100.display.photo.default(<full path and filename to GIF file>)
- George
yogesh kapil
9th October 2012, 14:03
Hi En,
I am having problem, how can i allow my user to attach any file in customize session and print the file. i saw your code but not able to understand. can you please help me.
Of course you can do it. I use it for instance for items. Per item I could have up to five different images. So the file names are <itemcode>1, <itemcode>2 etc, and the session calls the corresponding images.
The same you can do with your employees...
Good luck!
bdittmar
13th October 2012, 16:10
Hi En,
I am having problem, how can i allow my user to attach any file in customize session and print the file. i saw your code but not able to understand. can you please help me.
Hello,
it's a 5 year old B4 post.
In LN use ODM functionality !
Regards
kvl8969
7th February 2014, 08:49
Can any way to use in ERP LN?