SaveImage followed by LoadFromFile

Wish I could do this using streams... all help and suggestions will be appreciated!
Here is my problem. The last two lines have very "unacceptable" behaviour.
After calling "JQwPaintImg.SaveImage(gv_FN);" I expect the file will be saved before "qryPagesPageImg.LoadFromFile(gv_FN);" is called but it is not.
I have tried many different methodologies including multiple timers but without success. Is there any way I can force a flush and close of the file to disk before the load to the database record?
The file does get saved BUT only after the procedure exited/completed.
TIA
- Code: Select all
procedure TIWForm3.qryPagesBeforePost(DataSet: TDataSet);
var
lv_FN:string;
begin
if qryPages.State = dsInsert then
begin
qry1.Close;
qry1.SQL.Text := 'Select isnull(max(PageNum) + 1, 1) from Pages where BookRecID = ' + qryBooks.FieldByName('RecID').AsString;
qry1.Open;
qryPages.FieldByName('PageNum').AsInteger := qry1.Fields[0].AsInteger;
qry1.Close;
end;
if qryPages.FieldByName('PageTitle').AsString = '' then
qryPages.FieldByName('PageTitle').AsString := 'Page ' + qryPages.FieldByName('PageNum').AsString;
iwcgjqwpnt1.ExportToImage(JQwPaintImg); {iwcgjqwpnt1 is a TIWCGJQWPaint and JQwPaintImg is a TIWCGJQImage}
lv_FN := 'wwwroot/tmp/' + CGGenAutoID + '.jpg';
JQwPaintImg.SaveImage(gv_FN);
qryPagesPageImg.LoadFromFile(gv_FN);
end;
Here is my problem. The last two lines have very "unacceptable" behaviour.
After calling "JQwPaintImg.SaveImage(gv_FN);" I expect the file will be saved before "qryPagesPageImg.LoadFromFile(gv_FN);" is called but it is not.
I have tried many different methodologies including multiple timers but without success. Is there any way I can force a flush and close of the file to disk before the load to the database record?
The file does get saved BUT only after the procedure exited/completed.
TIA