test002 |
|
conundrum
尊榮會員 發表:893 回覆:1272 積分:643 註冊:2004-01-06 發送簡訊給我 |
unit PLWORD;
{$A ,B-,C ,D ,E-,F-,G ,H ,I ,J ,K-,L ,M-,N ,O ,P ,Q-,R-,S-,T-,U-,V ,W-,X ,Y ,Z1}
{$WARNINGS OFF}
//===================================================================
// ???操作???? Ver. 5.9
// 開?環境 Word2000,Word2002
// (Word97,98??開??????.?????)
//
// Ver 4.0?????文書表示?TWebBrowser?行?方式??更????.
// ??????,使用??Form?一????,?????更?自由???
// ???.??,概??拙作?印刷??????似????.??結果,?
// ?????????非常?????????.??一方?IE5(SP1)
// 以上?????????????PC????正常動作???????
// ?????.
//
// ?二重起動
// ???????????.各自?????下??.
// 二重起動???,起動??From??????終了???,??以降,表示
// 中????????操作?????????.??終了時??????
// 生???.
//
// ?印刷??????
// ???????利用?考??,印刷??????Delphi?TPrintDialog
// ?使用?????.??印刷????????????設定???容?,
// 印刷?反映??????[?????]????無????????.
// ????用?印刷??????使用?????????設定?可能?
// ????.
//
// ?Form???????
// 今見???plWord.pas????操作???????????????.
// ??Form???????登???,登???Form??承??利用???
// 便利??.
// ??????表示中?[F12]?表示??Form??更???,?承??
// Form?自動的??更????.
//
// ?使用方法
// 添付???????????????考???下??.
// ????????????????他????????????修正
// ??利用??手?????.
//
//
// 2002.12.22~ Mr.XRAY
//==================================================================
interface uses
{$IFDEF VER130}
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ExtCtrls, Menus, RegMng,Printers,SHDocVw,OleCtrls,
plFileDialog, OleServer, Office2000,Word2000, ToolWin,ActiveX,
Clipbrd,Math, ComCtrls,SndKey32, AppEvnts;
{$ELSE}
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ExtCtrls, Menus, RegMng,Variants,Printers,OleCtrls,
Word2000, Office2000,plFileDialog,OleServer,Clipbrd,Math,ComCtrls,
SHDocVw,SndKey32;
{$ENDIF} type {2003.4.1 WordShape?WordRange追加}
{Office2000??Shape?????????互換性?????明示的?定義}
WordShape = Word2000.Shape;
WordRange = Range; TplWordForm = class(TForm)
LeftPanel: TPanel;
IconBar: TToolBar;
PrintBtn: TSpeedButton;
PageSetBtn: TSpeedButton;
Space10: TSpeedButton;
FileOpenBtn: TSpeedButton;
SaveBtn: TSpeedButton;
Space20: TSpeedButton;
ZoomDownBtn: TSpeedButton;
ZoomUpBtn: TSpeedButton;
PageWholeBtn: TSpeedButton;
PageWidthBtn: TSpeedButton;
Space30: TSpeedButton;
CloseBtn: TSpeedButton;
PanelRight: TPanel;
RegManager1: TRegManager;
plBrowseFolder1: TplBrowseFolder;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
PopupMenu2: TPopupMenu;
N2: TMenuItem;
plSaveDialog1: TplSaveDialog;
plOpenDialog1: TplOpenDialog;
OpenDialog1: TOpenDialog;
PrintDialog1: TPrintDialog;
OverWriteBtn: TSpeedButton;
NewFileBtn: TSpeedButton;
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure PageSetBtnClick(Sender: TObject);
procedure PrintBtnClick(Sender: TObject);
procedure ZoomUpBtnClick(Sender: TObject);
procedure PageWholeBtnClick(Sender: TObject);
procedure PageWidthBtnClick(Sender: TObject);
procedure CloseBtnClick(Sender: TObject);
procedure DefaultFileSelectClick(Sender: TObject);
procedure SaveFolderSelectClick(Sender: TObject);
procedure ZoomDownBtnClick(Sender: TObject);
procedure FileOpenBtnClick(Sender: TObject);
procedure SaveBtnClick(Sender: TObject);
procedure PrintDialog1Show(Sender: TObject);
procedure PrintDialog1Close(Sender: TObject);
procedure OverWriteBtnClick(Sender: TObject);
procedure NewFileBtnClick(Sender: TObject);
private
FWebBrowser : TWebBrowser;
FWordApp : TWordApplication;
FWordDoc : TWordDocument;
FFileExt : String; {文書??張子(Ver5.7?追加}
FWordDispSize : OleVariant; {????表示???}
FWordVersion : String; {?????????文字列}
FWordVersionNo : Integer; {?????????整?部???}
FDefaultFilePath : String; {起動時??出?文書名}
FSaveFolderPath : String; {作成??文書?保存先????最後尾\付?}
FFilePath : String; {????名.????張子付?}
FFileName : String; {????????張子???????名}
FFileOpened : Boolean; {Word文書?開?????True}
FFileChanged : Boolean; {文書?更????}
FHeaderFooterPrint : Boolean; {???????部?印刷???}
FPrintPageType : Integer; {印刷??頁?指定.0:全?,1:奇?頁,2:偶?頁}
FPrinterNo : Integer; {????番?}
FIniFilePath : String; {Ini?????保存場所}
FwdShape : WordShape; {現在操作?象?Shape??????}
FwdRange : WordRange; {現在?Range??????}
FOnAfterWordFileOpen : TNotifyEvent; {WebBrowser?文書表示後??生??????}
FOnAfterWordOpen : TNotifyEvent; {WebBrowser?最初?文書表示後??生??????}
FOnBeforeWordFileClose : TNotifyEvent; {Word?文書?閉??前??生}
FOnBeforeWordFileOpen : TNotifyEvent; {Word文書?開?前??生}
FOnBeforeWordFileSave : TNotifyEvent; {保存??????開?前}
FOnAfterWordFileSave : TNotifyEvent; {Wond文書保存後??生.保存??????無?係} procedure CheckFileSaved;
procedure SetRulers(Flg: Boolean);
procedure WMActivate(var Msg: TWMActivate); message WM_ACTIVATE;
procedure CMShowingChanged(var Msg:TMessage);Message CM_SHOWINGCHANGED;
procedure WordFileOpenSub(FName: String);
procedure SetComboBoxItem(H: HWND; Item: Integer);
procedure MoveFocusByTab(H:HWND; Cnt: Integer); {Ver5.6?追加}
procedure InputStateCancel;
public
{SetFocusWord?Ver5.6?追加}
procedure SetFocusWord;
function WordFileOpen(FName: String): Boolean;
function WordFileSave(FName: String): Boolean;
function FileCheck(OpenFilePath: String): Boolean;
procedure WordPrintOut(FirstPage,LastPage,PCopies:Integer; HeaderFlg:Boolean=True);
procedure ReplaceBookMark(BookName,UserStr: String);
procedure ReplaceString(Str,UserStr:String);
procedure AddRow(TblNo:Integer);
procedure PutCellString(TblNo,Row,Col:Integer;Str:String);
procedure PutCellText(TblNo,Row,Col:Integer;Str:String);
procedure AddRowCopy(TblNo:Integer);
procedure AddRowEx(TblNo,Row:Integer;Col:Integer=0);
procedure AddTitleRowCopy(TblNo: Integer); {以下8行Ver5.7?追加}
procedure ClearRow(TblNo,ARow: Integer);
procedure ClearRowEx(TblNo,ARow,InnerRowCnt,TitleRowCnt: Integer);
procedure DeleteRow(TblNo,aRow:Integer);
procedure DeleteRowEx(TblNo,ARow,InnerRowCnt,TitleRowCnt: Integer);
procedure InsertRow(TblNo,ARow: Integer; Direction: Integer=1);
procedure InsertRowEx(TblNo,ARow,InnerRowCnt,TitleRowCnt: Integer; Direction: Integer=1);
function GetSelectRowCol(var ARow,ACol: Integer): Boolean;
function GetSelectRowColEx(var ARow,ACol: Integer; InnerRowCnt,TitleRowCnt:Integer): Boolean; function PutTextBoxEx(Item, LineSpace, FontSize:Integer;
FontName:String; Alignment:Integer; Str: String): Boolean;
function PutTextBoxExSP(Item:String; LineSpace, FontSize:Integer;
FontName:String; Alignment:Integer; Str: String): Boolean;
function PutTextBox(Item:Integer;Str: String): Boolean;
function PutTextBoxSP(Item,Str: String):Boolean;
function PutShape(Left,Top,Width,Height: Integer; FileName: String): Boolean;
procedure PutLine(Xb,Xe,Yb,Ye,LineWidth:Integer;LineStyle:TPenStyle; Color: TColor);
procedure PutBox(Xb,Xe,Yb,Ye,LineWidth:Integer;LineStyle:TPenStyle; Color: TColor);
procedure PutCircle(Xb,Xe,Yb,Ye,LineWidth: Integer;LineStyle:TPenStyle; Color: TColor);
procedure PutArrow(Xb,Xe,Yb,Ye,LineWidth:Integer;LineStyle:TPenStyle; Color:TColor; BeginArrow,EndArrow: Boolean);
function GetBookMarkText(BookName: String): String;
function GetTextBoxText(Item: Integer): String;
function GetTextBoxTextSP(Item: String): String;
function GetCellText(TblNo,Row,Col: Integer): String;
procedure JumpPage(PageNo: Integer);
procedure InsertFile(FileName:String;InsertType:Integer);
procedure WordDisplayComplete(Sender: TObject;const pDisp: IDispatch; var URL: OleVariant); property WordVersion : String read FWordVersion;
property WordVersionNo : Integer read FWordVersionNo;
property WordDispSize : OleVariant read FWordDispSize write FWordDispSize;
property WebBrowser : TWebBrowser read FWebBrowser write FWebBrowser;
property WordApp : TWordApplication read FWordApp write FWordApp;
property WordDoc : TWordDocument read FWordDoc write FWordDoc;
property FileExt : String read FFileExt write FFileExt;
property DefaultFilePath : String read FDefaultFilePath write FDefaultFilePath;
property SaveFolderPath : String read FSaveFolderPath write FSaveFolderPath;
property FilePath : String read FFilePath write FFilePath;
property FileName : String read FFileName write FFileName;
property FileOpened : Boolean read FFileOpened;
property FileChanged : Boolean read FFileChanged write FFileChanged;
property HeaderFooterPrint : Boolean read FHeaderFooterPrint write FHeaderFooterPrint;
property PrintPageType : Integer read FPrintPageType write FPrintPageType;
property PrinterNo : Integer read FPrinterNo write FPrinterNo;
property IniFilePath : String read FIniFilePath write FIniFilePath;
property wdShape : WordShape read FwdShape write FwdShape;
property wdRange : WordRange read FwdRange write FwdRange;
property OnAfterWordFileOpen : TNotifyEvent read FOnAfterWordFileOpen write FOnAfterWordFileOpen;
property OnAfterWordOpen : TNotifyEvent read FOnAfterWordOpen write FOnAfterWordOpen;
property OnBeforeWordFileClose : TNotifyEvent read FOnBeforeWordFileClose write FOnBeforeWordFileClose;
property OnBeforeWordFileOpen : TNotifyEvent read FOnBeforeWordFileOpen write FOnBeforeWordFileOpen;
property OnBeforeWordFileSave : TNotifyEvent read FOnBeforeWordFileSave write FOnBeforeWordFileSave;
property OnAfterWordFileSave : TNotifyEvent read FOnAfterWordFileSave write FOnAfterWordFileSave;
end; type
TplWordDialogThread = class(TThread)
protected
procedure Execute; override;
private
procedure SendEnter;
public
end; var
plWordForm : TplWordForm;
wdHandle : HWND; {????????}
wdProcessID : DWORD;{Word?????ID} implementation {$R *.DFM} const
InfoS1='現在?同名?文書??.置換????. ';
InfoS3='??文書?他?方?使用中??.使用?????. ' #13#10 ' ';
InfoS4='指定??文書?見??????.文書名?確認??下??. ' #13#10 ' ';
InfoS5='起動時?開?文書?設定???????. ' #13#10 ' ';
InfoS6='??文書??更??????.保存????? ';
InfoS7='????起動中?利用?????. ';
var
{???利用?考????類?名??整備(Ver5.6)}
{wdProcessID?????????移動}
// wdProcessID : DWORD; {Word?????ID}
ProcessID : DWORD; {本??????????ID}
hwdProcess : THandle; {Wrod?????ID?????} fgSavePropertiesPrompt: Boolean; {保存時?文書?????入力???}
fgRulers: WordBool; {???表示????}
fgShowAll: Boolean; {全?表示}
fgParagraphs: Boolean; {段落記?表示????}
fgSpaces: Boolean; {空白記?表示????}
fgTabs: Boolean; {??記?表示????}
fgTableLines: Boolean; {表????????表示????}
fgFunctionKeys : Boolean; {???????表示????}
FPrinting : Boolean; {印刷中????}
WBpCopies : OleVariant; {印刷部?}
WBpFrom : OleVariant; {印刷開始頁}
WBpTo : OleVariant; {印刷終了頁}
OldFilePath : String; {保存前?文書?????} {TplWordDialogThread} //==================================================================
// ???印刷??????[Enter]?送????????
//
// TPrintDialog????OnShow??????????????代用
//==================================================================
procedure TplWordDialogThread.Execute;
begin
FreeOnTerminate:=True;
SendEnter;
end; procedure TplWordDialogThread.SendEnter;
begin
Sleep(100);
SendKeys('{ENTER}',True);
end; //TplWordForm
//==================================================================
// ini?????定義????表示用?????作成
//
// 開??????????設定??保存先??更??場合?,Ini???
// ??????書?換???,Ini?????設定??更???.
// Ini?????????[RegManager]??索???Ok??.
//
// 2003.05.05
// ????起動中??起動可能???
// ????先?終了??時,???操作?????文書???表示??
// ????態?終了???TWordApplication?正常終了????,使用
// ??問題?????明確??????.
//==================================================================
procedure TplWordForm.FormCreate(Sender: TObject);
var
AIniFilePath : String;
begin
FFilePath :=''; {文書?未表示}
FFileExt :='doc'; {??????張子}
FDefaultFilePath :=''; {呼出文書名}
FSaveFolderPath :=''; {保存先????}
FFileOpened :=False; {?然文書?開?????}
FFileChanged :=False; {?然?更???}
FWordVersionNo :=0; {????????番?初期化}
FHeaderFooterPrint :=True; {??????部?印刷??}
FPrinting :=False; {印刷中????}
FPrintPageType :=0; {印刷?全頁} {IniFile}
AIniFilePath:=GetCurrentDir '\' ExtractFileName(ChangeFileExt(Application.ExeName,'.ini'));
if FIniFilePath='' then FIniFilePath:=AIniFilePath;
if FileExists(FIniFilePath) then begin
RegManager1.IniFileName:=FIniFilePath;
{Form?表示位置等?情報?INI???????出?}
plOpenDialog1.FormTop :=RegManager1['PlWordListFormTop'].AsInteger;
plOpenDialog1.FormLeft :=RegManager1['plWordListFormLeft'].AsInteger;
plOpenDialog1.FormWidth :=RegManager1['plWordListFormWidth'].AsInteger;
plOpenDialog1.FormHeight :=RegManager1['plWordListFormHeight'].AsInteger;
plSaveDialog1.FormTop :=plOpenDialog1.FormTop;
plSaveDialog1.FormLeft :=plOpenDialog1.FormLeft;
plSaveDialog1.FormWidth :=plOpenDialog1.FormWidth;
plSaveDialog1.FormHeight :=plOpenDialog1.FormHeight;
{表示?????出?}
FWordDispSize :=RegManager1['plWordStartDispSize'].AsInteger;
{????番???出?}
FPrinterNo :=RegManager1['plWordPrinterNo'].AsInteger;
{起動時??出?文書名}
FDefaultFilePath:=RegManager1['plWordDefaultFilePath'].AsString;
{作成澄??文書?保存先?????}
FSaveFolderPath:=RegManager1['plWordSaveFolderPath'].AsString;
end;
{作成澄??文書?保存先?????}
if FSaveFolderPath='' then FSaveFolderPath:=ExtractFilePath(Application.Exename);
end;
//==================================================================
// 日本語入力未?換????終了???????生??Word?????
// ?????????入力中??換????????
// (Ver5.6?追加)
//==================================================================
procedure TplWordForm.InputStateCancel;
begin
PostMessage(wdHandle,WM_KEYDOWN,VK_ESCAPE,0);
PostMessage(wdHandle,WM_KEYUP,VK_ESCAPE,0);
end;
//==================================================================
// ?????表示
// TWordApplication??????
// FDefaultFilePath????文書?開???????行
//==================================================================
procedure TplWordForm.FormShow(Sender: TObject);
begin
OldFilePath:='';
FWordApp:=TWordApplication.Create(Self);
FWordDoc:=TWordDocument.Create(Self);
WordFileOpen(FDefaultFilePath);
end;
//==================================================================
// Form表示終了後
// ?????文書?FDefaultFilePath???場合???旨?警告表示
//==================================================================
procedure TplWordForm.CMShowingChanged(var Msg: TMessage);
begin
inherited;
Update;
if Visible then begin
if FDefaultFilePath='' then begin
Update;
{表示?????起動時?文書????????前???削除}
{2003.4.6}
// Application.MessageBox(PChar(InfoS5),'起動時文書',MB_OK MB_ICONWARNING);
end;
end;
end;
//==================================================================
// ?????開????????
// ????一???選????
// ?????????名?FFilePath?
// ??????張子?除??FFileName?返?
//==================================================================
procedure TplWordForm.FileOpenBtnClick(Sender: TObject);
var
pFilePath: String;
begin
if FFileOpened then begin
{表示形式???????場合?考??印刷?????表示?????}
FWordApp.ActiveWindow.ActivePane.View.SeekView:=wdSeekMainDocument;
{現文書??更???????必要??保存}
CheckFileSaved;
end;
{既存文書?一??表示}
plOpenDialog1.Directory :=ExtractFileDir(FSaveFolderPath);
plOpenDialog1.FileExt :=FFileExt;
if plOpenDialog1.Execute then begin
Self.Update;
pFilePath:=plOpenDialog1.FilePath;
FFileChanged:=False;
WordFileOpen(pFilePath);
end;
{??????????合??}
plSaveDialog1.FormTop :=plOpenDialog1.FormTop;
plSaveDialog1.FormLeft :=plOpenDialog1.FormLeft;
plSaveDialog1.FormWidth :=plOpenDialog1.FormWidth;
plSaveDialog1.FormHeight:=plOpenDialog1.FormHeight;
end;
//==================================================================
// 開????????????????理
// 起動時?呼出?文書?指定??.指定??文書(????名)?ini??
// ???記???.
// ?理後?FDefaultFilePath(????名)?FFileName(????張子?
// 除??????名)?返?
// 文書一?表示??拙作???????使用
//==================================================================
procedure TplWordForm.DefaultFileSelectClick(Sender: TObject);
var
AText: String;
begin
AText:='Word文書 |*.' FFileExt ';}*.dot';
OpenDialog1.Filter:=AText;
OpenDialog1.FileName:=FDefaultFilePath;
if OpenDialog1.Execute then begin
{?????????名}
FDefaultFilePath:=OpenDialog1.FileName;
WordFileOpen(FDefaultFilePath);
end;
end;
//==================================================================
// 新規文書作成???????時?動作
//
// ??型???文書???呼出???,利用者?作成??下??.
// 2003.05.05 追加
//==================================================================
procedure TplWordForm.NewFileBtnClick(Sender: TObject);
begin
//
end;
//==================================================================
// 保存???
// 保存先?????一定???InputBox????????????
// 保存???保存先?FFilePath(????名)?FFileName(名前??)?
// 返?
// 2003.01.20 一部改
// 2003.02.08 WordFileSave追加?伴?????更
// 2003.04.18 OnBeforeWordFileSave?係????追加
//==================================================================
procedure TplWordForm.SaveBtnClick(Sender: TObject);
var
pFilePath : String;
begin
if FFileOpened=False then exit;
{表示形式???????場合?考??印刷?????表示?????}
FWordApp.ActiveWindow.ActivePane.View.SeekView:=wdSeekMainDocument;
if Assigned(FOnBeforeWordFileSave) then FOnBeforeWordFileSave(Self); plSaveDialog1.Directory :=FSaveFolderPath; {保存先????}
plSaveDialog1.FileExt :=FFileExt; {?張子}
plSaveDialog1.FileName :=FFileName; {????名?欄}
if plSaveDialog1.Execute then begin
Self.Update;
pFilePath:=plSaveDialog1.FilePath;
{保存?行.FFilePath?FFileName?返????}
WordFileSave(pFilePath);
end;
{文書?開???????????位置?同????}
plOpenDialog1.FormTop :=plSaveDialog1.FormTop;
plOpenDialog1.FormLeft :=plSaveDialog1.FormLeft;
plOpenDialog1.FormWidth :=plSaveDialog1.FormWidth;
plOpenDialog1.FormHeight:=plSaveDialog1.FormHeight;
end;
//==================================================================
// 上書保存???
// 2003.04.18 追加
// 2003.04.18 OnBeforeWordFileSave?係????追加
// 2003.06.29 保存文書名?確???????SaveAs?引??????
// ??名?追加
//==================================================================
procedure TplWordForm.OverWriteBtnClick(Sender: TObject);
var
pFilePath: OleVariant;
begin
pFilePath:=FFilePath;
try
FWordDoc.SaveAs(pFilePath);
FFileChanged:=False;
if Assigned(FOnAfterWordFileSave) then FOnAfterWordFileSave(Self);
except
end;
end;
//==================================================================
// 2003.02.08 追加
// 保存??????表示????文書?保存.上書?確認???
// 成功???True,失敗???False?返?
// FName?????名?与??
// ????????行???以下?????????
// FFilePath 文書?????名
// FFileName 文書名(名前??)
// 2003.04.18 OnBeforeWordFileSave?係????追加
// 2003.04.18 OnAfterWordFileSave?係????追加
// 2003.05.05 保存後??出??行??????
// 前?文書名?保存?????,??文書??出?時?判
// ????????(FileCheck)
//==================================================================
function TplWordForm.WordFileSave(FName: String): Boolean;
var
LowFName : String;
ExtLowFName : String;
pFilePath : OleVariant;
pFileFormat : OleVariant;
pLockComments : OleVariant;
pPassword : OleVariant;
pAddToRecent : OleVariant;
pWritePassword : OleVariant;
pReadOnly : OleVariant;
AExt : String;
OldFilePathOle : OleVariant;
begin
Result:=False;
{保存文書?????現在?文書??????同???上書?保存}
if FName=FFilePath then begin
try
FWordDoc.SaveAs;
FFileChanged:=False;
if Assigned(FOnAfterWordFileSave) then FOnAfterWordFileSave(Self);
Result:=True;
except
end;
end else begin
{外部???利用?考??????}
if FFileOpened=False then exit;
{小文字????張子?有無???}
LowFName :=AnsiLowerCase(FName);
{文書名???張子?取得}
ExtLowFName :=ExtractFileExt(LowFName);
{?張子?'.' FFileExe???場合?FName?追加??}
AExt:=AnsiLowerCase('.' FFileExt);
if Pos(AExt,ExtLowFName)=0 then begin
pFilePath:=FName '.' FFileExt;
end else begin
pFilePath:=FName;
end; pFileFormat :=wdFormatDocument;
pLockComments :=False;
pPassWord :='';
pAddToRecent :=False;
pWritePassWord:='';
pReadOnly :=False;
try
{?際?保存 引??省略不可}
FWordDoc.SaveAs(
pFilePath, {保存????名}
pFileFormat, {保存形式}
pLockComments, {?取??用指定}
pPassWord, {文書?出??????指定}
pAddToRecent, {????編集履??追加指定}
pWritePassWord,{文書保存?????指定}
pReadOnly, {?出??用指定}
EmptyParam, {TrueType????埋??}
EmptyParam, {???????係}
EmptyParam, {????使用????保存}
EmptyParam); {????情報?保存}
{前?文書?????名?保存}
OldFilePath :=FFilePath;
OldFilePathOle:=FFilePath;
{新??文書?????}
FFilePath:=pFilePath;
{?張子?除??名前??取得}
FFileName:=ChangeFileExt(ExtractFileName(FFilePath),'');
{Form???????}
Self.Caption:=FFileName;
{?際??以下?3行?????????同?}
if Assigned(FOnAfterWordFileSave) then FOnAfterWordFileSave(Self);
FFileChanged:=False;
Result:=True;
except
LockWindowUpdate(0);
Result:=False;
end;
end;
Screen.Cursor:=crDefault;
end;
//==================================================================
// 保存???????????????理
// 作成???文書?呼出?????(文書?保存先????)?指定
// ?理後?FSaveFolderPath?返?(?????最後?\?付加)
// 拙作??????使用
//==================================================================
procedure TplWordForm.SaveFolderSelectClick(Sender: TObject);
var
CurDir: String;
begin
with plBrowseFolder1 do begin
InitDir:=FSaveFolderPath; {表示開始時?現在設定??????選??態?}
if Execute then begin
CurDir:=Directory;
{末尾?\????付加}
CurDir:=IncludeTrailingBackslash(CurDir);
FSaveFolderPath:=CurDir; {保存先????名???設定}
end;
end;
end;
//==================================================================
// ???????設定??????表示??設定
//==================================================================
procedure TplWordForm.PageSetBtnClick(Sender: TObject);
begin
if not FFileOpened then exit;
FWordApp.ActiveWindow.ActivePane.View.SeekView:=wdSeekMainDocument;
Application.ProcessMessages;
FWordApp.Dialogs.Item(wdDialogFilePageSetup).Show(EmptyParam);
end;
//==================================================================
// 印刷???
// Delphi?TPrintDialog?表示??設定
// ??????設定可能???,????名,印刷頁?指定,印刷部?
// ??他,???上?以下?????????使用
//
// HeaderFooterPrint ??????部?印刷???
// True 印刷??
// False 印刷???
// PrinterNo ????番?(Printer.PrinterIndex????)
// 印刷??????????????上???番?
// 0?一番上?????
// PrintPageType 印刷頁?種類
// 0 全??頁?印刷
// 1 奇?頁??印刷
// 2 偶?頁??印刷
//
// ??????設定???無????使用不可?(OnPrintDialogShow?)
// ????.
// ?????操作??????文書?表示?TWebBrowser?使用????
// ??,????印刷??????表示?????直接表示????.?
// ?PrintOut??????印刷頁?印刷部??指定?無????????}
// ??TWebBrowser?ExecWB?????使用????.
//==================================================================
procedure TplWordForm.PrintBtnClick(Sender: TObject);
var
StartP,StopP,CopyP: Integer;
begin
if not FFileOpened then exit; with PrintDialog1 do begin
{印刷範?指定可能??????????開?}
PrintDialog1.Options := [poPageNums];
{印刷範?指定?場合?開始頁?,Word?現在?頁}
FromPage:=FWordApp.Selection.Information[wdActiveEndPageNumber];
MinPage:=1;
{印刷範?指定?場合?終了頁?,Word?現在?頁}
ToPage:=FromPage;
{指定可能頁??,現在?Word文書?頁?}
MaxPage:=FWordApp.Selection.Information[wdNumberOfPagesInDocument];
{印刷部??1}
Copies:=1;
PrintRange:=prAllPages;
if Execute then begin
if PrintRange=prAllPages then begin
StartP:=1;
StopP :=MaxPage;
end else if PrintRange=prPageNums then begin
StartP:=PrintDialog1.FromPage;
StopP :=PrintDialog1.ToPage;
end else begin
exit;
end;
{印刷部?}
CopyP:=PrintDialog1.Copies;
{印刷用??????呼出?}
WordPrintOut(StartP,StopP,CopyP,True);
end;
end;
end;
//==================================================================
// TPrintDialog?開??時??理
//
// 日本語入力FEP?起動?不可???
// ??????設定????使用不可?(??設定?印刷?反映????)
// FPrinterNo??????????????????Item?選?
//==================================================================
procedure TplWordForm.PrintDialog1Show(Sender: TObject);
var
PrnName: array [0..255] of Char;
Wnd,CWnd: HWND;
begin
Wnd:=PrintDialog1.Handle;
{????入力?????日本語FEP?起動不可?}
SetImeMode(Wnd,imDisable);
{?????????使用不可???}
CWnd:=GetDlgItem(Wnd,1025);
EnableWindow(CWnd,False);
{????名???????????????選?}
CWnd:=GetDlgItem(Wnd,1139);
SendMessage(CWnd,CB_SETCURSEL,FPrinterNo,0);
{??????名?文字列?取得}
GetWindowText(CWnd,PrnName,256);
{????名?表示用?????????取得??????名?表示}
{??????起動後,最初???????表示??時??必要}
CWnd:=GetDlgItem(Wnd,1098);
SetWindowText(CWnd,PrnName);
end;
//==================================================================
// 閉??前?????名???????????????取得保存
//==================================================================
procedure TplWordForm.PrintDialog1Close(Sender: TObject);
var
CWnd: HWND;
begin
CWnd:=GetDlgItem(PrintDialog1.Handle,1139);
FPrinterNo:=SendMessage(CWnd,CB_GETCURSEL,0,0);
end;
//==================================================================
// ?際?印刷
// ???????外部???利用可能
// FirstPage 印刷開始頁番?
// LastPage 印刷終了頁番?
// PCopies 印刷部?
//
// 引?以外?以下???????現在??用??印刷??
// PrinterNo ????番?(Printer.PrinterIndex????)
// 印刷??????????????上???番?
// 0?一番上?????
// PrintPageType 印刷頁?種類
// 0 全??頁?印刷
//
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |