Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

embedding a jpg or bmp in a general field programatically

Status
Not open for further replies.

vdeveloper

Programmer
Aug 5, 2000
42
IN
Hi all

How can I embed a jpg or bmp image into a general field programatically ? what is the syntax to be used ? I have a database which stores pathnames of the images in a memo field and shows the actual picture when a report is generated for which I have to create a temporary cursor having a general field.

Thanks

Ravi
 
this is from VFP 6.0's help:

Syntax

APPEND GENERAL GeneralFieldName
[FROM FileName]
[DATA cExpression]
[LINK]
[CLASS OLEClassName]

Arguments

GeneralFieldName

Specifies the name of the general field in which the OLE object is placed. You can specify a general field in a table open in a noncurrent work area by including the table alias with the field name.

FROM FileName

Specifies the file containing the OLE object. You must include the entire file name, including its extension. If the file is located in a directory other than the current default directory, include the path with the file name.

DATA cExpression

Specifies a character expression that is evaluated and passed as a character string to the OLE object in the general field. The OLE object must be capable of receiving and processing the string. For example, you cannot send a character string to a graphics object such as one created using Paintbrush.

LINK

Creates a link between the OLE object and the file that contains the object. The OLE object appears in the general field but the object's definition remains in the file. If you omit LINK, the OLE object is embedded in the general field.

CLASS OLEClassName

Specifies an OLE class for an OLE object other than the default class.

Tip You can determine the class for an OLE object by running REGEDIT and double-clicking the OLE object. The class name is listed under Identifier.

You can specify a class name when the file extension for the file containing the OLE object is different from the default extension and you want to force the behavior for the class. If the default extension can be used by multiple Automation servers, include the class to specify a particular server.

Remarks

If an OLE object already exists in the general field, it is replaced with the OLE object from the file. To remove an OLE object from a general field, issue APPEND GENERAL GeneralFieldName (GeneralFieldName is the name of the general field to clear) without any additional arguments.


just one piece of advice - be very careful of storing large image files into general fields since they tend to get bloated in time. i suggest you just use a character field for the path of your image files and then open them using codes. there are lots of sample codes of image viewers in this forum. feel free to browse in the FAQ section for such a need.

kilroy [trooper]
philippines
"and that's what we call creativity..."
 
Hi all

thanks for the replies

I just need to do this in a temporary cursor which is closed and destroyed after the report is run, so database bloat does not enter into the picture here.

what is the OLEclassname for jpg images? I have found out that OLEClassname for BMPs is PBRUSH.

Thanks


 
Vdeveloper,

The OLE class name for a JPG image depends on which application is registered for that file type on the user's machine. But, in any case, you don't need to specify it in the APPEND GENERAL command. Just ignore it.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Hi Mike

I tried giving &quot;append general <fieldname> from <jpg filename>&quot; and I am getting an error which says &quot;OLE Error. application not found&quot;. How can I solve this problem? How can I find out which class / application is registered for JPG files?

Thanks

Ravi
 
Ravi,

OK, if that's right, maybe you need the class name after all.

Assuming you have access to the computer on which this is running, you could go to the Folder Options window (from the Tools menu in any folder window), then go to the File Types page. Scroll down until you see the extension you are interested in, and check the associated application.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Hi Mike

I did check through folder options and the JPG file type is associated with 'IEXPLORE'. accordingly if I give the command as &quot;append general <fieldname> from <jpg filename> class iexplore&quot;, I still am getting the same OLE error mentioned above. what could be the problem here? or am I entering the command wrongly?

Thanks

Ravi
 
I am just investigating this to do the same thing and am dissapointed...

My PC produces a lovely report but most others miss out the images.

By default there does not appear to be a 'server' registered so the pictures do not appear on a Report.

My registry entry

HKEY-CLASSES_ROOT\.jpg says (Default) REG-SZ CorelPhotoPaint.Image.8

I have canvased some thirty people - few have an app entry there other than what appears to be the default - jpegfile]

One other that appears is REG_SZ DellImageExpertImage

Our questions are

Can a small 'server' be distributed with a VFP app

How is it registered?

Surely others have come across this problem?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top