我放了一个opendialog组件,写了同样一段程序,在xp环境下会起作用,会有提示‘不是文本文件’,在win7下就不会提示。
procedure TForm10.ToolButton1Click(Sender: TObject);
var
fname:string;
begin
with OpenDialog1 do
begin
Filter:='文本文件 .txt';
DefaultExt:= 'ini';
FileName:= '';
Options:= [ofHideReadOnly,ofFileMustExist,ofPathMustExist] ;
if Execute then
begin
if ofExtensionDifferent in Options then
MessageDlg('这不是文本文件',mtWarning,[mbYes],0)
else
begin
RichEdit1.Lines.LoadFromFile(OpenDialog1.FileName);
fname:= OpenDialog1.FileName;
StatusBar1.Panels[3].Text:= fname;
end;
end;
end;
end;1、问题是ofExtensionDifferent in Options不可能为true,因为前面options已经赋值了,不包含ofExtensionDifferent这个枚举,无法理解。2、为什么在win7这个条件ofExtensionDifferent in Options就始终是false,求教育。
procedure TForm10.ToolButton1Click(Sender: TObject);
var
fname:string;
begin
with OpenDialog1 do
begin
Filter:='文本文件 .txt';
DefaultExt:= 'ini';
FileName:= '';
Options:= [ofHideReadOnly,ofFileMustExist,ofPathMustExist] ;
if Execute then
begin
if ofExtensionDifferent in Options then
MessageDlg('这不是文本文件',mtWarning,[mbYes],0)
else
begin
RichEdit1.Lines.LoadFromFile(OpenDialog1.FileName);
fname:= OpenDialog1.FileName;
StatusBar1.Panels[3].Text:= fname;
end;
end;
end;
end;1、问题是ofExtensionDifferent in Options不可能为true,因为前面options已经赋值了,不包含ofExtensionDifferent这个枚举,无法理解。2、为什么在win7这个条件ofExtensionDifferent in Options就始终是false,求教育。
解决方案 »
- 分栏打印的问题!高手请进!!!
- 怎样连接网址,比如,连接到www.csdn.net?---delphi函数。在线等。。。
- 各位帮帮忙吧...散分200!
- 关于opc的一个问题—怎样自动查找节点设备?
- 急!!!送分!!!socket发送变长中文+字符数组
- TStrings问题。
- 急需答案
- 如何获取IE的版本信息?
- 我的Delphi6,为什么在DEBUG的时候,我把鼠标放在变量上,DELPHI不会显示变量的值了?以前还好好的
- 难题又来了。求助各位!(query查询)
- 判断是不是使用Advanced Configuration and Power Interface (ACPI) PC
- 请问 Delphi大神这个是个上面东西。'PkgMyCtrls'
Options:= [ofHideReadOnly,ofFileMustExist,ofPathMustExist]
然后判断
ofExtensionDifferent in Options
明明Options里面没有ofExtensionDifferent,执行起来(在xp下)却是true,为什么呢?
.....
TOpenDialog.Execute里的代码,后面修改了FOptions的值,
Result := TaskModalDialog(Func, OpenFileName);
if Result then
begin
GetFileNames(OpenFilename);
if (Flags and OFN_EXTENSIONDIFFERENT) <> 0 then
Include(FOptions, ofExtensionDifferent) else //这里
Exclude(FOptions, ofExtensionDifferent); //这里