I do have a DrawColumnCell proc and a OnClick event.
~**DrawColumncell**~
procedure TBrowsePolicies.TransactionsGridDrawColumnCell(Sender: TObject;const Rect: TRect;
DataCol: Integer; Column: TColumnEh;State: TGridDrawState);
var
bitmap : TBitMap;
fixrect : TRect;
bmpHeight, bmpLeft : integer;
Imgindex : integer;
begin
inherited;
fixrect := Rect;
{$IFNDEF NCGMRate}
if Column.FieldName = 'AIMAGE' then
begin
TransactionsGrid.Canvas.Brush.Color := clWindow;
TransactionsGrid.Canvas.FillRect(Rect);
if not Datamodule.History.FieldByname('AIMAGE').IsNull then
begin
imgIndex := 0;
bitmap := TBitMap.Create;
try
THImageList.GetBitMap(ImgIndex,Bitmap);
bmpHeight := (Rect.Bottom - Rect.Top);
FixRect.Right := Rect.Left + bmpHeight;
TransactionsGrid.Canvas.StretchDraw(FixRect,Bitmap);
finally
BitMap.Free;
end;
end;
end;
if Column.FieldName = 'BIMAGE' then
begin
TransactionsGrid.Canvas.Brush.Color := clWindow;
TransactionsGrid.Canvas.FillRect(Rect);
if not Datamodule.History.FieldByname('BIMAGE').IsNull then
begin
imgIndex := 1;
bitmap := TBitMap.Create;
try
THImageList.GetBitMap(ImgIndex,Bitmap);
bmpHeight := (Rect.Bottom - Rect.Top);
FixRect.Right := Rect.Left + bmpHeight;
TransactionsGrid.Canvas.StretchDraw(FixRect,Bitmap);
finally
BitMap.Free;
end;
end;
end;
if Column.FieldName = 'CIMAGE' then
begin
TransactionsGrid.Canvas.Brush.Color := clWindow;
TransactionsGrid.Canvas.FillRect(Rect);
if not Datamodule.History.FieldByname('CIMAGE').IsNull then
begin
imgIndex := 2;
bitmap := TBitMap.Create;
try
THImageList.GetBitMap(ImgIndex,Bitmap);
bmpHeight := (Rect.Bottom - Rect.Top);
FixRect.Right := Rect.Left + bmpHeight;
TransactionsGrid.Canvas.StretchDraw(FixRect,Bitmap);
finally
BitMap.Free;
end;
end;
end;
{$ELSE}
if Column.FieldName = 'DIMAGE' then
begin
TransactionsGrid.Canvas.Brush.Color := clWindow;
TransactionsGrid.Canvas.FillRect(Rect);
if not Datamodule.History.FieldByname('DIMAGE').IsNull then
begin
imgIndex := 3;
bitmap := TBitMap.Create;
try
THImageList.GetBitMap(ImgIndex,Bitmap);
bmpHeight := (Rect.Bottom - Rect.Top);
FixRect.Right := Rect.Left + bmpHeight;
TransactionsGrid.Canvas.StretchDraw(FixRect,Bitmap);
finally
BitMap.Free;
end;
end;
end;
___________________________________________________________
~**GridCellClick**~
procedure TBrowsePolicies.TransactionsGridCellClick(Column: TColumnEh);
var
BStream : TStream;
FStream : TFileStream;
QRPDevice : TQRPHandler;
begin
inherited;
{$IFNDEF NCGMRate}
if (Upper(TransactionsGrid.SelectedField.DisplayLabel) = 'AIMAGE') and
(not Datamodule.History.FieldByname('AIMAGE').IsNull) then
begin
BStream := Datamodule.History.CreateBlobStream(Datamodule.History.FieldByName(AIMAGE'),bmRead);
try
BStream.Seek(0, soFromBeginning);
with TFileStream.Create(ExtractFilePath(Application.ExeName)+'APAGE.PDF',fmCreate) do
try
CopyFrom(BStream, BStream.Size);
finally
Free
end;
finally
BStream.Free;
end;
PDFFileViewer := TPDFFileViewer.Create(Application);
PDFFileViewer.PDFFile.LoadFile(ExtractFilePath(Application.ExeName)+'APAGE.PDF');
PDFFileViewer.ShowModal;
PDFFileViewer.PDFFile.Destroy;
// TransactionsGrid.Refresh;
//IntToStr(transactionsGrid.Col - 4);
// TranHistTab.
end
else
If (Upper(TransactionsGrid.SelectedField.DisplayLabel) = AIMAGE') and
Datamodule.History.FieldByname(AIMAGE').IsNull then
raise Exception.Create('No Dec Page to display.');
if (Upper(TransactionsGrid.SelectedField.DisplayLabel) = 'BIMAGE') and
(not Datamodule.History.FieldByname('BIMAGE').IsNull) then
begin
BStream := Datamodule.History.CreateBlobStream(Datamodule.History.FieldByName('BIMAGE'),bmRead);
try
BStream.Seek(0, soFromBeginning);
with TFileStream.Create(ExtractFilePath(Application.ExeName)+'BPAGE.PDF',fmCreate) do
try
CopyFrom(BStream, BStream.Size);
finally
Free
end;
finally
BStream.Free;
end;
PDFFileViewer := TPDFFileViewer.Create(Application);
PDFFileViewer.PDFFile.LoadFile(ExtractFilePath(Application.ExeName)+'BPAGE.PDF');
PDFFileViewer.ShowModal;
PDFFileViewer.PDFFile.Destroy;
TransactionsGrid.Refresh;
end
else
If (Upper(TransactionsGrid.SelectedField.DisplayLabel) = 'BIMAGE') and Datamodule.History.FieldByname('BIMAGE').IsNull then
raise Exception.Create('No Billing Notice to display.');
if (Upper(TransactionsGrid.SelectedField.DisplayLabel) = 'CIMAGE') and
(not Datamodule.History.FieldByname('CIMAGE').IsNull) then
begin
BStream := Datamodule.History.CreateBlobStream(Datamodule.History.FieldByName('CIMAGE'),bmRead);
try
BStream.Seek(0, soFromBeginning);
with TFileStream.Create(ExtractFilePath(Application.ExeName)+'CPAGE.PDF',fmCreate) do
try
CopyFrom(BStream, BStream.Size);
finally
Free
end;
finally
BStream.Free;
end;
PDFFileViewer := TPDFFileViewer.Create(Application);
PDFFileViewer.PDFFile.LoadFile(ExtractFilePath(Application.ExeName)+'CPAGE.PDF');
PDFFileViewer.ShowModal;
PDFFileViewer.PDFFile.Destroy;
TransactionsGrid.Refresh;
end
else
If (Upper(TransactionsGrid.SelectedField.DisplayLabel) = 'CIMAGE') and Datamodule.History.FieldByname('CIMAGE').IsNull then
raise Exception.Create('No Notice to display.');
{$ELSE}
if (Upper(TransactionsGrid.SelectedField.DisplayLabel) = 'DIMAGE') and
(not Datamodule.History.FieldByname('DIMAGE').IsNull) then
begin
BStream := Datamodule.History.CreateBlobStream(Datamodule.History.FieldByName('DIMAGE'),bmRead);
try
BStream.Seek(0, soFromBeginning);
with TFileStream.Create(ExtractFilePath(Application.ExeName)+'DPAGE.PDF',fmCreate) do
try
CopyFrom(BStream, BStream.Size);
finally
Free
end;
finally
BStream.Free;
end;
PDFFileViewer := TPDFFileViewer.Create(Application);
PDFFileViewer.PDFFile.LoadFile(ExtractFilePath(Application.ExeName)+'DPAGE.PDF');
PDFFileViewer.ShowModal;
PDFFileViewer.PDFFile.Destroy;
TransactionsGrid.Refresh;
end
end;
Thanks