5,392
社区成员
发帖
与我相关
我的任务
分享
//在Delphi 7的IDE的主窗口中显示项目全路径
//由于使用了固定名称,所以只能在Delphi7中使用,其他版本自行调整
//By 蓝色光芒
unit IDEShowPath;
interface
procedure Register;
implementation
{$IFDEF VER150} //只有Delphi 7.0用,其它版本相应调整
Uses
Windows, Messages, Forms, 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 SetTextProc(var Message: TMessage);
var
fCaption : String;
PJ : IOTAProject;
begin
PJ := GetActiveProject;
if PJ<>NIL then fCaption := 'Delphi 7 - ' + PJ.FileName
else if StrScan(PChar(Message.LParam) , '-')=NIL then fCaption := 'Delphi 7'
else fCaption := 'Delphi 7 - ' + fFileName;
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.