My configuration:
P3 1GHZ, 512MB Ram, HDD 80GB. (55GB Free).
Windows XP Pro, all updates and Service Packs,
Visual Fox Pro 8.0 all updates and Service Packs,
Norton Antivirus 2003 updated and running.
Thanks a lot.
Javier
Did you know it's better not to use general fields at all? You can run into
problems if the OLE server that was used to store the image in the general
field, is not
available. In addition, it's hard to get data out of the general field.
Instead, use binary memo fields. In VFP9, you can use the new Blob data type
to store image data. A public beta of VFP9 will be available this month.
Here's some samples by Trevor Hancock of MS VFP Product Support:
REPORT
---------------
By using the MEMO BINARY field type and a UDF(), we can store .JPG files in
a table field yet when the report
runs have them read from DISK. Here's how:
(1) Create a table or cursor with a structure like this (plus any added
fields as necessary)
FileName C (150)
MemBin MEMO(BINARY)
The command would be CREATE TABLE GENDBF (FileName c(150), MemoBin M
NOCPTRANS)
(2) Append .JPG/BMP files into the MEMO(Binary) field using FILETOSTR() and
set the filename field
accordingly. For instance:
INSERT INTO CURSORNAME VALUES("ToothBrush.JPG", FILETOSTR(<PathToFile>))
(3) The FoxPro report will still need an OLEBOUND control on it to print
pictures, but instead of pointing the
OLEBOUND to a general field, point it FILE and use this as the expression:
MYUDF(FileName, MemoBin)
Where MyUDF is in some program made available via SET PROC and reads thusly:
PROCEDURE MYUDF(lpFileName, lpMemoBinFld)
LOCAL lcTemp as String
lcTemp = ADDBS(SYS(2023)) + "JPGTEMP\"
IF !DIRECTORY(lcTemp)
MD (lcTemp)
ENDIF
SET SAFETY OFF
STRTOFILE(lpMemoBinFld, lcTemp + lpFileName)
SET SAFETY ON
RETURN lcTemp + lpFileName
(4) Finally, preview/print the report. You may also want to fire some lines
like this to clean up afterward:
ERASE ADDBS(SYS(2023)) + "JPGTEMP\*.jpg"
RD ADDBS(SYS(2023)) + "JPGTEMP"
----------------------------------------------------------------------------
---
===FORM (code assumes full install of VFP8)===
CREATE CURSOR PICTURES (FileName c(150), MemBin M NOCPTRANS)
INSERT INTO PICTURES VALUES([FOX.bmp], FILETOSTR(ADDBS(HOME()) + [FOX.BMP]))
INSERT INTO PICTURES VALUES([Bandrpt.bmp], FILETOSTR(ADDBS(HOME()) +
[Wizards\Bandrpt.bmp]))
INSERT INTO PICTURES VALUES([readme2.jpg], FILETOSTR(ADDBS(HOME()) +
[samples\webservices
\northwind\readme2.jpg]))
LOCATE
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.SHOW
RETURN
**************************************************
DEFINE CLASS form1 AS FORM
TOP = 71
LEFT = 48
HEIGHT = 310
WIDTH = 504
CAPTION = "Fox Image Demo"
NAME = "Form1"
ADD OBJECT image1 AS IMAGE WITH ;
HEIGHT = 296, ;
LEFT = 3, ;
TOP = 8, ;
WIDTH = 381, ;
NAME = "Image1"
ADD OBJECT cmdPrevious AS COMMANDBUTTON WITH ;
TOP = 27, ;
LEFT = 422, ;
HEIGHT = 27, ;
WIDTH = 24, ;
CAPTION = "<", ;
NAME = "cmdPrevious"
ADD OBJECT cmdNext AS COMMANDBUTTON WITH ;
TOP = 27, ;
LEFT = 446, ;
HEIGHT = 27, ;
WIDTH = 24, ;
CAPTION = ">", ;
NAME = "cmdNext"
ADD OBJECT cmdQuit AS COMMANDBUTTON WITH ;
TOP = 72, ;
LEFT = 405, ;
HEIGHT = 27, ;
WIDTH = 84, ;
CAPTION = "Quit", ;
NAME = "cmdQuit"
PROCEDURE getimage
LPARAMETERS lpFileName, lpMemoBinFld
LOCAL lcTemp AS STRING
lcTemp = ADDBS(SYS(2023)) + "JPGTEMP\"
IF !DIRECTORY(lcTemp)
MD (lcTemp)
ENDIF
SET SAFETY OFF
STRTOFILE(lpMemoBinFld, lcTemp + lpFileName)
SET SAFETY ON
RETURN lcTemp + lpFileName
ENDPROC
PROCEDURE DESTROY
USE IN SELECT([PICTURES])
ERASE ADDBS(SYS(2023)) + [JPGTEMP\*.jpg]
ERASE ADDBS(SYS(2023)) + [JPGTEMP\*.bmp]
RD ADDBS(SYS(2023)) + [JPGTEMP]
ENDPROC
PROCEDURE INIT
THISFORM.image1.PICTURE = ;
THIS.getimage(PICTURES.FileName, PICTURES.MemBin)
ENDPROC
PROCEDURE cmdPrevious.CLICK
IF RECNO() <> 1
SKIP -1
THISFORM.image1.PICTURE = ;
THISFORM.getimage(PICTURES.FileName, PICTURES.MemBin)
THISFORM.REFRESH
ENDIF
ENDPROC
PROCEDURE cmdNext.CLICK
IF RECCOUNT() <> RECNO() AND !EOF()
SKIP
THISFORM.image1.PICTURE = ;
THISFORM.getimage(PICTURES.FileName, PICTURES.MemBin)
THISFORM.REFRESH
ENDIF
ENDPROC
PROCEDURE cmdQuit.CLICK
THISFORM.RELEASE
ENDPROC
ENDDEFINE
**************************************************
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
Eric is right, you can better use a binary memo field to store pictures, or
store the path + file name and path in a file name...
Anyway a workaround for your problem is to find out which program on the
machine is associated with bmp and jpg files. Uninstall that program or/and
make sure that "paint" is associated with the images.
You can use General fields for object linking and embeding...
Gerben Kessen.
"Javier Valverde" <anon...@discussions.microsoft.com> wrote in message
news:230C94B8-BBCE-4479...@microsoft.com...
> Thanks Eric, but instead what can I do to make available the OLE server?
because I need that my application work. And if the General Field is better
not to use, why they are in the VFP?..
>
> I have to resolve my problem and is very convenient to me to fix the error
as is, because I have not time to use changing the code.
>
> Thanks
>
> Javier