gpt4 book ai didi

Delphi - OleContainer - PowerPoint - 自动播放

转载 作者:行者123 更新时间:2023-12-03 15:45:34 26 4
gpt4 key购买 nike

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

我用此代码加载和运行演示文稿文件:

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 中工作),但在我的应用程序演示文稿中,仍然位于第一张幻灯片上。运行命令不对?

最佳答案

您不需要 OleContainer 来在应用程序的容器内运行演示文稿。在表单中放置一个面板容器来运行演示文稿,然后尝试以下例程:

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 必须以点为单位提供,而不是以像素为单位。我将像素转换为点的可怜的解决方案就在这里,它在我的测试中对我有用......找到在您的环境中转换的正确方法取决于您。

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

关于Delphi - OleContainer - PowerPoint - 自动播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5679935/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com