Previewing Documents In A Managed Application

  • Thread starter Thread starter Tim Haughton
  • Start date Start date
T

Tim Haughton

Hi, I'm trying to implement a preview feature in a managed application to
preview files of arbitrary type. Has anyone done this in a managed app? I've
seen at least one suggestion that you can host prevhost on your form, but
I'm not sure this is correct.

I've seen the IPreviewHandler and IPreviewHandlerFrame interfaces, but
haven't managed to use them from C#. They both live in shobjidl.idl, but
when I create the type library using midl.exe, the key interfaces are
missing.

Can anyone offer any assistance?

Tim
 
Tim said:
Hi, I'm trying to implement a preview feature in a managed
application to preview files of arbitrary type. Has anyone done this
in a managed app? I've seen at least one suggestion that you can host
prevhost on your form, but I'm not sure this is correct.

I suppose you could, but I think it would be rather hard work. Also, preview handlers are new for Vista so it wouldn't be much use on previous versions. If you just want a pictorial representation of a file, you could show a thumbnail. On Vista, IShellItemImageFactory::GetImage makes this very easy. On older Windows versions, you can fall back to GetUIObjectOf/IExtractImage.
 
Tim,

Why not just declare the interfaces in C# code manually? They are not
that big, and the types are not so complex that it would be very difficult.
 
Thanks Jim, we already have the IShellItemImage factory stuff in their, but
it's kind of a document management application, so we need the preview stuff
as well - and it's a Vista only app.


Cheers,

Tim

Tim said:
Hi, I'm trying to implement a preview feature in a managed
application to preview files of arbitrary type. Has anyone done this
in a managed app? I've seen at least one suggestion that you can host
prevhost on your form, but I'm not sure this is correct.

I suppose you could, but I think it would be rather hard work. Also, preview
handlers are new for Vista so it wouldn't be much use on previous versions.
If you just want a pictorial representation of a file, you could show a
thumbnail. On Vista, IShellItemImageFactory::GetImage makes this very easy.
On older Windows versions, you can fall back to GetUIObjectOf/IExtractImage.
 
Thanks Nicholas, I'm heading that way, so I'll give it a look.

Tim


Nicholas Paldino said:
Tim,

Why not just declare the interfaces in C# code manually? They are not
that big, and the types are not so complex that it would be very
difficult.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Tim Haughton said:
Hi, I'm trying to implement a preview feature in a managed application to
preview files of arbitrary type. Has anyone done this in a managed app?
I've
seen at least one suggestion that you can host prevhost on your form, but
I'm not sure this is correct.

I've seen the IPreviewHandler and IPreviewHandlerFrame interfaces, but
haven't managed to use them from C#. They both live in shobjidl.idl, but
when I create the type library using midl.exe, the key interfaces are
missing.

Can anyone offer any assistance?

Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top