下午好:-),在我的应用程序中,我使用OleContainer查看来自Microsoft的演示文稿。
此代码用于加载和运行表示文件
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;演示文稿是作为自动播放幻灯片创建的(在微软PowerPoint working中),但在我的应用程序演示文稿中,仍然是第一幻灯片上的。运行命令是不对的?
发布于 2011-04-16 01:35:52
在应用程序中的容器中运行表示不需要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。
发布于 2011-04-15 23:34:49
Run是TOleContainer的一种方法,它不是特定于任何类型OLE对象的方法,例如电源点表示或位图图像。文档声明“调用Run以确保服务器应用程序正在运行..”。
您需要调用对象特定的方法来对它们进行操作,请参阅PowerPoint对象模型参考。样本代码:
procedure TForm1.Button1Click(Sender: TObject);
const
ppAdvanceOnTime = $00000002;
var
P: OleVariant;
S: OleVariant;
i: Integer;
begin
P := OleContainer1.OleObject.Application.Presentations.Item(1);
// below block would not be necessary for a slide show (i.e. a *.pps)
for i := 1 to P.Slides.Count do begin
P.Slides.Item(i).SlideShowTransition.AdvanceOnTime := True;
P.Slides.Item(i).SlideShowTransition.AdvanceTime := 1;
end;
S := P.SlideShowSettings;
S.AdvanceMode := ppAdvanceOnTime;
S.Run;
end;虽然上面的演示文稿将以幻灯片形式运行,但它可能不是您想要的,因为它是在全屏运行的。我不知道如何在集装箱窗口中运行它。
https://stackoverflow.com/questions/5679935
复制相似问题