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

Graphics in .doc problem 2

Status
Not open for further replies.

jlockley

Technical User
Nov 28, 2001
1,522
US
To store pictures of my chefs' dishes for international placement I have been pasting the graphics into Word documents and cuttinig and pasting those into an object field. This works wonderfully, and when I view the field in the form I see perfect, tiny plates of cuisine. These disappear, however, when I open the document, leaving the circle, triangle and square icon which shows no picture available.I am going to fiddle wiht graphics fields, but does does anyone have an idea why I can't access them? Thank you.
 
Added graphics question: How (preferably with the easy interface) can I set a field on a form to accept a .gif or .jpg or other file by cut and paste, as it is possible to do with a word document. I set up a data entry field for a graphics on a dummy file, but attempting to paste the picture I get an error message that the field cannot accept embedded objects. I can use the past from option for .gif (not .jpg) files, which is more cumbersome, but I cannot open the file later. Is this a limitation or something I am doing wrong?
 
I'm not sure I understand you correctly, but here goes.

First, the graphics object needs to be attached to an underlying graphic field in a table if you plan to have it change depending on the record (there are programatic ways to do this, but for simplicity you should use a table). Next, the table must be in edit mode. Finally, right-click on the graphics object and tell it to paste.

Here is some button code to accomplish image insertion if you prefer to click a button and get your image from file.

Code:
var
   fbi FileBrowserInfo
   imageHolder	graphic
   selectedFile String
   fs	FileSystem
endVar

fbi.Alias = ":SxImage:" ; where the files are located
fbi.CustomFilter = "(Bitmap image) *.bmp|*.bmp|(Other graphics files) *.jpg;*.pcx|*.jpg;*.pcx||"

if fileBrowserEx(selectedFile, fbi)
  then	if not imageHolder.readFromFile(selectedFile)
           then	msgInfo("Error","Problem reading file. Try again.")
        return
   	endif
   	  else return
endIf

image = imageHolder ; 'image' is the name of your field
Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
I think I have it figured out, but it's odd. I began with a graphics field attempting to cut and paste as you would a word document. With word you can either just pick up the document from it's folder, or you can cut and paste from the document itself. Copying the file directly or cut and paste from IE as graphics browser (I have to change that) both result in the error. I have just found, however, that it is quite possible to cut and paste from paint, and I have no doubt from Adobe or Corel Draw (Have both on other stations), so the problem's solved. Curious, but solved.

Thanks very much for the help.

JLL
 
..but I do have two questions (Every solved problem immediately throws a litter of wriggling pups).
1)With a document embedded in a record you can right click on the document to open int. This doesn't seem to happen with graphichs, or am I missing something?


2) I am about to try it, but why not ask? I don't need to look at this stuff when I surf candidates, so I don't need to see it up front. Putting their food pictures in with their resumes just makes everything easier, at least in theory. Is it possible to place a .zip file in a record as an object? More curious than hopeful.

Thanks again for the help. JLL
 
jll,

1) It depends on how the graphic is embedded. If it's embedded as an OLE object and you have a registered OLE editor, it should be openable.

In practice, you may find it more convenient to simply store a filename instead of the image and then to create a custom right-click menu to open the image in a poper graphic editor.

One reason why this may be more convenient stems from what happens internally when you save graphics. Regardless of the original image type, graphics are converted to WMF by Windows itself, thus you may lose palette information or find that the converted image takes more space than it originally did. (Unlike GIF's or JPG's, WMF files do not support compression.) Also, your image is automatically converted to the video depth of your current display settings. Again, you may lose detail.

2) Yes, it's possible. You have to store it in a BLOB (Binary) field. You also need code to handle this. Given this, it may (again) be easier to simply store the filename to the ZIP file and then to create a custom right-click menu for handling the ZIP file.

Hope this helps...

-- Lance
 
Thanks. I am getting smarter, but slowly. What about linking a zip file? I can think of a few reasons not to (for one it entails extra filing and naming), but your arguments are pretty strong.

I have a set of ten spaces where I can store images, but I haven't got anything worth worrying about stored there yet, so I could and probably go over to your plan a. What you are talking about is essentially linking, isn't it?

You know a moment ago I was feeling extremely clever, and now I am feeling extremely marginal. What one post will do for you. By the way, this is all about laziness in the long run. Thanks again.
 
jll,

Actually, I'm talking about a slightly different solutiuon than linking and embedding. My basic theory is to store filenames instead and then to simply store the files separately from the database.

That way, you don't have to worry about additional overhead for the linking (which is somewhat problematic anyway as Paradox doesn't fully implement the full linking features. That work was done quickly for version 5.0 and, AFAIK, has never been properly reviewed or updated).

Instead, you simply add an alpha field long enough to hold a pathname. I usually use an 8.3 for this. I then store the actual files in a subdirectory of my DATA directory (where I keep all my tables) and save the shortened version of the actual ZIP/graphic file.

When implementing this, I usually use a two-stage approach.

First, I create a library function for selecting a filename, such as the systemSaveAs() method shown below:

Code:
method systemSaveAs( var strFileName String,
                     fbiInput fileBrowserInfo ) Logical
;----------------------------------------------------------------
; This routine lets the user choose a filename for a save
; operation.  The parameters indicate, respectively, the location
; for the final file name and the options to be used with the
; fileBrowser() call.
;
; The return value indicates whether or not the user changed the
; file name from its initial value.
;----------------------------------------------------------------

var
   strValue  String            ; Fully qualified file name
   fbi       FileBrowserInfo   ; Structure for FileBrowser()
   loRetval  Logical           ; value returned to caller.
   dynParts  Dynarray[] String ; Parts of selected file.
   loRepeat  Logical           ; Variable for the while loop
endVar

   ; Initialize local variables
   loRetval = TRUE         ; assume user will choose a new name.
   loRepeat = TRUE         ; loop control variable
   strValue = strFileName  ; default selected file

   ; Initialize the file browser info structure
   fbi = fbiInput

   while loRepeat

      loRetval = fileBrowser( strValue, fbi )
      If loRetval then

         ; the user selected a file or the user selected an
         ; alias that no longer exists.  So, we need to determine
         ; If the user actually selected a file.

         ; Start by building the final file name from the
         ; components of the fileBroswerInfo structure.

         If fbi.Path <> &quot;&quot; then
            strValue = fbi.Path + strValue
         endIf

         If fbi.Drive <> &quot;&quot; then
            strValue = fbi.Drive + strValue
         else
            strValue = getAliasPath( fbi.alias ) + &quot;\\&quot; + strValue
         endIf

         splitFullFileName( strValue, dynParts )

         ; See if a bad alias was selected.

         If dynParts[ &quot;NAME&quot; ] = &quot;&quot; then
            msgStop( &quot;Can't Use Alias&quot;, &quot;The &quot; + fbi.Alias +
                     &quot; alias is not valid, presumeably because &quot; +
                     &quot;the folder or network drive no longer &quot; +
                     &quot;exists.  Choose a different alias or &quot; +
                     &quot;folder.&quot; )
            fbi.Alias = &quot;:PRIV:&quot;
         else
            loRepeat = FALSE
         endIf

      else
         loRepeat = FALSE
      endIf
   endWhile

   ; Now, determine whether or not the user changed the file
   ; name
   loRetval = NOT ( upper( FullName( strFileName ) ) =
                    upper( strValue ) )
   If loRetval then
      strFileName = strValue
   endIf

   dynParts.empty()
   return loRetval

endMethod

Next, I create a caller routine for dealing with the actual file inquestion. For example, here's another routine I use for saving graphs:

Code:
method graphSave( uiTarget UIObject ) Logical
; ---------------------------------------------------------------
; This routine lets the user save a graph as a bitmap image.
;
; The parameter points to the graph to be saved and the return
; value indicates whether or not the data was successfully saved.
; ---------------------------------------------------------------
var
   fbiXFile  FileBrowserInfo   ; data for systemSaveAs() function.
   loRetval  Logical           ; Value returned to calling process.
   strValue  String            ; Holds filenames
   dynParts  Dynarray[] String ; Holds parts of a filename.
   grOutput  Graphic           ; Internal var used to create BMP
endVar

const
   ERRTITLE = &quot;Can't Save Graph&quot;  ; title for error dialogs
endConst

   ; initialize local vars
   loRetval = TRUE
   strValue = &quot;MYGRAPH&quot;

   fbiXFile.Title          = &quot;Save Graph As&quot;

   ; Note the constant that's used here.  Though the documentation
   ; says the constant is called &quot;browseOptPathMustExist,&quot; that
   ; generates a compiler error.  A quick look at the table
   ; generated by enumRTLConstants() shows this is the constant
   ; to use instead.
   fbiXFile.Options        = browseOptPathMustExit
   fbiXFile.AllowableTypes = fbBitmap
   fbiXFile.Alias          = &quot;:PRIV:&quot;
   fbiXFile.NewFileOnly    = True
   fbiXFile.DefaultExt     = &quot;BMP&quot;

   ; Call the SaveAs wrapper function
   loRetval = systemSaveAs( strValue, fbiXFile )

   if loRetval then

      ; Breakapart the user's selected file name
      splitFullFileName( upper( strValue ), dynParts )


      ; Convert the graph to a bitmap.
      message( &quot;Copying graph to &quot; + strValue + &quot;...&quot; )
      setMouseShape( mouseWait )
      uiTarget.action( editCopySelection )
      grOutput.readFromClipboard()
      loRetval = grOutput.writeToFile( strValue )
      setMouseShape( mouseArrow )
      If not loRetval then
         errorShow( ERRTITLE,
                    &quot;Data failed to copy; see details...&quot; )
      endIf
   endIf
   Message( &quot;&quot; )
   return loRetval

endMethod

When calling this, I use something like this:

Code:
method pushButton(var eventInfo Event)

   doDefault
   libApp.graphSave( ChtData )

endMethod

Now, this is taken from a form with a global library variable and a graph object called chtData.

In your case, you'd probably want to rework graphSave() so it returns the name of the selected file to the calling process. Once you have that in hand, you'd basically store that into a string field.

Next, you'd add a trigger that would either execute WinZip with that value as an argument.

I don't have access to an example of that at the moment, but the above code should be enough to get you started. It was originally written for Paradox 8, but it should work in most other versions of Paradox.

Hope this helps...

-- Lance


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top