如题。
解决方案 »
- OLE Excel导出的时候可不可以保存为低版本的文件
- 大虾我的程序想调用FOXMAIL,然后从数据表里填入收件人地址,不知道如何做?
- 熟悉clientdataset和dbgrided的进来,一定给分
- 指针、结构,分不多,请大家帮忙!
- 关于Stream与Zlib的一个问题
- 关于修改表主键的问题
- 请问如何用Delphi7制作Win XP风格用户界面?
- 关于在delphi中用c++ builder中vcl原文件问题
- 用dbchart怎样画一条竖直的虚线?
- 如何屏蔽鼠标事件?
- 点击一个按钮就调开一个外部程序
- 求助:怎样为STRINGGRID和DRAWGRID的某一格设置颜色,并且将焦点放在这一格上!!!!!
TSaveDialog不可以满足要求吗
TSaveDialog动态的创建不就可以了吗
TOpenDialog,TSaveDialog 会在任务栏上有个空白的安钮,
而且对话框不是模式的,用户不小心点了后面的IE后,对话框
会跑到后面去,而IE此时又不能操作,让人十分迷惑。下面的两个函数就是已经包装好的API:function OpenFileDlg(H: THandle; InitFileName: String; FileExt: String='所有文件(*.*)|*.*'; Title: String='打开文件' ): String; function AllocFilterStr(const S: string): string;
var
P: PChar;
begin
Result := '';
if S <> '' then
begin
Result := S + #0;
P := AnsiStrScan(PChar(Result), '|');
while P <> nil do
begin
P^ := #0;
Inc(P);
P := AnsiStrScan(P, '|');
end;
end;
end;var
ofn : TOpenFileName;
tlt , cfn , flt : String;
begin
Result:='';
FillChar(ofn, SizeOf(TOpenFileName), 0);
if (Win32MajorVersion >= 5) and (Win32Platform = VER_PLATFORM_WIN32_NT) or // Win2k
((Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and (Win32MajorVersion >= 4) and (Win32MinorVersion >= 90)) then //WinME
ofn.lStructSize := SizeOf(TOpenFilename)
else
ofn.lStructSize := SizeOf(TOpenFilename) - (SizeOf(DWORD) shl 1) - SizeOf(Pointer); //subtract size of added fields
tlt:=Title; SetLength(tlt,MAX_PATH+1); tlt[Length(Title)+1]:=#0;
cfn:=InitFileName; SetLength(cfn,MAX_PATH+1); cfn[Length(InitFileName)+1]:=#0;
flt:=FileExt;
ofn.hwndOwner:=H;
ofn.hInstance:=HInstance;
ofn.lpstrFilter:=PChar(AllocFilterStr(flt));
ofn.lpstrFile:=PChar(cfn);
ofn.nMaxFile:=MAX_PATH;
ofn.lpstrTitle:=PChar(tlt);
ofn.nMaxFileTitle:=MAX_PATH;
ofn.Flags:=OFN_OVERWRITEPROMPT + OFN_PATHMUSTEXIST;
if GetOpenFileName(ofn) then
Result:=String(ofn.lpstrFile);
end;function SaveFileDlg(H: THandle; InitFileName: String; Title: String='保存文件'): String;
var
ofn : TOpenFileName;
tlt , cfn : String;
begin
Result:='';
FillChar(ofn, SizeOf(TOpenFileName), 0);
if (Win32MajorVersion >= 5) and (Win32Platform = VER_PLATFORM_WIN32_NT) or // Win2k
((Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and (Win32MajorVersion >= 4) and (Win32MinorVersion >= 90)) then // WinME
ofn.lStructSize := SizeOf(TOpenFilename)
else
ofn.lStructSize := SizeOf(TOpenFilename) - (SizeOf(DWORD) shl 1) - SizeOf(Pointer); // subtract size of added fields
tlt:=Title; SetLength(tlt,MAX_PATH+1); tlt[Length(Title)+1]:=#0;
cfn:=InitFileName; SetLength(cfn,MAX_PATH+1); cfn[Length(InitFileName)+1]:=#0;
ofn.hwndOwner:=H;
ofn.hInstance:=HInstance;
ofn.lpstrFile:=PChar(cfn);
ofn.nMaxFile:=MAX_PATH;
ofn.lpstrTitle:=PChar(tlt);
ofn.nMaxFileTitle:=MAX_PATH;
ofn.Flags:=OFN_OVERWRITEPROMPT + OFN_PATHMUSTEXIST;
if GetSaveFileName(ofn) then
Result:=String(ofn.lpstrFile);
end;
unit OSDialogLib;interfaceuses
Windows,SysUtils,Dialogs,Forms;function ShowOpenDialog():PChar;stdcall;
function ShowSaveDialog():PChar;stdcall;implementation//显示打开文件对话框
function ShowOpenDialog():PChar;stdcall;
var
OpenDialog: TOpenDialog;
FileName: String;
begin
Result := PChar('');
Application.Handle := GetActiveWindow();
OpenDialog := TOpenDialog.Create(Application);
OpenDialog.Filter := 'NOTES数据库(*.nsf)|*.nsf';
//设置路径和文件必须存在
OpenDialog.Options := OpenDialog.Options + [ofPathMustExist, ofFileMustExist]; if OpenDialog.Execute() then
begin
FileName := OpenDialog.FileName;
if Pos('nsf',FileName) <= 0 then FileName := FileName + '.nsf';
Result := PChar(FileName);
OpenDialog.Free;
end;
end;//保存打开文件对话框
function ShowSaveDialog():PChar;stdcall;
var
SaveDialog: TSaveDialog;
FileName: String;
begin
Result := PChar('');
Application.Handle := GetActiveWindow();
SaveDialog := TSaveDialog.Create(Application);
SaveDialog.Filter := 'NOTES数据库(*.nsf)|*.nsf'; if SaveDialog.Execute() then
begin
FileName := SaveDialog.FileName;
if Pos('nsf',FileName) <= 0 then FileName := FileName + '.nsf';
Result := PChar(FileName);
SaveDialog.Free;
end;
end;end.
unit OSDialogLib;interfaceuses
Windows,SysUtils,Dialogs,Forms;function ShowOpenFileDialog(const DialogPrompt:PChar;
const DefaultFileName:PChar;
const FileFilter:PChar):PChar; stdcall;
function ShowSaveFileDialog(const DialogPrompt:PChar;
const DefaultFileName:PChar;
const FileFilter:PChar):PChar; stdcall;implementation//显示打开文件对话框
function ShowOpenFileDialog(const DialogPrompt:PChar;
const DefaultFileName:PChar;
const FileFilter:PChar):PChar; stdcall;
var
OpenFileDialog: TOpenDialog;
FileNameA: String;
FileName: String;
begin
Result := PChar('');
Application.Handle := GetActiveWindow();
OpenFileDialog := TOpenDialog.Create(Application);
OpenFileDialog.Filter := StrPas(FileFilter);
OpenFileDialog.Title := StrPas(DialogPrompt);
if OpenFileDialog.Title = '' then OpenFileDialog.Title := '打开';
//设置路径和文件必须存在
OpenFileDialog.Options := OpenFileDialog.Options + [ofPathMustExist, ofFileMustExist];
FileNameA := StrPas(DefaultFileName);
if FileNameA <> '' then OpenFileDialog.FileName := FileNameA; if OpenFileDialog.Execute() then
begin
FileName := OpenFileDialog.FileName;
if Pos('nsf',FileName) <= 0 then FileName := FileName + '.nsf';
Result := PChar(FileName);
OpenFileDialog.Free;
end;
end;//保存打开文件对话框
function ShowSaveFileDialog(const DialogPrompt:PChar;
const DefaultFileName:PChar;
const FileFilter:PChar):PChar; stdcall;
var
SaveFileDialog: TSaveDialog;
FileNameA: String;
FileName: String;
begin
Result := PChar('');
Application.Handle := GetActiveWindow();
SaveFileDialog := TSaveDialog.Create(Application);
SaveFileDialog.Filter := StrPas(FileFilter);
SaveFileDialog.Title := StrPas(DialogPrompt);
if SaveFileDialog.Title = '' then SaveFileDialog.Title := '另存为';
//设置提示用户文件已经存在
SaveFileDialog.Options := SaveFileDialog.Options + [ofOverwritePrompt];
FileNameA := StrPas(DefaultFileName);
if FileNameA <> '' then SaveFileDialog.FileName := FileNameA; if SaveFileDialog.Execute() then
begin
FileName := SaveFileDialog.FileName;
if Pos('nsf',FileName) <= 0 then FileName := FileName + '.nsf';
Result := PChar(FileName);
SaveFileDialog.Free;
end;
end;end.