Nan*_*nik 3 delphi powerpoint autoplay
下午好:-),在我的应用程序中,我使用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;
Run Code Online (Sandbox Code Playgroud)
该演示文稿已创建为自动播放幻灯片(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 Code Online (Sandbox Code Playgroud)
我手头没有文档,但我的想法是 Run.Width 和 Run.Height 必须以点为单位提供,而不是以像素为单位。我将像素转换为点的可怜人解决方案在这里,它在我的测试中对我有用……找到在您的环境中转换的正确方法取决于您。
假设您可以从oPPTPres.SlideShowSettings.Run.HWND属性中获取演示窗口的句柄,但这对我来说不起作用,因此调用 FindWindow。
| 归档时间: |
|
| 查看次数: |
7584 次 |
| 最近记录: |