Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Inserting Pictures into Farpoint/GrapeCity Spread Control



Permlink Replies: 1 - Last Post: Dec 21, 2017 6:34 AM Last Post By: Ian Kirk Threads: [ Previous | Next ]
Ian Kirk

Posts: 12
Registered: 10/24/01
Inserting Pictures into Farpoint/GrapeCity Spread Control
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 20, 2017 2:34 AM
I'm attempting to insert a file-based JPG picture into a GrapeCity (was Farpoint) Spread control, using code of this form:

var
  aLoadedPic: TPicture ;
begin
  fpSpread.AddCellSpan(1, 1, 5, 5) ;
  fpSpread.BlockMode := True ;
  fpSpread.Col := 1 ;
  fpSpread.Row := 1 ;
  fpSpread.Col2 := 5 ;
  fpSpread.Row2 := 5 ;
  fpSpread.CellType := CellTypePicture ;
  fpSpread.TypePictMaintainScale := True ;
  fpSpread.TypePictCenter        := True ;
 
  aLoadedPic := TPicture.Create ;
  aLoadedPic.LoadFromFile('D:\Test.jpg') ;
 
  fpSpread.TypePictPicture := aLoadedPic ;
  aLoadedPic.Free ;


It's a rather old (v8) ActiveX version of the control, accessed via a TOleControl-based wrapper generated via the Delphi IDE.

All other aspects of driving the Spread control work, aside from this attempt to insert the picture (which doesn't generate any errors - it just fails silently). Removing the block mode-related lines makes no difference.

FWIW inserting a picture via the spread designer does work, so it seems there's some route to getting one in there (unfortunately there's no route I can see for obtaining script-type lines corresponding to the designer operations).

If anyone has any suggestions for how this can be done - or, ideally, fragments of working code they can share - that would be greatly appreciated!

TIA for all responses,
Ian
Ian Kirk

Posts: 12
Registered: 10/24/01
Re: Inserting Pictures into Farpoint/GrapeCity Spread Control
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 21, 2017 6:34 AM   in response to: Ian Kirk in response to: Ian Kirk
An update on this, in case anyone else runs into this problem - after a lot of experimentation a workable solution's been found; it seems that the Spread control will only display images that are help in bitmap format within the TPicture (and silently fails on any other type).

So, code of this form will display the image:

var
  aLoadedPic, aBMPPic: TPicture ;
begin
  fpSpread.AddCellSpan(1, 1, 5, 5) ;
  fpSpread.BlockMode := True ;
  fpSpread.Col := 1 ;
  fpSpread.Row := 1 ;
  fpSpread.Col2 := 5 ;
  fpSpread.Row2 := 5 ;
  fpSpread.CellType := CellTypePicture ;
  fpSpread.TypePictStretch := True ;
  fpSpread.TypePictMaintainScale := True ;
  fpSpread.TypePictCenter        := True ;
 
  aLoadedPic := TPicture.Create ;
  aLoadedPic.LoadFromFile('D:\Test.jpg') ;
 
  aBMPPic := TPicture.Create ;
  aBMPPic.Bitmap.Width  := aLoadedPic.Width  ;
  aBMPPic.Bitmap.Height := aLoadedPic.Height ;
  aBMPPic.Bitmap.Canvas.Draw(0, 0, aLoadedPic.Graphic) ;
 
  fpSpread.TypePictPicture := aBMPPic ;
  aLoadedPic.Free ;
  aBMPPic.Free ;


Ian Kirk wrote:
I'm attempting to insert a file-based JPG picture into a GrapeCity (was Farpoint) Spread control, using code of this form:

var
  aLoadedPic: TPicture ;
begin
  fpSpread.AddCellSpan(1, 1, 5, 5) ;
  fpSpread.BlockMode := True ;
  fpSpread.Col := 1 ;
  fpSpread.Row := 1 ;
  fpSpread.Col2 := 5 ;
  fpSpread.Row2 := 5 ;
  fpSpread.CellType := CellTypePicture ;
  fpSpread.TypePictMaintainScale := True ;
  fpSpread.TypePictCenter        := True ;
 
  aLoadedPic := TPicture.Create ;
  aLoadedPic.LoadFromFile('D:\Test.jpg') ;
 
  fpSpread.TypePictPicture := aLoadedPic ;
  aLoadedPic.Free ;


It's a rather old (v8) ActiveX version of the control, accessed via a TOleControl-based wrapper generated via the Delphi IDE.

All other aspects of driving the Spread control work, aside from this attempt to insert the picture (which doesn't generate any errors - it just fails silently). Removing the block mode-related lines makes no difference.

FWIW inserting a picture via the spread designer does work, so it seems there's some route to getting one in there (unfortunately there's no route I can see for obtaining script-type lines corresponding to the designer operations).

If anyone has any suggestions for how this can be done - or, ideally, fragments of working code they can share - that would be greatly appreciated!

TIA for all responses,
Ian
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02