You do not need an OleContainer to run a presentation inside a container in your application. Place the panel container to launch the presentation in your form and try this procedure:
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;
I don't have the documentation at hand, but I thought that Run.Width and Run.Height should be provided in points, not pixels. My poor solution for converting pixels to points here, and it works for me in my tests here ... to find the right way to convert to your environment, is up to you.
It is assumed that you can get the Presentation Window Handle from the oPPTPres.SlideShowSettings.Run.HWND
property, but this does not work for me, therefore, the call to FindWindow.
source share