whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1548)

Database (90)
Files (137)
Forms (107)
Graphic (116)
IDE (21)
Indy (5)
Internet / LAN (131)
IntraWeb (0)
Math (76)
Misc (127)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (268)
VCL (243)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

27 Visitors Online


 
...save a Formula One spreadsheet to a blob field?
Autor: Brett McLean
[ Print tip ]  

Tip Rating (4):  
     


uses vcf1, dbtables;


procedure SaveSpreadsheet(F1Book: TF1Book);
var
  
BlobStream: TBlobStream;
  MyBlob: HGlobal;
  pblob: Pointer;
begin
  with 
Datamodule1.Query1 do
  begin
    
Set8087CW($133f);
    try
      
Application.ProcessMessages;
      F1Book.SaveWindowInfo;
      MyBlob := GlobalAlloc(GMEM_MOVEABLE, 2000);
      try
        
F1Book.WriteToBlob(MyBlob, 0);
        pBlob := globalLock(MyBlob);
        try
          
Blobstream := TBlobStream.Create(TBlobField(FieldByName('QUOTE_BLOB')),
            bmWrite);
          try
            
Blobstream.Write(pBlob^, GlobalSize(myBlob));
          finally
            
Blobstream.Free;
          end;
        finally
          
globalUnlock(MyBlob);
        end;
        F1book.IF1Book_Modified := False;
      finally
        
globalFree(myblob);
      end;
    finally
      
Set8087CW(Default8087CW);
      Application.ProcessMessages;
    end;
  end;
end;

//Depending on your Delphi Version (<D4), you will need:
//D4 und frühere Versionen brauchen noch:

var
  
Default8087CW: Word = $1332;

procedure Set8087CW(NewCW: Word);
asm
  
MOV     Default8087CW,AX
  FLDCW   Default8087CW
end;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners