Baanboard.com

Baanboard.com (http://www.baanboard.com/baanboard/index.php)
-   Code & Utilities (http://www.baanboard.com/baanboard/forumdisplay.php?f=33)
-   -   Pictures on Baan IV Forms (http://www.baanboard.com/baanboard/showthread.php?t=12892)

Ruskin 9th September 2003 06:34

Pictures on Baan IV Forms
 
1 Attachment(s)
Firstly, I can not take any credit for the development of this code... It was posted in the thread: Photo Display on Form , 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

Resizing windows
 
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. 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

could u please provide a screen shot
 
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:
Code:

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()
Code:

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:
Code:

|        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;
Code:


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

Improved version..
 
1 Attachment(s)
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

Hi Ruskin,
 
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!


All times are GMT +2. The time now is 17:03.


vB.Sponsors
©2001-2017 - Baanboard.com - Baanforums.com