[V4RB] VPicture.SetPicture and RB 4.5.3

Frank Bitterlich bitterlich at gsco.de
Tue Mar 11 11:36:21 CST 2003


Ruslan,

I got a little closer now. First of all, it doesn't seem to have
anything to do whether RB 4.5.3 or 4.5.2 is used.

The V4RB Picture examples work fine on my machine.

Now the funny part: If I put the picture into an ImageWell before I call
VPicture.SetPicture, no crash occurs. I don't have to do anything else
with the imagewell; I'm not putting the picture into the ImageWell and
get it back, I just put a "copy" of the picture into the ImageWell.
Really strange.

What could be wrong with the picture? Or the VPicture field?

Here's the actual code:

  dim picfld as VPicture
  dim preview as Picture
  dim Alias as MacAliasMBS
  dim ALiasRec as string
  dim PK as integer
  
  
  if (fi=nil) or (not fi.Exists) or (oBOFiles=nil) then
    return false
  end if
  
  PK = DBGetPK
  VLong(oBOFiles.Field("PK")).Value=PK
  oBOFiles.Field("FILENAME").SetString fi.Name
  VLong(oBOFiles.Field("FILESIZE")).Value = fi.Length
  picfld = VPicture(oBOFiles.Field("PREVIEW"))
  preview = FileGetPreview(fi)
  
  ImageWell1.Image = preview // without this, it crashes.
  
  picfld.SetPicture(preview)
  Alias = new MacAliasMBS
  if Alias.Create(nil, fi) = 0 then
    AliasRec = Alias.GetRecord
    VVarBinary(oBOFiles.Field("ALIASREC")).Value = AliasRec
  end if
  
  oBOFiles.AddRecord
  
  return (oDB.ErrNumber=0)

Here's how I obtain that "preview" picture:

Function FileGetPreview(fi as FolderItem) As picture
   dim pic as Picture
   dim rf as ResourceFork
   dim id as integer
   dim scaler as classImageScaler
   
   if fi<>nil and fi.Exists then
      rf = fi.OpenResourceFork
      if rf<>nil then
         id = rf.ResourceID("PICT",0)
         pic = rf.GetPicture(id)
         rf.Close
      end if
      if pic = nil then
         scaler = new classImageScaler
         pic = scaler.Scale(fi.OpenAsPicture, 200, 200, 16, 0, false)
      end if
   end if
   
   return pic
End Function

Thanks,
   Frank+++

Ruslan Zasukhin wrote:
> 
> on 3/10/03 4:02 PM, Frank Bitterlich at bitterlich at gsco.de wrote:
> 
> > Hi,
> >
> > I'm having a problem with a VPicture field in an app I'm writing. To me,
> > it looks like the problems started when I upgraded from RB 4.5.2 to
> > 4.5.3. Can anybody confirm?
> >
> > Scenario: I'm putting picture file preview images into a VPicture field.
...
> 
> Hi Frank,
> 
> check V4RB example with pictures.


--
Günter Schmidt & Co. oHG         
Frank Bitterlich             eMail: bitterlich at gsco.de
Schlosserstr. 4              WWW:   http://www.gsco.de/gsco
D-60322 Frankfurt            Tel.:  069 / 156809-29
GERMANY                      Fax:   069 / 156809-28


More information about the Valentina mailing list