当D7遇到WIN7打开文件的方式好象变了 我原来是D7在XP下的,如果在文件夹中双击打开工程文件,然后再点D7左上角的打开,候选文件中都是在同一个文件夹内的PAS文件,这样很方便对程序的编辑。现在装在WIN7下后,用同样的方式双击打开工程文件,再点左上角的打开,候选文件是上一次打开的文件夹,这样不得不再寻找当前文件夹的位置再打开文件,很烦,有没有什么方法设置成XP下那种只打开工程文件所在文件夹的内容? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 嗯。这是办法之一,但就是不明白WIN7下有没有方法设置成XP下那种样子。 以下代码的功能:1.所有已经保存的工程在标题上显示全路径2.Win 7下调整打开文件对话框的路径为当前项目的路径.首先把 $(DELPHI)\Source\ToolsAPI 加入到搜索搜索路径中,把以下代码复制到一个单元中并保存为IDEShowPath.pas;然后点菜单 Component -> Install Component... 弹出的窗口中,Package file name中选择???\borland\delphi7\Lib\dclusr.dpk,这个是用户自定义包,方便搞的,然后在Unit file name 一栏中,选择刚才保存的文件IDEShowPath.pas,然后点OK询问是否重新编译,选择YES,然后关闭Delphi 7,关闭过程中,选择保存 dclusr重新启动Delphi 7功能实现.//1.在Delphi 7的IDE的主窗口中显示项目全路径//2.在Win 7下调整打开文件对话框的路径为当前项目路径//由于使用了固定名称,所以只能在Delphi7中使用,其他版本自行调整//By 蓝色光芒unit IDEShowPath;interfaceprocedure Register;implementation{$IFDEF VER150} //只有Delphi 7.0用,其它版本相应调整Uses Windows, Messages, Forms, Dialogs, Classes, SysUtils , ToolsAPI;Type TNotifyOTAObject = class(TNotifierObject, IOTANotifier, IOTAIDENotifier) protected procedure FileNotification(NotifyCode: TOTAFileNotification; const FileName: string; var Cancel: Boolean); procedure BeforeCompile(const Project: IOTAProject; var Cancel: Boolean); overload; procedure AfterCompile(Succeeded: Boolean); overload; procedure HwndProc(var Message: TMessage); end;var Obj : TNotifyOTAObject; fOldHwndProc : TWndMethod; fFileName : String; liIndex : integer;procedure InitOpenDialogPath(Const Path : String);var i : integer;begin for i:=0 to Application.MainForm.ComponentCount-1 do begin if Application.MainForm.Components[i].ClassName='TOpenDialog' then begin TOpenDialog(Application.MainForm.Components[i]).InitialDir := Path; Break; end; end;end;procedure SetTextProc(var Message: TMessage);var fCaption , FileName : String; PJ : IOTAProject;begin PJ := GetActiveProject; if PJ<>NIL then FileName := PJ.FileName else if StrScan(PChar(Message.LParam) , '-')=NIL then FileName := '' else FileName := fFileName; if FileName='' then fCaption := 'Delphi 7' else begin fCaption := 'Delphi 7 - ' + FileName; InitOpenDialogPath(ExtractFilePath(FileName)); end; Message.LParam := integer(fCaption); fOldHwndProc(Message);end;{ TNotifyOTAObject }procedure TNotifyOTAObject.HwndProc(var Message: TMessage);begin if Message.Msg=WM_SETTEXT then SetTextProc(Message) else fOldHwndProc(Message);end;procedure TNotifyOTAObject.AfterCompile(Succeeded: Boolean);beginend;procedure TNotifyOTAObject.BeforeCompile(const Project: IOTAProject;var Cancel: Boolean);beginend;procedure TNotifyOTAObject.FileNotification(NotifyCode: TOTAFileNotification; const FileName: string; var Cancel: Boolean);begin if NotifyCode=ofnActiveProjectChanged then fFileName := FileName;end;procedure Register;begin Obj := TNotifyOTAObject.Create; fOldHwndProc := Application.MainForm.WindowProc; Application.MainForm.WindowProc := Obj.HwndProc; liIndex := (BorlandIDEServices as IOTAServices).AddNotifier(Obj);end;initializationfinalization Application.MainForm.WindowProc := fOldHwndProc; (BorlandIDEServices as IOTAServices).RemoveNotifier(liIndex);{$ELSE}procedure Register;beginend;{$ENDIF}end. 感谢,虽说稍有些复杂,但这个回答极精确地知道了我提问的意思,连我自己都没能表达清,其实我要问的正是以上所讲的:“Win 7下调整打开文件对话框的路径为当前项目的路径.” 这种总是,就是DELPHI7关联自己工程而出的错误的、我的测试环境如下:XPSP3+DELPHI7 测试OK、WIN7+DELPHI7 测试OK、 方法2条1)将打开方式指定即可2)重装安装DELPHI,让DELPHI自己关联一下即可 太感谢了kiboisme蓝色光芒 delphi问题 POP3接收邮件出错 Uneven size in DecodeToStream EmbeddedWB控件安装的问题? 为什么这个SQL不能运行? 各位大侠救救急!!救人一命胜造七级浮屠 哪里有DELPHI的反编译工具? 问一个很菜的问题,怎样设置客户数据集的Datasetfield 属性 求救:一个打印暂停的问题! 有关acrobat reader的问题 HELP! MDI的DLL子窗体中怎么实现快捷键功能啊 用delphi2010怎么在win7下自定义注册表定位的过程
1.所有已经保存的工程在标题上显示全路径
2.Win 7下调整打开文件对话框的路径为当前项目的路径.首先把 $(DELPHI)\Source\ToolsAPI 加入到搜索搜索路径中,
把以下代码复制到一个单元中并保存为IDEShowPath.pas;
然后点菜单 Component -> Install Component... 弹出的窗口中,Package file name中选择
???\borland\delphi7\Lib\dclusr.dpk,这个是用户自定义包,方便搞的,
然后在Unit file name 一栏中,选择刚才保存的文件IDEShowPath.pas,然后点OK
询问是否重新编译,选择YES,然后关闭Delphi 7,关闭过程中,选择保存 dclusr
重新启动Delphi 7功能实现.//1.在Delphi 7的IDE的主窗口中显示项目全路径
//2.在Win 7下调整打开文件对话框的路径为当前项目路径
//由于使用了固定名称,所以只能在Delphi7中使用,其他版本自行调整
//By 蓝色光芒
unit IDEShowPath;interfaceprocedure Register;implementation{$IFDEF VER150} //只有Delphi 7.0用,其它版本相应调整
Uses
Windows, Messages, Forms, Dialogs, Classes, SysUtils , ToolsAPI;Type
TNotifyOTAObject = class(TNotifierObject, IOTANotifier, IOTAIDENotifier)
protected
procedure FileNotification(NotifyCode: TOTAFileNotification;
const FileName: string; var Cancel: Boolean);
procedure BeforeCompile(const Project: IOTAProject; var Cancel: Boolean); overload;
procedure AfterCompile(Succeeded: Boolean); overload; procedure HwndProc(var Message: TMessage);
end;var
Obj : TNotifyOTAObject;
fOldHwndProc : TWndMethod;
fFileName : String;
liIndex : integer;procedure InitOpenDialogPath(Const Path : String);
var
i : integer;
begin
for i:=0 to Application.MainForm.ComponentCount-1 do begin
if Application.MainForm.Components[i].ClassName='TOpenDialog' then begin
TOpenDialog(Application.MainForm.Components[i]).InitialDir := Path;
Break;
end;
end;
end;procedure SetTextProc(var Message: TMessage);
var
fCaption , FileName : String;
PJ : IOTAProject;
begin
PJ := GetActiveProject;
if PJ<>NIL then FileName := PJ.FileName
else if StrScan(PChar(Message.LParam) , '-')=NIL then FileName := ''
else FileName := fFileName;
if FileName='' then fCaption := 'Delphi 7'
else begin
fCaption := 'Delphi 7 - ' + FileName;
InitOpenDialogPath(ExtractFilePath(FileName));
end;
Message.LParam := integer(fCaption);
fOldHwndProc(Message);
end;{ TNotifyOTAObject }
procedure TNotifyOTAObject.HwndProc(var Message: TMessage);
begin
if Message.Msg=WM_SETTEXT then SetTextProc(Message)
else fOldHwndProc(Message);
end;
procedure TNotifyOTAObject.AfterCompile(Succeeded: Boolean);
begin
end;
procedure TNotifyOTAObject.BeforeCompile(const Project: IOTAProject;var Cancel: Boolean);
begin
end;
procedure TNotifyOTAObject.FileNotification(NotifyCode: TOTAFileNotification;
const FileName: string; var Cancel: Boolean);
begin
if NotifyCode=ofnActiveProjectChanged then
fFileName := FileName;
end;procedure Register;
begin
Obj := TNotifyOTAObject.Create;
fOldHwndProc := Application.MainForm.WindowProc;
Application.MainForm.WindowProc := Obj.HwndProc;
liIndex := (BorlandIDEServices as IOTAServices).AddNotifier(Obj);
end;initialization
finalization
Application.MainForm.WindowProc := fOldHwndProc;
(BorlandIDEServices as IOTAServices).RemoveNotifier(liIndex);
{$ELSE}
procedure Register;
begin
end;
{$ENDIF}
end.
我的测试环境如下:
XPSP3+DELPHI7 测试OK、
WIN7+DELPHI7 测试OK、
1)将打开方式指定即可2)重装安装DELPHI,让DELPHI自己关联一下即可
蓝色光芒