imagem em db para dbgrid, só uma duvida?

25/03/2006

0

Olá, tenho uma tabela simples com tres campos e um deles é BLOB que esta sendo gravada uma imagem BMP, esta funcionando blz, mas quero mostar esse campo em um dbgrid ai que esta a dúvida pesquisei aqui no forum e encontrei um topico que mostrava esse codigo:

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
bitmap : TBitmap;
fixRect : TRect;
bmpWidth : integer;
imgIndex : integer;
begin
fixRect := Rect;
if Column.Field = EmployeeTableBMP then
begin
Bitmap := TBitmap.Create;
try
//Pega o grafico da Tabela
Bitmap.Assign(EmployeeTable.FieldByName(´BMP´));
//Desenha
DBGrid1.Canvas.StretchDraw(fixRect, bitmap);
finally
bitmap.Free;
end;
// Limpa a saida do Retangulo
fixRect := Rect;
fixRect.Left := fixRect.Left + bmpWidth;
end;
//draw default text (fixed position)
DBGrid1.DefaultDrawColumnCell(fixRect, DataCol, Column, State);
end;
===============================================
mas quando tenho compilar da o seguinte erro:

Undeclared indentifier: ´EmployeeTableBMP´

Será que alguém pode me ajudar?

Obrigado.


Juniorprog

Juniorprog

Responder

Posts

25/03/2006

Martins

mas quando tenho compilar da o seguinte erro: Undeclared indentifier: ´EmployeeTableBMP´


A Declaração não foi identificada

[color=red:38e5bc0153][b:38e5bc0153]EmployeeTableBMP[/b:38e5bc0153][/color:38e5bc0153] provavelmente isso aqui :arrow: [color=red:38e5bc0153]if Column.Field = EmployeeTableBMP then [/color:38e5bc0153]

Não sei se vc está usando a tabela Employee, mas [b:38e5bc0153]Column.Field[/b:38e5bc0153] deve ser igual ao campo BMP de sua tabela, se vc pegou esse exemplo e não modificou para atender a sua necessidade, faça-o e depois retorne aqui no fórum.

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; 
DataCol: Integer; Column: TColumn; State: TGridDrawState); 
var 
bitmap : TBitmap; 
fixRect : TRect; 
bmpWidth : integer; 
imgIndex : integer; 
begin 
fixRect := Rect; 
// Se o campo da coluna for igual ao campo [b]blob[/b] então faça...
if Column.Field = SuaTabelaSeuCampoBlob then 
begin 
Bitmap := TBitmap.Create; 
try 
//Pega o grafico da Tabela 
Bitmap.Assign(SuaTabela.FieldByName(´SeuCampoBlob´)); 
//Desenha 
DBGrid1.Canvas.StretchDraw(fixRect, bitmap); 
finally 
bitmap.Free; 
end; 
// Limpa a saida do Retangulo 
fixRect := Rect; 
fixRect.Left := fixRect.Left + bmpWidth; 
end; 
//draw default text (fixed position) 
DBGrid1.DefaultDrawColumnCell(fixRect, DataCol, Column, State); 
end; 


Boa sorte!!


Responder

27/03/2006

Juniorprog

Obrigado esse código que vc me passou funcionou direitrinho, é por isso que adoro o clube, sempre tem pessoas empenhada e capacitada para nos ajudar pois sempre somos aprendizes.

Valeu.

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; 
DataCol: Integer; Column: TColumn; State: TGridDrawState); 
var 
bitmap : TBitmap; 
fixRect : TRect; 
bmpWidth : integer; 
imgIndex : integer; 
begin 
fixRect := Rect; 
// Se o campo da coluna for igual ao campo [b]blob[/b] então faça...
if Column.Field = SuaTabelaSeuCampoBlob then 
begin 
Bitmap := TBitmap.Create; 
try 
//Pega o grafico da Tabela 
Bitmap.Assign(SuaTabela.FieldByName(´SeuCampoBlob´)); 
//Desenha 
DBGrid1.Canvas.StretchDraw(fixRect, bitmap); 
finally 
bitmap.Free; 
end; 
// Limpa a saida do Retangulo 
fixRect := Rect; 
fixRect.Left := fixRect.Left + bmpWidth; 
end; 
//draw default text (fixed position) 
DBGrid1.DefaultDrawColumnCell(fixRect, DataCol, Column, State); 
end; 


Boa sorte!!



Responder

27/03/2006

Martins

Tranquilo, estamos aqui para isso :wink:


Responder

Assista grátis a nossa aula inaugural

Assitir aula

Saiba por que programar é uma questão de
sobrevivência e como aprender sem riscos

Assistir agora

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar