将Word嵌入Delphi中
来源:互联网 发布:淘宝数据包怎么解压啊 编辑:程序博客网 时间:2024/04/29 13:29
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls,Comobj;
type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Label1: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Panel1Resize(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
FComApp:OleVariant;
gWaveHwnd:Hwnd;
public
{ Public declarations }
procedure SetParentWindow(pParent: TWinControl);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
Word : Variant;
begin
FComApp := CreateOLEObject('Word.Application');
FComApp.Documents.Open(extractfilepath(Application.ExeName)+'/test.doc',false);
FComApp.Visible := True;
Label1.Caption := FComApp.ActiveWindow.Caption;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
SetParentWindow(Panel1);
end;
procedure TForm1.Panel1Resize(Sender: TObject);
begin
if gWaveHwnd<>0 then
begin
FComApp.ActiveWindow.Height := Panel1.Height;
FComApp.ActiveWindow.Width := Panel1.Width;
Windows.MoveWindow(gWaveHwnd,0,0,Panel1.Width,Panel1.Height,false);
end;
end;
procedure TForm1.SetParentWindow(pParent: TWinControl);
var
lWaveHwnd : Hwnd;
lWidth, lHeight: Integer;
lWindowCaption: String;
begin
//lwaveHwnd := FindWindow(nil,'Microsoft Word');//窗口标题
lWindowCaption := FComApp.ActiveWindow.Caption;
lwaveHwnd := FindWindow(nil,pAnsiChar(lWindowCaption+' - Microsoft Word'));//窗口标题
//lwaveHwnd := FindWindowW(nil,pWideChar(String(FComApp.ActiveWindow.Caption)));//窗口标题
Windows.SetWindowLong(lWaveHwnd,GWL_STYLE,GetWindowLong(lWaveHwnd, GWL_STYLE)
and not (WS_CAPTION or WS_SYSMENU));
Windows.SetParent(lWaveHwnd,pParent.Handle);
gWaveHwnd:=lWaveHwnd;
lWidth := pParent.Width;
lHeight := pParent.Height;
Windows.MoveWindow(lWaveHwnd,0,0,lWidth,lHeight,false);
//mParent := pParent;
end;
end.
- 将Word嵌入Delphi中
- 将Word嵌入Delphi中
- 将Word嵌入Delphi中
- 将MS Word 嵌入C# Winform 中
- 详解如何将MathType嵌入word中
- Delphi编写ActiveX控件及程序中嵌入word方案
- 将Word嵌入到自己的程序中
- C# 将excel表格嵌入到Word中
- C#操作Word(二)——将Word文档嵌入到WinForm窗体中
- C#操作Word(二)——将Word文档嵌入到WinForm窗体中
- 在MFC中嵌入Word
- 在DELPHI中嵌入脚本语言
- Delphi中编辑word
- delphi中关于使用CreateOleObject方法控制word的一些心得。将word放入到pannel中
- MFC在应用程序中嵌入MS Word
- 在WinForm中嵌入Word和Excel
- SWT 中嵌入Word 控件应用
- 在PB中嵌入Word文档
- Android build system note
- Delphi + Word = 数据库 + 公文处理
- SpringSide1:Java开发环境的构建
- Javascript在网页页面加载时的执行顺序
- 请教一下,大家使用VMWARE ESX多不多!
- 将Word嵌入Delphi中
- MySql报错: You can't specify target table 'table name' for update in FROM clause解决办法
- Bash Shell 快捷键
- linux socket test
- window.open
- 控制主从表的关系
- 决心
- SSIS常用的包—通用的属性
- ctags的基本使用