首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

当D7碰到WIN7打开文件的方式好象变了

2013-01-11 
当D7遇到WIN7打开文件的方式好象变了我原来是D7在XP下的,如果在文件夹中双击打开工程文件,然后再点D7左上

当D7遇到WIN7打开文件的方式好象变了
我原来是D7在XP下的,如果在文件夹中双击打开工程文件,然后再点D7左上角的打开,候选文件中都是在同一个文件夹内的PAS文件,这样很方便对程序的编辑。现在装在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;

interface

procedure 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.

热点排行