| Ver tema anterior :: Ver tema siguiente |
| Autor |
Mensaje |
Tugui Master


Registrado: 09 Nov 2002Mensajes: 663
|
Publicado: Jue 06 Oct, 2016 7:02 pm Asunto: Traducir de Delphi |
|
|
Hola a todos a ver si alguien puede hacerme el favor de traducir este código a c++:
| Código: |
procedure TForm1.FormCreate(Sender: TObject);
begin
with TStringGrid(DBGrid1) do
begin
DefaultRowHeight := 60; // alto de filas a gusto
RowHeights[0] := 25; // alto de título
end;
DBGrid1.Options := DBGrid1.Options - [dgColumnResize]; // columnas fijas
end;
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if ( Column.FieldName = 'GRAPHIC' ) then
with TPicture.Create do
try
Assign( Column.Field );
DBGrid1.Canvas.StretchDraw( Rect, BitMap );
finally
Free;
end;
end;
|
El propósito es mostrar imágenes en un DBGrid.
Gracias. _________________ ¡ADELANTE CON ESTE SUPER FORO! |
|
| Volver arriba |
|
 |
_Leo Site Admin

Registrado: 11 Ago 2002Mensajes: 1875Ubicación: Lanzarote - Islas Canarias (España)
|
Publicado: Jue 06 Oct, 2016 9:34 pm Asunto: |
|
|
Hola, en el constructor del Form:
| Código: | reinterpret_cast<TStringGrid*>(DBGrid1)->DefaultRowHeight = 60;
reinterpret_cast<TStringGrid*>(DBGrid1)->RowHeights[0] = 25;
DBGrid1->Options = TDBGridOptions(DBGrid1->Options) >> dgColumnResize; |
En el evento OnDrawColumnCell del TDBGrid:
| Código: | if (Column->FieldName == "GRAPHIC")
{
TPicture* pict = new TPicture;
try {
pict->Assign(Column->Field);
DBGrid1->Canvas->StretchDraw(Rect, pict->Bitmap);
}
__finally {
delete pict;
}
} |
|
|
| Volver arriba |
|
 |
Tugui Master


Registrado: 09 Nov 2002Mensajes: 663
|
Publicado: Jue 06 Oct, 2016 10:33 pm Asunto: |
|
|
Gracias Leo pero no me muestra la imagen, algo estoy haciendo mal. _________________ ¡ADELANTE CON ESTE SUPER FORO! |
|
| Volver arriba |
|
 |
_Leo Site Admin

Registrado: 11 Ago 2002Mensajes: 1875Ubicación: Lanzarote - Islas Canarias (España)
|
Publicado: Vie 07 Oct, 2016 12:43 am Asunto: |
|
|
| Tugui escribió: | | Gracias Leo pero no me muestra la imagen, algo estoy haciendo mal. |
¿Has puesto el nombre del campo gráfico sustituyendo a "GRAPHIC"?
¿Te da algún error? |
|
| Volver arriba |
|
 |
Tugui Master


Registrado: 09 Nov 2002Mensajes: 663
|
Publicado: Vie 07 Oct, 2016 9:41 am Asunto: |
|
|
Ahora si, muchisimas gracias eres un fenómeno, no cambies  _________________ ¡ADELANTE CON ESTE SUPER FORO! |
|
| Volver arriba |
|
 |
|