home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2001 September
/
Chip_2001-09_cd1.bin
/
zkuste
/
delphi
/
nastroje
/
d5
/
5EXCELRE.ZIP
/
START
/
OTCNASTR.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1999-10-29
|
3KB
|
112 lines
unit Otcnastr;
interface
uses
SysUtils, Windows, Messages, Classes, Graphics, Controls,
Forms, Dialogs, Buttons, Report,DB, StdCtrls,
ExtCtrls, SHELLAPI,DBTables;
type
TForm_nastr = class(TForm)
SpeedButton1: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton5: TSpeedButton;
Report1: TReport;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
rg1: TRadioGroup;
procedure SpeedButton5Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
FileNamerpt : ShortString;
Function WinExecAndWait(var Path : ShortString; Visibility : word) : word;
Function WEWExcell(var Pth : ShortString; Visibility : word) : word;
end;
var Form_nastr: TForm_nastr;
implementation
{$R *.DFM}
//Uses IniFiles;
procedure TForm_nastr.SpeedButton5Click(Sender: TObject);
begin
Close
end;
procedure TForm_nastr.SpeedButton1Click(Sender: TObject);
begin
OpenDialog1.FilterIndex:=RG1.ItemIndex+1;
if OpenDialog1.Execute then
FileNamerpt := OpenDialog1.FileName;
end;
Function TForm_nastr.WinExecAndWait(var Path : Shortstring; Visibility : word) : word;
var InstanceID : THandle;
begin
{ Try to run the application }
InstanceID := ShellExecute(0,nil,'wordrep.exe',@Path[1],nil,SW_HIDE); {WinExec(@Path,Visibility);}
if InstanceID < 32 then Result:= InstanceID // error
else begin
Repeat
Application.ProcessMessages;
until Application.Terminated ;
Result := 32;
end;
end;
Function TForm_nastr.WEWExcell(var Pth : ShortString; Visibility : word) : word;
var InstanceID : THandle;
sd,ss : ShortString;
begin
Pth:=Pth+#0;
ss:=Pth;
ss:=ExtractFilePath(Paramstr(0));
{Path:=ExtractFileName(Path)+#0;}
GetDir(0,sd);
ChDir(ss);
InstanceID := ShellExecute(0,nil,'put_rep1.exe',@Pth[1],nil,SW_HIDE);
if InstanceID < 32 then Result := InstanceID { error }
else begin
Repeat
Application.ProcessMessages;
until Application.Terminated;
Result := 32;
end;
ChDir(sd);
end;
procedure TForm_nastr.SpeedButton3Click(Sender: TObject);
Const acTail:string[9]='reprptxls';
Var i :integer;
ss:Shortstring;
begin
ss := FileNamerpt;
i:=pos('.',ss);
if i>0 then ss:=copy(ss,1,i-1);
ss:=ss+'.'+Copy(acTail,RG1.ItemIndex*3+1,3)+#0;
case RG1.ItemIndex of
1: begin
Report1.ReportName := FileNamerpt ;
Report1.Run;
i:=32;
end;
0: i:=WinExecAndWait(ss,1);
2: i:=WEWExcell(ss,1);
end;
if i<32 then Application.MessageBox('Error','Attention',mb_OK+mb_IconHand+mb_TaskModal);
end;
procedure TForm_nastr.FormCreate(Sender: TObject);
begin
FileNameRpt:=''
end;
end.