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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ERROR CREATING OLE OBJECT

Status
Not open for further replies.

savita

Programmer
May 19, 2002
6
0
0
HK
I am using FPW2.6 to convert BMP image file into JPEG format using ESPIA 3rd party software.

when using append general field_name from c:\image_file.bmp class paint.picture

I have also tried different class as PBRUSH and without class as well, however when I use this application on Win XPP it does not append the picture some time and sometime it does.

My XPP machine is running with 512 MB as main memory, P4 CPU.

Please advise.

Thanks a lot.
Savita

 
Savita,
I wrote the following back in the fall of 1996 for our local Fox User Group newsletter
Code:
I'm sure that most of you have at least seen or played with the OLE demonstrations that display pictures (.BMP or .PCX files) using GENERAL fields. (In FoxPro for Windows 2.5 see \GOODIES\PHOTOALB and for FPW 2.6 see \SAMPLE\OLE\.) This is definitely an inexpensive way to add the ability to display pictures in your FoxPro for Windows' applications. 'PaintBrush', the OLE server that actually does the work, even comes "free" with every copy of Windows. The code to put the picture into a GENERAL field is quite straight forward (e.g.):

   APPEND GENERAL tmp.PHOTO FROM my.pcx;
    CLASS PBRUSH

To display this picture, just use the Picture Tool in the Screen designer or in code (also as generated in the .SPR):

   @ 1.000,25.000 SAY tmp.photo ;
     SIZE 22.000,94.000 ;
     CENTER ISOMETRIC STYLE ""

This works great under Windows 3.1x, Windows NT and even under Windows 95 - if you installed it using the upgrade version. The problem comes when you run the application on a machine that came with Windows 95 and has never 'seen' Windows 3.1x.

The key is to 'know' that the <ole Class> mentioned in the help file syntax (see below) is NOT the name of the 'PaintBrush' code file (PBRUSH.EXE), but rather the 'ProgID' (Win 95) or the 'Identifier' (Win 3.1x) of the OLE server as defined in the approproiate Registration Database (run REGEDIT.EXE to view).

   APPEND GENERAL <general field> FROM <file>
     | FROM MEMO <picture field>
      [LINK]
      [CLASS <ole class>] 

In Windows 95 the 'Paint' program is MSPAINT.EXE, and has a ProgID of PAINT.PICTURE. After borrowing and adapting a TIP from FoxPro Advisor Magazine (June 1996) by Rick Strahl which sets some platform specific flags, my "cross-platform" code now reads:

DO CASE
CASE _WIN31
   APPEND GENERAL tmp.PHOTO FROM my.pcx ;
     CLASS PBRUSH
CASE _WIN95
   APPEND GENERAL tmp.PHOTO FROM my.pcx ;
     CLASS PAINT.PICTURE
CASE _WINNT
   APPEND GENERAL tmp.PHOTO FROM my.pcx ;
     CLASS PBRUSH
ENDCASE

This is the first 'major' coding change that I've had to make to run FPW applications under Windows 95 - let's hope that there aren't too many other surprises waiting. Note: While I was explicitly developing this under FPW, all the above information should apply to VFP also.

Note: The details of the FPA article are no longer available, but the ideas used are the same in the code at However in FPW, everything newer than Win 3.x comes up 3.95!

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top