NPRao
16th April 2003, 00:41
I have seen few postings on the board about displaying photos/picture with BaaN Tools.

Thanks to Vamsi and a few others, I got some baseline code to start with and finish it off.

I have this code in a DLL and it can be called by any program.


#define ALTF4 ((1024-1) + 4)
function extern view.picture(string pic.path(256))
{
DLLUSAGE
view the *.gif file in a picture browser
ENDDLLUSAGE
long gwin
long cmap_sz
long cmap(256)
long icon_w, icon_h
long valid.icon
long buflen, fp
string imap(1) based
string bufr(1) based
long idc, idp, image
long event(EVTMAXSIZE), type, option

on case ostype()
case OS_WINDOWS_95:
case OS_WINDOWS_NT:
pic.path = tolower$(pic.path)
|* Dos/Windows files are case insensitive
break
case OS_UNIX:
case OS_OS400:
break |* Unix files are case sensitive
endcase
pic.path = strip$(shiftl$(pic.path))
if pic.path(len(pic.path) - 3) <> ".gif" then
mess("zmadms0037", 1) |* Only *.gif files can be used
return
endif
fp = seq.open(pic.path, "r")
if fp < 0 then
mess("zmadms0010", 1) |* File Handling Errors
return
endif
buflen = seq.seek(0, 2, fp)
e = alloc.mem(bufr, buflen)
e = seq.rewind(fp)
if seq.read(bufr, buflen, fp) > 0 then
if get.pixmap.info(bufr, cmap_sz, icon_w, icon_h) then
alloc.mem(imap, icon_w * icon_h)
valid.icon = decompress.pixmap(bufr, cmap, imap)
cmap(1) = rgb(128,128,128)
endif
else
mess("zmadms0010", 1) |* File Handling Errors
return
endif
e = seq.close(fp)
free.mem(bufr)
gwin = create.object( DsCgwindow, current.mwindow(),
DsNbackground, 3 ,
DsNwidth, icon_w,
DsNheight, icon_h,
DsNpointerCursor, DSCHAND, DsNeventMask, EVTALLEVENTMASK )
update.object(gwin)
idc = create.object(DsCcolormap,current.display(),DsNcolorTable,cmap,cmap_sz)
idp = create.object( DsCpixmap, current.display(),
DsNcolormap, idc,
DsNwidth, icon_w,
DsNheight, icon_h,
DsNdata, imap,
icon_w * icon_h,
DsNdataType, DSPIXMAP8 )
image = create.sub.object( gwin, DsCgpImage,
DsNpixmap, idp,
DsNx, 0,
DsNy, 0 )
raise.object(gwin)
repeat
option = 0
type = next.event(event)
on case type
case EVTKEYPRESS:
if ( evt.keypress.key(event) = ALTF4 ) then
option = 1
break
endif
case EVTBUTTONPRESS:
if ( evt.button.button(event) = ALTF4 ) then
option = 1
break
endif
endcase
until (option)
if image <> 0 then
destroy.sub.object(gwin, image)
endif
if gwin <> 0 then
destroy.object(gwin)
endif
}
|******************************************************************************


Any suggestions and enhancements are welcome!

rochus
25th April 2003, 20:45
any idea, how to prevent , that program ends after
pressing "Alt+F4" ?

mark_h
25th April 2003, 20:54
You can actually drop the code after the repeat statement. Of course then you need to make sure you can exit the session.

If you wanted you could actually drop this code into a 4gl session and put a company logo on a session. That is how I tested it - I actually put the code into a init.form section.

Mark

NPRao
8th July 2003, 22:54
oh well, after all I found a BaaN standard function to do this.

I found it in the tools library - ttstp_stddll

image.display
long image.display( const string image.path() )

image.display() appears to activate ttdskimage and sends the image.path as a parameter. ttdskimage appears to call create.pixmap() and then proceed to create a window to display the image in. It appears to process ALT-F4 to shut down the window and resize events.

Eddie Monster
22nd July 2003, 17:51
NPRao,

Could you please provide an example of the image.display() function used in code? I am having trouble getting my code to compile correctly.

Thanks!

Francesco
22nd July 2003, 19:48
I used Prashant's finding to introduce my newborn to my collegues in (Baan)style.
This was all it took in a 3GL script:

|***************************************************
|* cecusffjonah 0 VRC B50o b uat
|* Show Jonah
|* francesco
|* 07-09-03 [04:51]
|***************************************************
|* Script Type: 0
|***************************************************

function main()
{
image.display( "/opt/apps/baan/tmp/jonah.gif" )
}

Eddie Monster
22nd July 2003, 20:59
Here is my code. I'm trying to use it within a form (maybe that is the problem...)

|******************************************************************************
|* tdtstimage 0 VRC B40C c4 obg4
|* View Image on Form Test
|* erice
|* 07-22-03 [09:34]
|******************************************************************************
|* Script Type: 4
|******************************************************************************
| Written by: Eric Edder
| Request: TR
|****************************** DECLARATION SECTION ***************************
declaration:

| Selection Criteria

| Working Storage

| Libraries


|****************************** PROGRAM SECTION ***************************
|****************************** ZOOM FROM SECTION ***************************
|****************************** FORM SECTION ***************************

form.1:
init.form:
get.screen.defaults()

|****************************** CHOICE SECTION ***************************

choice.cont.process:
on.choice:
image.display("/app/baan4/bse/common/test.gif")

|****************************** FIELD SECTION ***************************
|****************************** MAIN TABLE SECTION ***************************
|****************************** FUNCTION SECTION ***************************
functions:

|******************************************************************************
| This function...
|******************************************************************************
|function main.function()
|{

|}

|****************************** END OF SCRIPT ***************************



and this is my error upon compiling:

Error: Unresolved reference to function 'image.display'

Should I try to make my form call a 3GL program to display the image?

Eddie Monster
22nd July 2003, 21:06
Is this function even available in Baan IV????

NPRao
22nd July 2003, 21:14
Eddie,

Check the functions prototype of the tools object - ttstp_stddll

>bic_info6.2 -?
bic_info6.2: illegal option ?
Show Object Information (c)

Usage: bic_info6.2 [-aideushwcV] [-f[flags]] object

-a : Show all object information
-i : Show assembler
-d : Show used DLL's
-e : Show exported DLL function prototypes
-u : Show usage of DLL (description)
-s : Show symboltable
-h : Show object header
-w : Show object idents (what)
-c : Check checksum
-f : Show all flags
-f<flg> : Test flags 1=NOTRANSACTIONS 2=DEBUG
4=PROFILE 8=DLL
-qo <out>: Redirect output to file out
-qe <err>: Redirect error output to file err
-set <env=val>:
set environment variable
-V : Show version

You can use $ bic_info6.2 -e ottstp_stddll to check the function prototypes if this function is available in your BaaN version or not.

Eddie Monster
22nd July 2003, 21:31
Thank you for the quick response!

I ran bic_info6.1 but I'm not quite sure what all of that information is (sounds like that could be an entirely new post).


I used the following command (using the -a switch instead of -e to see what was available):

bic_info6.1 -a ottstp_stddll

in the DLL prototype there was a long list of functions. The only 'display' functions were:

display.enumerate()
display.info()
display.note()

Does this mean that I can't use it or I need to update some sort of object??? Please advise, I'm a little lost.

NPRao
22nd July 2003, 21:56
Eddie,

use $ bic_info6.1 -e ottstp_stddll to check the function prototypes if this function is available in your BaaN version or not.

If the function is not available then you need to check up with the BaaN support if you there are any latest patches in tools.

Also, this function might not have been ported to the BaaN-4 series. I cannot validate that as I do not have access to BaaN-4 versions, and we are working on BaaN-5.2

BaaN support gave me this info.
Caution -
"image.display() is not documented in the programmers guide and is not supported for customer use. Since it is declared as extern, they can use it, but at their own risk. We may make changes to these at any time without notification."

rupertb
23rd July 2003, 09:41
No Prashanth image.display() is not available in c4 it looks like eddie will have to take the long road...

Regards,
Rupert