Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #7  
Antiguo 07-03-2012
manuc manuc is offline
Miembro
 
Registrado: abr 2010
Posts: 165
Poder: 15
manuc Va por buen camino
Ok, pues te dejo esta función que hace justo lo que quieres.

Con esta función puedes generar el thumbnail, a apartir de la ruta hasta el fichero. Hay varias formas de hacer esto, pero esta es la que mejor me ha funcionado.

Código Delphi [-]
function GetThumbnail(lpPathName, lpFileName: PWideChar; Width, Height: Integer): TBitmap;
var
 Desktop, Folder: IShellFolder;
 ItemIDList: PItemIDList;
 Flags, Priority: Cardinal;
 ExtractImage: IExtractImage;
 Res: HRESULT;
 hBitmap: Windows.HBITMAP;
 Buffer: array[0..MAX_PATH-1] of WideChar;
 Size: TSize;
begin
  Result := nil;
  SHGetDesktopFolder(Desktop);
  if LongBool(Desktop.ParseDisplayName(0, nil, lpPathName, PDWORD(0)^, ItemIDList, PDWORD(0)^)) then Exit;
  Desktop.BindToObject(ItemIDList, nil, IShellFolder, Folder);
  CoTaskMemFree(ItemIDList);
  if LongBool(Folder.ParseDisplayName(0, nil, lpFileName, PDWORD(0)^, ItemIDList, PDWORD(0)^)) then Exit;
  Folder.GetUIObjectOf(0, 1, ItemIDList, IExtractImage, nil, ExtractImage);
  CoTaskMemFree(ItemIDList);
  if not Assigned(ExtractImage) then Exit; // TODO
  Size.cx := Width; Size.cy := Height; Priority := 0;
  Flags := $28{IEIFLAG_SCREEN+IEIFLAG_OFFLINE};
  Res := ExtractImage.GetLocation(Buffer, SizeOf(Buffer), Priority, Size, 24{pf32bit}, Flags);
  if (Res = NOERROR) or (Res = E_PENDING{IEIFLAG_ASYNC}) then
  begin
    if not LongBool(ExtractImage.Extract(hBitmap)) then
    begin
     Result := TBitmap.Create;
     Result.Handle := hBitmap;
    end;
  end;
end;

¿cómo utilizarla? Por ejemplo:
Código Delphi [-]
Var
  bmp:TBitmap;
  vFichero:WideString;
  vRuta:WideString;
begin
  vRuta    := ExtractFilePath(path_fichero_pdf);
  vFichero := ExtractFilename(path_fichero_pdf);

  bmp := GetThumbnail(PWideChar(vRuta), PWideChar(vFichero), 122, 200);
  Image1.Picture.Assign(bmp);
  freeandnil(bmp)

Espero que te ayude.
Cualquier cosa, consulta sin problemas.

Un saludo.
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
SSH Telnet, algun componente? bastardo10 Varios 1 04-04-2009 14:04:39
algun componente Gantt miguel_e Gráficos 8 02-05-2008 20:51:29
Programa que realice configuraciones en mi pc zvf OOP 3 04-08-2006 00:39:54
Algun componente cesar_picazo Varios 1 25-08-2005 10:53:21
Algun componente para un GIF? andrestsas Varios 3 20-08-2003 20:36:50


La franja horaria es GMT +2. Ahora son las 18:40:19.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi