/* * Concordance Watermark DDE Communication program. * * Copyright (c) 1994 Dataflight Software, Inc. * 2337 Roscomare Road, Suite 11 * Los Angeles, CA 90077 * * ALL RIGHTS RESERVED. * * Unauthorized distribution, adaptation or use may be * subject to civil and criminal penalties. * * You may incorporate this program into your own programs * ONLY if you incorporate the following copyright notice: * * Copyright (c) 1994 YOUR NAME. ALL RIGHTS RESERVED. * Portions copyright (c) 1994 Dataflight Software, Inc. * * This program will cause Watermark Professional to display an * image file if the image file name is stored in the Concordance * database in an image field. Designate an image field on the * New/Modify Database screen by checking the "Image" check box. * * Create a "database.INI" or Concordw.INI file with the entry that * follows. In your case the "database" portion of the file name will * be the name of your own database. Place the file in the same * directory as the database.DCB file. The contents of the file * should be something like: * * [Settings] * ViewerCPL=F:\Apps\Viewers\Watermrk.cpl * * This setting will cause Concordance to execute the named CPL * program whenever a user clicks on the Camera icon on the Browse, * Table, or Edit screens. We have followed Watermark's instructions * on DDE commands, and the program works in the Dataflight office. * * NOTE: * The following conditions must be met for this program to work: * - ViewerCPL statement must be added to INI file, as shown above. * - Image field in Concordance must contain the full image path * (e.g. "C:\CONCORD5\CONCORD.TIF") * - Watermark executable ("wmpro.exe") must be specified * in the watermrk.cpl spawn() command (see program line 59) * - For the spawn()function to work, the watermark directory must * be included in the autoexec.bat path statement * - The image must be viewable if opened through native Watermark * (i.e., images must be of a demonstrably compatible file format) * */ /************************************************************************ * name: Watermrk * * synopsis: Sends a DDE message to the Watermark viewer to display * * an image. Executes the image viewer if it isn't running.* * returns: Returns NULL if not successful, non-zero if successful. * ************************************************************************/ main() { int hConv; /* Handle to Conversation */ int NULL; text hszService; /* Service Name Handle */ text hszTopic; /* Topic Name Handle */ int db, i; /* Make sure the database is open. */ if (db.documents >= 0) { /* Initialize the strings used to communicate with the DDE program. */ hszService = "Watermrk"; hszTopic = "System"; /* Try to connect, do a WinExec() if it isn't running. */ /* It will run Watermark if it is in the path. */ if ((hConv = ddeConnect(hszService,hszTopic)) == NULL) { /* No connection, execute the display program, it may not be running. */ /* Then try to connect to the server a second time. */ spawn("\windows\watermrk\watermrk.exe", ""); sleep(2); hConv = ddeConnect(hszService, hszTopic); } if (hConv == NULL) Message("Couldn't connect to "+hszService, 1); else { /* Bring Watermark to the fore. */ ddeExec(hConv,"[ShowWindow 2]"); /* Cycle through the fields, send the image field to Watermark. */ /* Use the str() function on the field, it will leave text fields */ /* alone and convert numeric fields to text for the dde message. */ for(i = 1; i <= db.fields; i = i + 1) if (db.image[i]) ddeExec(hConv,"[Open "+str(db->i)+", 0]"); ddeDisconnect(hConv); } } return(hConv); } /* main() */ /**************************************************************** * Name: RGB * * Synopsis: Convert red, green, blue values to a color. * ****************************************************************/ RGB(int red, grn, blu) { return(((blu & 255) * 65536) | ((grn & 255) * 256) | (red & 255)); } /**************************************************************** * Name: Message * * Synopsis: Displays error message and waits for key. * ****************************************************************/ Message(text message; int wait ) { text screen; int key; cursoroff(); /* If this isn't the windows version of Concordance, */ /* the box() function will produce a drop shadowed box */ /* ignoring the background color parameters. */ /* Draw a large dropped box with a raised box */ /* displayed in its center. */ if (wait) { screen = save(4,12,9,70); box( 5,13,9,69,"3U", RGB(128,0, 128), RGB(255,0,255)); box( 5,13,9,69,"3U", RGB(190,190,190), RGB(128,128,128)); puts(7,14,pad(message,'C',53), 0, RGB(255,0,255)); puts(7,14,pad(message,'C',53), 0, RGB(128,128,128)); key = edit("Ok" ,6, 61, 8, 67,"Button" ,1,"" ,0,0,MenuColor_); restore(4,12,screen); } else { box( 5,13,9,69,"3U", RGB(128,0, 128), RGB(255,0,255)); puts(6,14,pad(message,'C',53),0, RGB(255,0,255)); } return(asc(upper(chr(key)))); } /* Message() */