Delphi - OleContainer - PowerPoint - 自动播放 [英] Delphi - OleContainer - PowerPoint - AutoPlay

查看:75
本文介绍了Delphi - OleContainer - PowerPoint - 自动播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下午好 :-),在我的应用程序中,我使用 OleContainer 查看来自 Microsoft Powerpoint 的演示文稿.

Good afternoon :-), in my application I use OleContainer to view presentation from Microsoft Powerpoint.

我用来加载和运行演示文件的这段代码:

This code I use to load and run presentation file:

with oleContainer do begin
    Parent := mediaPanel; Left := 0; Top := 0;
    Width := mediaPanel.Width; Height := mediaPanel.Height;
    CreateObjectFromFile('C:\Users\Nanik\Desktop\Present.ppt', false);
    Iconic := false; Visible := true; Run;
 end;

<小时>

演示文稿创建为自动播放幻灯片(在 Microsoft PowerPoint 中工作),但在我的应用程序中,演示文稿仍然位于第一张幻灯片.运行命令不对?


The presentation was created as autoplay slideshow (in Microsoft PowerPoint working), but in my application presentation was still on first slide. Run command isn't right?

推荐答案

您不需要 OleContainer 即可在应用程序的容器内运行演示文稿.放置一个面板容器以在您的表单中运行演示文稿并尝试此例程:

You do not need a OleContainer to run the presentation inside a container in your application. Put a panel container to run the presentation in your form and try this routine:

procedure TForm2.Button3Click(Sender: TObject);
const
  ppShowTypeSpeaker = 1;
  ppShowTypeInWindow = 1000;
  SHOW_FILE = 'C:\Users\jcastillo\Documents\test.pps';
var
  oPPTApp: OleVariant;
  oPPTPres: OleVariant;

  screenClasshWnd: HWND;
  pWidth, pHeight: Integer;

  function PixelsToPoints(Val: Integer; Vert: Boolean): Integer;
  begin
    if Vert then
      Result := Trunc(Val * 0.75)
    else
      Result := Trunc(Val * 0.75);
  end;

begin
  oPPTApp := CreateOleObject('PowerPoint.Application');
  oPPTPres := oPPTApp.Presentations.Open(SHOW_FILE, True, True, False);
  pWidth := PixelsToPoints(Panel1.Width, False);
  pHeight := PixelsToPoints(Panel1.Height, True);
  oPPTPres.SlideShowSettings.ShowType := ppShowTypeSpeaker;
  oPPTPres.SlideShowSettings.Run.Width := pWidth;
  oPPTPres.SlideShowSettings.Run.Height := pHeight;
  screenClasshWnd := FindWindow('screenClass', nil);
  Windows.SetParent(screenClasshWnd, Panel1.Handle);
end;

我手头没有文档,但我的想法是 Run.Width 和 Run.Height 必须以点为单位提供,而不是以像素为单位.我将像素转换为点的可怜人解决方案在这里,它在我的测试中对我有用......找到在您的环境中转换的正确方法取决于您.

I do not have documentation at hand, but my thought is Run.Width and Run.Height must be provided in points, not in pixels. My poor man solution to convert pixels to points is here, and it works for me in my tests here... to find the correct way to convert in your environment is up to you.

假设您可以从 oPPTPres.SlideShowSettings.Run.HWND 属性获得演示窗口的句柄,但这对我来说不起作用,因此调用 FindWindow.

Is supposed you can get the Handle of the presentation window from the oPPTPres.SlideShowSettings.Run.HWND property, but that does not work here for me, hence the FindWindow call.

这篇关于Delphi - OleContainer - PowerPoint - 自动播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆