加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

delphi – Windows 7是否有预览处理程序VCL?

发布时间:2020-12-15 09:50:14 所属栏目:大数据 来源:网络整理
导读:本文 http://msdn.microsoft.com/en-gb/library/bb776867.aspx 将Windows中的预览处理程序描述为 Preview handlers are called when an item is selected to show a lightweight,rich,read-only preview of the file’s contents in the view’s reading pan
本文

http://msdn.microsoft.com/en-gb/library/bb776867.aspx

将Windows中的预览处理程序描述为

Preview handlers are called when an
item is selected to show a
lightweight,rich,read-only preview
of the file’s contents in the view’s
reading pane. This is done without
launching the file’s associated
application.

和……

A preview handler is a hosted
application. Hosts include the
Microsoft Windows Explorer in Windows
Vista or Microsoft Outlook 2007.

是否有一些Delphi VCL代码可以用作这种处理程序的起点?

解决方法

@Mjn,我知道我正在为我的 blog写一篇文章来实现Delphi的预处理程序,但是由于时间不够,我不知道什么时候这个完成,因为其他用户目前还没有提到VCL组件Delphi实现预览处理程序,过去我为客户实现了几个预览处理程序,但使用的是Delphi-Prism和C#.

作为起点,如果你想开始自己的项目,我在这里留下一些提示.

>您必须使用IPreviewHandler,InitializeWithFile,InitializeWithStream,IPreviewHandlerFrame,IPreviewHandlerVisuals接口.

这是这些接口的头文件的delphi转换

uses
  Windows,ActiveX,AxCtrls,ShlObj,ComObj;

type


  IIPreviewHandler = interface(IUnknown)
    ['{8895b1c6-b41f-4c1c-a562-0d564250836f}']
    function SetWindow(hwnd: HWND; var RectangleRef: TRect): HRESULT; stdcall;
    function SetRect(var RectangleRef: TRect): HRESULT; stdcall;
    function DoPreview(): HRESULT; stdcall;
    function Unload(): HRESULT; stdcall;
    function SetFocus(): HRESULT; stdcall;
    function QueryFocus(phwnd: HWND): HRESULT; stdcall;
    function TranslateAccelerator(PointerToWindowMessage: MSG): HRESULT; stdcall;
  end;

  IInitializeWithFile = interface(IUnknown)
    ['{b7d14566-0509-4cce-a71f-0a554233bd9b}']
    function Initialize(pszFilePath: LPWSTR; grfMode: DWORD):HRESULT;stdcall;
  end;

  IInitializeWithStream = interface(IUnknown)
    ['{b824b49d-22ac-4161-ac8a-9916e8fa3f7f}']
    function Initialize(pstream: IStream; grfMode: DWORD): HRESULT; stdcall;
  end;

  IIPreviewHandlerFrame = interface(IUnknown)
    ['{fec87aaf-35f9-447a-adb7-20234491401a}']
    function GetWindowContext(pinfo: HWND): HRESULT; stdcall;
    function TranslateAccelerator(PointerToWindowMessage: MSG): HRESULT; stdcall;
  end;

  IIPreviewHandlerVisuals = interface(IUnknown)
    ['{8327b13c-b63f-4b24-9b8a-d010dcc3f599}']
        function SetBackgroundColor(color: COLORREF ): HRESULT; stdcall;
        function SetFont(plf:LOGFONTW): HRESULT; stdcall;  
        function SetTextColor(color: COLORREF): HRESULT; stdcall;
  end;

>你必须创建一个com dll,其中包含一个来自这些接口的类IIPreviewHandler,IIPreviewHandlerVisuals,IOleWindow,IObjectWithSite来管理可视化,第二个类来加载要显示的文件.这个类必须来自IPreviewHandler,IInitializeWithStream.

这样的事情

TMyPreviewHandler = class(IIPreviewHandler,IObjectWithSite)

  TMyStream = class(IIPreviewHandler,IInitializeWithStream,IStream)

>现在,您必须为父接口创建自己的方法实现.
这是您需要实现的方法列表.

IPreviewHandler – > DoPreview,SetWindow,SetRect,Unload,SetFocus,TranslateAccelerator,QueryFocus.

IObjectWithSite – > GetSite,SetSite.

IOleWindow – > GetWindow

IPreviewHandlerVisuals – > SetBackgroundColor,SetFont,SetColor

InitializeWithStream – >初始化
>最后,您必须在系统中注册您的com以及将使用PrevieHandler类的文件扩展名.
>将此项目作为起点Windows Preview Handler Pack(用C#编写)和本文View Data Your Way With Our Managed Preview Handler Framework

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读