第一我第二这两个问题我已经解决了!!我修改了代码如:procedure TForm1.ToolButton4Click(Sender: TObject);
var
h:HWnd;
s:String;
begin
//P := GetActiveOleObject('PowerPoint.Application')
P := createoleobject('Powerpoint.Application'); P.visible := true;
s := P.caption;
h := FindWindow(nil,Pchar(s));
p.width := width-width*0.254;
p.height:= height;
P.left := 0;
p.top := 0;
//p.height:= 500;
windows.SetParent(h,Panel1.Handle);
//windows.SetWindowPos(h,self.Handle,0,0,width,height,SWP_SHOWWINDOW);
P.Presentations.Open('F:\Delphi\社区卫生\文档\罗毅\PPT模板.ppt',msoFalse, msoFalse, msoTrue);
//p.WindowState := wsMinimized;
// Presentations.Run('SHOW.TOOLBAR("Ribbon",False)'); // 报错
end;我把pp,p:variant;设置为了类全局变量,我在窗口Colse事件中把P.quit就好了。
第三个问题还是无解!!
var
h:HWnd;
s:String;
begin
//P := GetActiveOleObject('PowerPoint.Application')
P := createoleobject('Powerpoint.Application'); P.visible := true;
s := P.caption;
h := FindWindow(nil,Pchar(s));
p.width := width-width*0.254;
p.height:= height;
P.left := 0;
p.top := 0;
//p.height:= 500;
windows.SetParent(h,Panel1.Handle);
//windows.SetWindowPos(h,self.Handle,0,0,width,height,SWP_SHOWWINDOW);
P.Presentations.Open('F:\Delphi\社区卫生\文档\罗毅\PPT模板.ppt',msoFalse, msoFalse, msoTrue);
//p.WindowState := wsMinimized;
// Presentations.Run('SHOW.TOOLBAR("Ribbon",False)'); // 报错
end;我把pp,p:variant;设置为了类全局变量,我在窗口Colse事件中把P.quit就好了。
第三个问题还是无解!!
解决方案 »
- 发布了个通信用的软件,有亮点(SQLite导出Excel以秒计),欢迎捧场。
- 有个小问题 有句程序不理解什么意思 大家帮忙看看
- ADOConnection1的难题,请教高手指点谜经?在线等待~~~~~~~
- 開啟子窗口的疑問
- 各位哥们,谁有管理系统的图标,或知道下载地址?告诉ME一下!!做ERP的!!
- 高分求delphi 6.0(个人版)的下载地址(高速)!!!
- --------------什么是RPC占位程序版本不兼容---
- 谁来讲讲Web Server Application中三个选项ISAPI,CGI,WIN CGI三者的区别!
- 如何在一次插入多条记录
- 各位高手,大虾请回答!共享delphi类库!
- delphi对xml操作
- TIdSMTP发送邮件问题
unit Main; interface uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, OleServer, DBCtrls, ExtCtrls, Grids, DBGrids, Db,
DBTables, Msppt8, ComCtrls, ToolWin; type
TfrmMain = class(TForm)
PowerPointApplication1: TPowerPointApplication;
PowerPointSlide1: TPowerPointSlide;
PowerPointPresentation1: TPowerPointPresentation;
Table1: TTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
DBImage1: TDBImage;
ToolBar1: TToolBar;
btnPreview: TToolButton;
btnAddPre: TToolButton;
btnClose: TToolButton;
btnRun: TToolButton;
TV1: TTreeView;
Label1: TLabel;
btnOutPutData: TToolButton;
procedure Form1Activate(Sender: TObject);
procedure Form1Close(Sender: TObject; var Action: TCloseAction);
procedure btnPreviewClick(Sender: TObject);
procedure btnAddPreClick(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
procedure btnRunClick(Sender: TObject);
procedure btnOutPutDataClick(Sender: TObject);
private
SWindow:SlideShowWindow;
TN:TTreeNode;
{ Private declarations }
public
{ Public declarations }
end; var
frmMain: TfrmMain; implementation {$R *.dfm} procedure TfrmMain.Form1Activate(Sender: TObject);
begin
Table1.Open;
TN := nil;
end; procedure TfrmMain.Form1Close(Sender: TObject; var Action: TCloseAction);
begin
Table1.Close;
end; procedure TfrmMain.btnPreviewClick(Sender: TObject);
var
i: Integer;
Found: Boolean; begin
Found := False;
if (PowerPointApplication1.Presentations.Count > 0) and (TN <> nil) then
begin
for i := 1 to PowerPointApplication1.Presentations.Count do
begin
TN := TV1.Selected;
{Get Parent node to find Presentation name in case a slide is selected}
if TN.GetPrev <> nil then
TN := TN.Parent; if PowerPointApplication1.Presentations.Item(i).Name = TN.Text then
begin
Found := True;
Break;
end;
end;
if Found then
begin
PowerPointPresentation1.ConnectTo(PowerPointApplication1.Presentations.Item(i));
with PowerPointPresentation1 do
begin
SlideShowSettings.AdvanceMode := ppSlideShowUseSlideTimings;
// SlideShowSettings.LoopUntilStopped := msoTrue;
SWindow := SlideShowSettings.Run;
frmMain.SetFocus;
end;
end
else
ShowMessage('没有发现演示文稿 ' + TN.Text);
end
else
Showmessage('没有可用的演示文稿');
end; procedure TfrmMain.btnAddPreClick(Sender: TObject);
begin
try
btnOutPutData.Enabled := True;
PowerPointPresentation1.ConnectTo(PowerPointApplication1.Presentations.Add(1));
TN := TV1.Items.Insert(TN, PowerPointPresentation1.Name);
TN.Selected := True;
TV1.SetFocus;
except
on E: Exception do
begin
Showmessage(E.Message);
end;
end;
end;
procedure TfrmMain.btnCloseClick(Sender: TObject);
begin
PowerPointApplication1.Quit;
PowerPointApplication1.Disconnect;
end; procedure TfrmMain.btnRunClick(Sender: TObject);
begin
try
try
PowerPointApplication1.Connect;
except on E: Exception do
begin
E.Message := '没有安装PowerPoint';
raise;
end;
end;
PowerPointApplication1.Visible := 1;
btnAddPre.Enabled := True;
btnClose.Enabled := True;
frmMain.SetFocus;
except
on E: Exception do
begin
Showmessage(E.Message);
PowerPointApplication1.Disconnect;
end;
end;
end; procedure TfrmMain.btnOutPutDataClick(Sender: TObject);
begin
PowerPointSlide1.ConnectTo(PowerPointPresentation1.Slides.Add(PowerPointPresentation1.Slides.Count + 1, 1)); with PowerPointSlide1 do
begin
btnPreview.Enabled := True;
{Select layout where a bitmap is in the left corner}
Layout := 10;
{Set background}
FollowMasterBackground := 0;
Background.Fill.PresetGradient(2, 2, 10);
{Set text}
Shapes.Item(1).TextFrame.TextRange.InsertAfter(Table1.Fieldbyname('Common_Name').AsString);
Shapes.Item(2).TextFrame.TextRange.Font.Name := 'Arial';
Shapes.Item(2).TextFrame.TextRange.InsertAfter('种类 : ' + Table1.FieldByName('Category').AsString + #13 +
'名字: ' + Table1.FieldByName('Species Name').AsString);
{加入图像}
DbImage1.CopyToClipboard;
Shapes.Item(3).Delete;
Shapes.Paste;
Shapes.Item(3).Left := 100;
Shapes.Item(3).Top := 180;
Shapes.Item(3).Width := 150;
Shapes.Item(3).Height := 150;
{Set time displayed for each slide}
SlideShowTransition.AdvanceOnTime := 1;
SlideShowTransition.AdvanceTime := 2;
Name := Table1.FieldByName('Common_Name').AsString + (IntToStr(PowerPointPresentation1.Slides.Count));
TV1.Items.AddChild(TN, Name);
TN.Selected;
TV1.SetFocus;
end;
end; end.